prism 2.0.0.rc1-x86_64-linux-gnu
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/BSDmakefile +58 -0
- data/CHANGELOG.md +870 -0
- data/CODE_OF_CONDUCT.md +76 -0
- data/CONTRIBUTING.md +58 -0
- data/LICENSE.md +7 -0
- data/Makefile +145 -0
- data/README.md +81 -0
- data/config.yml +4752 -0
- data/docs/build_system.md +119 -0
- data/docs/configuration.md +69 -0
- data/docs/cruby_compilation.md +27 -0
- data/docs/design.md +53 -0
- data/docs/encoding.md +121 -0
- data/docs/fuzzing.md +81 -0
- data/docs/heredocs.md +36 -0
- data/docs/javascript.md +133 -0
- data/docs/local_variable_depth.md +229 -0
- data/docs/mapping.md +117 -0
- data/docs/parser_translation.md +24 -0
- data/docs/parsing_rules.md +22 -0
- data/docs/releasing.md +147 -0
- data/docs/relocation.md +32 -0
- data/docs/ripper_translation.md +63 -0
- data/docs/ruby_api.md +45 -0
- data/docs/ruby_parser_translation.md +19 -0
- data/docs/serialization.md +230 -0
- data/docs/testing.md +72 -0
- data/ext/prism/api_node.c +7005 -0
- data/ext/prism/extconf.rb +126 -0
- data/ext/prism/extension.c +1783 -0
- data/ext/prism/extension.h +19 -0
- data/include/prism/arena.h +37 -0
- data/include/prism/ast.h +10371 -0
- data/include/prism/buffer.h +52 -0
- data/include/prism/comments.h +55 -0
- data/include/prism/compiler/accel.h +24 -0
- data/include/prism/compiler/align.h +36 -0
- data/include/prism/compiler/assume.h +25 -0
- data/include/prism/compiler/exported.h +24 -0
- data/include/prism/compiler/fallthrough.h +22 -0
- data/include/prism/compiler/filesystem.h +32 -0
- data/include/prism/compiler/flex_array.h +19 -0
- data/include/prism/compiler/force_inline.h +21 -0
- data/include/prism/compiler/format.h +25 -0
- data/include/prism/compiler/inline.h +17 -0
- data/include/prism/compiler/nodiscard.h +22 -0
- data/include/prism/compiler/nonnull.h +18 -0
- data/include/prism/compiler/unused.h +18 -0
- data/include/prism/constant_pool.h +81 -0
- data/include/prism/diagnostic.h +93 -0
- data/include/prism/errors_format.h +53 -0
- data/include/prism/excludes.h +29 -0
- data/include/prism/integer.h +41 -0
- data/include/prism/internal/allocator.h +68 -0
- data/include/prism/internal/allocator_debug.h +88 -0
- data/include/prism/internal/arena.h +108 -0
- data/include/prism/internal/bit.h +42 -0
- data/include/prism/internal/buffer.h +91 -0
- data/include/prism/internal/char.h +145 -0
- data/include/prism/internal/comments.h +53 -0
- data/include/prism/internal/constant_pool.h +152 -0
- data/include/prism/internal/diagnostic.h +389 -0
- data/include/prism/internal/encoding.h +242 -0
- data/include/prism/internal/integer.h +68 -0
- data/include/prism/internal/isinf.h +16 -0
- data/include/prism/internal/line_offset_list.h +34 -0
- data/include/prism/internal/list.h +62 -0
- data/include/prism/internal/magic_comments.h +23 -0
- data/include/prism/internal/memchr.h +15 -0
- data/include/prism/internal/node.h +38 -0
- data/include/prism/internal/options.h +232 -0
- data/include/prism/internal/parser.h +984 -0
- data/include/prism/internal/regexp.h +26 -0
- data/include/prism/internal/serialize.h +39 -0
- data/include/prism/internal/source.h +72 -0
- data/include/prism/internal/static_literals.h +100 -0
- data/include/prism/internal/stringy.h +35 -0
- data/include/prism/internal/strncasecmp.h +18 -0
- data/include/prism/internal/strpbrk.h +33 -0
- data/include/prism/internal/tokens.h +11 -0
- data/include/prism/json.h +32 -0
- data/include/prism/line_offset_list.h +61 -0
- data/include/prism/magic_comments.h +35 -0
- data/include/prism/node.h +94 -0
- data/include/prism/options.h +354 -0
- data/include/prism/parser.h +404 -0
- data/include/prism/prettyprint.h +31 -0
- data/include/prism/serialize.h +115 -0
- data/include/prism/source.h +155 -0
- data/include/prism/stream.h +28 -0
- data/include/prism/string_query.h +63 -0
- data/include/prism/stringy.h +72 -0
- data/include/prism/version.h +38 -0
- data/include/prism.h +131 -0
- data/lib/prism/3.3/prism.so +0 -0
- data/lib/prism/3.4/prism.so +0 -0
- data/lib/prism/4.0/prism.so +0 -0
- data/lib/prism/compiler.rb +815 -0
- data/lib/prism/desugar_compiler.rb +463 -0
- data/lib/prism/dispatcher.rb +2383 -0
- data/lib/prism/dot_visitor.rb +4848 -0
- data/lib/prism/dsl.rb +1369 -0
- data/lib/prism/ffi.rb +740 -0
- data/lib/prism/inspect_visitor.rb +2425 -0
- data/lib/prism/lex_compat.rb +953 -0
- data/lib/prism/mutation_compiler.rb +780 -0
- data/lib/prism/node.rb +33204 -0
- data/lib/prism/node_ext.rb +504 -0
- data/lib/prism/node_find.rb +215 -0
- data/lib/prism/parse_result/errors.rb +72 -0
- data/lib/prism/parse_result/newlines.rb +423 -0
- data/lib/prism/parse_result.rb +1221 -0
- data/lib/prism/pattern.rb +314 -0
- data/lib/prism/polyfill/append_as_bytes.rb +15 -0
- data/lib/prism/polyfill/byteindex.rb +13 -0
- data/lib/prism/polyfill/scan_byte.rb +14 -0
- data/lib/prism/polyfill/unpack1.rb +14 -0
- data/lib/prism/polyfill/warn.rb +36 -0
- data/lib/prism/reflection.rb +427 -0
- data/lib/prism/relocation.rb +567 -0
- data/lib/prism/serialize.rb +5308 -0
- data/lib/prism/string_query.rb +46 -0
- data/lib/prism/translation/parser/builder.rb +70 -0
- data/lib/prism/translation/parser/compiler.rb +2226 -0
- data/lib/prism/translation/parser/lexer.rb +769 -0
- data/lib/prism/translation/parser.rb +376 -0
- data/lib/prism/translation/parser_current.rb +26 -0
- data/lib/prism/translation/parser_versions.rb +36 -0
- data/lib/prism/translation/ripper/filter.rb +53 -0
- data/lib/prism/translation/ripper/lexer.rb +133 -0
- data/lib/prism/translation/ripper/sexp.rb +118 -0
- data/lib/prism/translation/ripper/shim.rb +7 -0
- data/lib/prism/translation/ripper.rb +4278 -0
- data/lib/prism/translation/ruby_parser.rb +1721 -0
- data/lib/prism/translation.rb +20 -0
- data/lib/prism/visitor.rb +1440 -0
- data/lib/prism.rb +168 -0
- data/prism.gemspec +234 -0
- data/rbi/generated/prism/compiler.rbi +489 -0
- data/rbi/generated/prism/desugar_compiler.rbi +306 -0
- data/rbi/generated/prism/dispatcher.rbi +1138 -0
- data/rbi/generated/prism/dot_visitor.rbi +618 -0
- data/rbi/generated/prism/dsl.rbi +751 -0
- data/rbi/generated/prism/inspect_visitor.rbi +503 -0
- data/rbi/generated/prism/lex_compat.rbi +162 -0
- data/rbi/generated/prism/mutation_compiler.rbi +464 -0
- data/rbi/generated/prism/node.rbi +13681 -0
- data/rbi/generated/prism/node_ext.rbi +259 -0
- data/rbi/generated/prism/node_find.rbi +79 -0
- data/rbi/generated/prism/parse_result/errors.rbi +21 -0
- data/rbi/generated/prism/parse_result/newlines.rbi +208 -0
- data/rbi/generated/prism/parse_result.rbi +764 -0
- data/rbi/generated/prism/pattern.rbi +134 -0
- data/rbi/generated/prism/reflection.rbi +89 -0
- data/rbi/generated/prism/relocation.rbi +329 -0
- data/rbi/generated/prism/serialize.rbi +181 -0
- data/rbi/generated/prism/string_query.rbi +36 -0
- data/rbi/generated/prism/translation.rbi +7 -0
- data/rbi/generated/prism/visitor.rbi +650 -0
- data/rbi/generated/prism.rbi +86 -0
- data/rbi/prism/translation/parser.rbi +11 -0
- data/rbi/prism/translation/parser_versions.rbi +28 -0
- data/rbi/prism/translation/ripper.rbi +15 -0
- data/rbi/rubyvm/node_find.rbi +14 -0
- data/sig/generated/prism/compiler.rbs +492 -0
- data/sig/generated/prism/desugar_compiler.rbs +305 -0
- data/sig/generated/prism/dispatcher.rbs +1292 -0
- data/sig/generated/prism/dot_visitor.rbs +635 -0
- data/sig/generated/prism/dsl.rbs +928 -0
- data/sig/generated/prism/inspect_visitor.rbs +509 -0
- data/sig/generated/prism/lex_compat.rbs +166 -0
- data/sig/generated/prism/mutation_compiler.rbs +464 -0
- data/sig/generated/prism/node.rbs +20160 -0
- data/sig/generated/prism/node_ext.rbs +290 -0
- data/sig/generated/prism/node_find.rbs +90 -0
- data/sig/generated/prism/parse_result/errors.rbs +22 -0
- data/sig/generated/prism/parse_result/newlines.rbs +223 -0
- data/sig/generated/prism/parse_result.rbs +859 -0
- data/sig/generated/prism/pattern.rbs +156 -0
- data/sig/generated/prism/reflection.rbs +101 -0
- data/sig/generated/prism/relocation.rbs +428 -0
- data/sig/generated/prism/serialize.rbs +195 -0
- data/sig/generated/prism/string_query.rbs +36 -0
- data/sig/generated/prism/translation.rbs +8 -0
- data/sig/generated/prism/visitor.rbs +1111 -0
- data/sig/generated/prism.rbs +84 -0
- data/sig/manifest.yaml +2 -0
- data/src/arena.c +117 -0
- data/src/buffer.c +380 -0
- data/src/char.c +289 -0
- data/src/comments.c +454 -0
- data/src/constant_pool.c +406 -0
- data/src/diagnostic.c +886 -0
- data/src/encoding.c +5345 -0
- data/src/errors_format.c +519 -0
- data/src/integer.c +681 -0
- data/src/json.c +5733 -0
- data/src/line_offset_list.c +100 -0
- data/src/list.c +24 -0
- data/src/memchr.c +37 -0
- data/src/node.c +4515 -0
- data/src/options.c +451 -0
- data/src/parser.c +349 -0
- data/src/prettyprint.c +9024 -0
- data/src/prism.c +23739 -0
- data/src/regexp.c +1706 -0
- data/src/serialize.c +2309 -0
- data/src/source.c +518 -0
- data/src/static_literals.c +685 -0
- data/src/string_query.c +166 -0
- data/src/stringy.c +91 -0
- data/src/strncasecmp.c +37 -0
- data/src/strpbrk.c +447 -0
- data/src/tokens.c +724 -0
- metadata +259 -0
data/lib/prism.rb
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# :markup: markdown
|
|
3
|
+
#--
|
|
4
|
+
# rbs_inline: enabled
|
|
5
|
+
|
|
6
|
+
# The Prism Ruby parser.
|
|
7
|
+
#
|
|
8
|
+
# "Parsing Ruby is suddenly manageable!"
|
|
9
|
+
# - You, hopefully
|
|
10
|
+
#
|
|
11
|
+
module Prism
|
|
12
|
+
# There are many files in prism that are templated to handle every node type,
|
|
13
|
+
# which means the files can end up being quite large. We autoload them to make
|
|
14
|
+
# our require speed faster since consuming libraries are unlikely to use all
|
|
15
|
+
# of these features.
|
|
16
|
+
|
|
17
|
+
autoload :BasicVisitor, "prism/visitor"
|
|
18
|
+
autoload :Compiler, "prism/compiler"
|
|
19
|
+
autoload :DesugarCompiler, "prism/desugar_compiler"
|
|
20
|
+
autoload :Dispatcher, "prism/dispatcher"
|
|
21
|
+
autoload :DotVisitor, "prism/dot_visitor"
|
|
22
|
+
autoload :DSL, "prism/dsl"
|
|
23
|
+
autoload :InspectVisitor, "prism/inspect_visitor"
|
|
24
|
+
autoload :LexCompat, "prism/lex_compat"
|
|
25
|
+
autoload :MutationCompiler, "prism/mutation_compiler"
|
|
26
|
+
autoload :NodeFind, "prism/node_find"
|
|
27
|
+
autoload :Pattern, "prism/pattern"
|
|
28
|
+
autoload :Reflection, "prism/reflection"
|
|
29
|
+
autoload :Relocation, "prism/relocation"
|
|
30
|
+
autoload :Serialize, "prism/serialize"
|
|
31
|
+
autoload :StringQuery, "prism/string_query"
|
|
32
|
+
autoload :Translation, "prism/translation"
|
|
33
|
+
autoload :Visitor, "prism/visitor"
|
|
34
|
+
|
|
35
|
+
# Some of these constants are not meant to be exposed, so marking them as
|
|
36
|
+
# private here.
|
|
37
|
+
|
|
38
|
+
if RUBY_ENGINE != "jruby"
|
|
39
|
+
private_constant :LexCompat
|
|
40
|
+
private_constant :NodeFind
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Raised when requested to parse as the currently running Ruby version but Prism has no support for it.
|
|
44
|
+
class CurrentVersionError < ArgumentError
|
|
45
|
+
# Initialize a new exception for the given ruby version string.
|
|
46
|
+
#
|
|
47
|
+
#: (String version) -> void
|
|
48
|
+
def initialize(version)
|
|
49
|
+
message = +"invalid version: Requested to parse as `version: 'current'`; "
|
|
50
|
+
major, minor, =
|
|
51
|
+
if version.match?(/\A\d+\.\d+.\d+\z/)
|
|
52
|
+
version.split(".").map(&:to_i)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
if major && minor && ((major < 3) || (major == 3 && minor < 3))
|
|
56
|
+
message << " #{version} is below the minimum supported syntax."
|
|
57
|
+
else
|
|
58
|
+
message << " #{version} is unknown. Please update the `prism` gem."
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
super(message)
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# :call-seq:
|
|
66
|
+
# lex_compat(source, **options) -> LexCompat::Result
|
|
67
|
+
#
|
|
68
|
+
# Returns a parse result whose value is an array of tokens that closely
|
|
69
|
+
# resembles the return value of Ripper.lex.
|
|
70
|
+
#
|
|
71
|
+
# For supported options, see Prism.parse.
|
|
72
|
+
#
|
|
73
|
+
#: (String source, **untyped options) -> LexCompat::Result
|
|
74
|
+
def self.lex_compat(source, **options)
|
|
75
|
+
LexCompat.new(source, **options).result # steep:ignore
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# :call-seq:
|
|
79
|
+
# load(source, serialized, freeze) -> ParseResult
|
|
80
|
+
#
|
|
81
|
+
# Load the serialized AST using the source as a reference into a tree.
|
|
82
|
+
#
|
|
83
|
+
#: (String source, String serialized, ?bool freeze) -> ParseResult
|
|
84
|
+
def self.load(source, serialized, freeze = false)
|
|
85
|
+
Serialize.load_parse(source, serialized, freeze)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Given a Method, UnboundMethod, Proc, or Thread::Backtrace::Location,
|
|
89
|
+
# returns the Prism node representing it. On CRuby, this uses node_id for
|
|
90
|
+
# an exact match. On other implementations, it falls back to best-effort
|
|
91
|
+
# matching by source location line number.
|
|
92
|
+
#
|
|
93
|
+
#: (Method | UnboundMethod | Proc | Thread::Backtrace::Location callable) -> Node?
|
|
94
|
+
def self.find(callable)
|
|
95
|
+
NodeFind.find(callable)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# @rbs!
|
|
99
|
+
# VERSION: String
|
|
100
|
+
# BACKEND: :CEXT | :FFI
|
|
101
|
+
#
|
|
102
|
+
# interface _Stream
|
|
103
|
+
# def gets: (?Integer integer) -> (String | nil)
|
|
104
|
+
# end
|
|
105
|
+
#
|
|
106
|
+
# def self.parse: (String source, ?filepath: String, ?attach_comments: bool, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?raise_error: Symbol | true, ?scopes: Array[Array[Symbol]], ?version: String) -> ParseResult
|
|
107
|
+
# def self.profile: (String source, ?filepath: String, ?attach_comments: bool, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?raise_error: Symbol | true, ?scopes: Array[Array[Symbol]], ?version: String) -> void
|
|
108
|
+
# def self.lex: (String source, ?filepath: String, ?attach_comments: bool, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?raise_error: Symbol | true, ?scopes: Array[Array[Symbol]], ?version: String) -> LexResult
|
|
109
|
+
# def self.parse_lex: (String source, ?filepath: String, ?attach_comments: bool, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?raise_error: Symbol | true, ?scopes: Array[Array[Symbol]], ?version: String) -> ParseLexResult
|
|
110
|
+
# def self.dump: (String source, ?filepath: String, ?attach_comments: bool, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?raise_error: Symbol | true, ?scopes: Array[Array[Symbol]], ?version: String) -> String
|
|
111
|
+
# def self.parse_comments: (String source, ?filepath: String, ?attach_comments: bool, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?raise_error: Symbol | true, ?scopes: Array[Array[Symbol]], ?version: String) -> Array[Comment]
|
|
112
|
+
# def self.parse_success?: (String source, ?filepath: String, ?attach_comments: bool, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?raise_error: Symbol | true, ?scopes: Array[Array[Symbol]], ?version: String) -> bool
|
|
113
|
+
# def self.parse_failure?: (String source, ?filepath: String, ?attach_comments: bool, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?raise_error: Symbol | true, ?scopes: Array[Array[Symbol]], ?version: String) -> bool
|
|
114
|
+
# def self.parse_stream: (_Stream stream, ?filepath: String, ?attach_comments: bool, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?raise_error: Symbol | true, ?scopes: Array[Array[Symbol]], ?version: String) -> ParseResult
|
|
115
|
+
# def self.parse_file: (path filepath, ?attach_comments: bool, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?raise_error: Symbol | true, ?scopes: Array[Array[Symbol]], ?version: String) -> ParseResult
|
|
116
|
+
# def self.profile_file: (path filepath, ?attach_comments: bool, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?raise_error: Symbol | true, ?scopes: Array[Array[Symbol]], ?version: String) -> void
|
|
117
|
+
# def self.lex_file: (path filepath, ?attach_comments: bool, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?raise_error: Symbol | true, ?scopes: Array[Array[Symbol]], ?version: String) -> LexResult
|
|
118
|
+
# def self.parse_lex_file: (path filepath, ?attach_comments: bool, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?raise_error: Symbol | true, ?scopes: Array[Array[Symbol]], ?version: String) -> ParseLexResult
|
|
119
|
+
# def self.dump_file: (path filepath, ?attach_comments: bool, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?raise_error: Symbol | true, ?scopes: Array[Array[Symbol]], ?version: String) -> String
|
|
120
|
+
# def self.parse_file_comments: (path filepath, ?attach_comments: bool, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?raise_error: Symbol | true, ?scopes: Array[Array[Symbol]], ?version: String) -> Array[Comment]
|
|
121
|
+
# def self.parse_file_success?: (path filepath, ?attach_comments: bool, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?raise_error: Symbol | true, ?scopes: Array[Array[Symbol]], ?version: String) -> bool
|
|
122
|
+
# def self.parse_file_failure?: (path filepath, ?attach_comments: bool, ?command_line: String, ?encoding: Encoding | false, ?freeze: bool, ?frozen_string_literal: bool, ?line: Integer, ?main_script: bool, ?partial_script: bool, ?raise_error: Symbol | true, ?scopes: Array[Array[Symbol]], ?version: String) -> bool
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
require_relative "prism/polyfill/byteindex"
|
|
126
|
+
require_relative "prism/polyfill/warn"
|
|
127
|
+
require_relative "prism/node"
|
|
128
|
+
require_relative "prism/node_ext"
|
|
129
|
+
require_relative "prism/parse_result"
|
|
130
|
+
|
|
131
|
+
# This is a Ruby implementation of the prism parser. If we're running on CRuby
|
|
132
|
+
# and we haven't explicitly set the PRISM_FFI_BACKEND environment variable, then
|
|
133
|
+
# it's going to require the built library. Otherwise, it's going to require a
|
|
134
|
+
# module that uses FFI to call into the library.
|
|
135
|
+
if RUBY_ENGINE == "ruby" and !ENV["PRISM_FFI_BACKEND"]
|
|
136
|
+
# The C extension is the default backend on CRuby.
|
|
137
|
+
Prism::BACKEND = :CEXT
|
|
138
|
+
|
|
139
|
+
begin
|
|
140
|
+
# The precompiled native libraries are in <gem_dir>/lib/prism/<ruby_version>
|
|
141
|
+
require_relative "prism/#{RUBY_VERSION[/\d+\.\d+/]}/prism"
|
|
142
|
+
rescue LoadError => e
|
|
143
|
+
if e.message.include?("GLIBC")
|
|
144
|
+
warn(<<~EOM)
|
|
145
|
+
|
|
146
|
+
ERROR: It looks like you're trying to use Prism as a precompiled native gem on a system
|
|
147
|
+
with an unsupported version of glibc.
|
|
148
|
+
|
|
149
|
+
#{e.message}
|
|
150
|
+
|
|
151
|
+
If that's the case, then please install Prism via the `ruby` platform gem:
|
|
152
|
+
gem install prism --platform=ruby
|
|
153
|
+
or, in your Gemfile:
|
|
154
|
+
gem "prism", force_ruby_platform: true
|
|
155
|
+
|
|
156
|
+
EOM
|
|
157
|
+
raise e
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
# Precompiled library isn't available, fall back to the library compiled at installation time.
|
|
161
|
+
require "prism/prism"
|
|
162
|
+
end
|
|
163
|
+
else
|
|
164
|
+
# The FFI backend is used on other Ruby implementations.
|
|
165
|
+
Prism::BACKEND = :FFI
|
|
166
|
+
|
|
167
|
+
require_relative "prism/ffi"
|
|
168
|
+
end
|
data/prism.gemspec
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
Gem::Specification.new do |spec|
|
|
4
|
+
spec.name = "prism"
|
|
5
|
+
spec.version = "2.0.0.rc1"
|
|
6
|
+
spec.authors = ["Shopify"]
|
|
7
|
+
spec.email = ["ruby@shopify.com"]
|
|
8
|
+
|
|
9
|
+
spec.summary = "Prism Ruby parser"
|
|
10
|
+
spec.homepage = "https://github.com/ruby/prism"
|
|
11
|
+
spec.license = "MIT"
|
|
12
|
+
|
|
13
|
+
spec.required_ruby_version = ">= 2.7.0"
|
|
14
|
+
|
|
15
|
+
spec.require_paths = ["lib"]
|
|
16
|
+
spec.files = [
|
|
17
|
+
"BSDmakefile",
|
|
18
|
+
"CHANGELOG.md",
|
|
19
|
+
"CODE_OF_CONDUCT.md",
|
|
20
|
+
"CONTRIBUTING.md",
|
|
21
|
+
"LICENSE.md",
|
|
22
|
+
"Makefile",
|
|
23
|
+
"README.md",
|
|
24
|
+
"config.yml",
|
|
25
|
+
"docs/build_system.md",
|
|
26
|
+
"docs/configuration.md",
|
|
27
|
+
"docs/cruby_compilation.md",
|
|
28
|
+
"docs/design.md",
|
|
29
|
+
"docs/encoding.md",
|
|
30
|
+
"docs/fuzzing.md",
|
|
31
|
+
"docs/heredocs.md",
|
|
32
|
+
"docs/javascript.md",
|
|
33
|
+
"docs/local_variable_depth.md",
|
|
34
|
+
"docs/mapping.md",
|
|
35
|
+
"docs/parser_translation.md",
|
|
36
|
+
"docs/parsing_rules.md",
|
|
37
|
+
"docs/releasing.md",
|
|
38
|
+
"docs/relocation.md",
|
|
39
|
+
"docs/ripper_translation.md",
|
|
40
|
+
"docs/ruby_api.md",
|
|
41
|
+
"docs/ruby_parser_translation.md",
|
|
42
|
+
"docs/serialization.md",
|
|
43
|
+
"docs/testing.md",
|
|
44
|
+
"ext/prism/api_node.c",
|
|
45
|
+
"ext/prism/extconf.rb",
|
|
46
|
+
"ext/prism/extension.c",
|
|
47
|
+
"ext/prism/extension.h",
|
|
48
|
+
"include/prism.h",
|
|
49
|
+
"include/prism/compiler/accel.h",
|
|
50
|
+
"include/prism/compiler/align.h",
|
|
51
|
+
"include/prism/compiler/assume.h",
|
|
52
|
+
"include/prism/compiler/exported.h",
|
|
53
|
+
"include/prism/compiler/fallthrough.h",
|
|
54
|
+
"include/prism/compiler/filesystem.h",
|
|
55
|
+
"include/prism/compiler/flex_array.h",
|
|
56
|
+
"include/prism/compiler/force_inline.h",
|
|
57
|
+
"include/prism/compiler/format.h",
|
|
58
|
+
"include/prism/compiler/inline.h",
|
|
59
|
+
"include/prism/compiler/nodiscard.h",
|
|
60
|
+
"include/prism/compiler/nonnull.h",
|
|
61
|
+
"include/prism/compiler/unused.h",
|
|
62
|
+
"include/prism/internal/allocator.h",
|
|
63
|
+
"include/prism/internal/allocator_debug.h",
|
|
64
|
+
"include/prism/internal/arena.h",
|
|
65
|
+
"include/prism/internal/bit.h",
|
|
66
|
+
"include/prism/internal/buffer.h",
|
|
67
|
+
"include/prism/internal/char.h",
|
|
68
|
+
"include/prism/internal/comments.h",
|
|
69
|
+
"include/prism/internal/constant_pool.h",
|
|
70
|
+
"include/prism/internal/diagnostic.h",
|
|
71
|
+
"include/prism/internal/encoding.h",
|
|
72
|
+
"include/prism/internal/integer.h",
|
|
73
|
+
"include/prism/internal/isinf.h",
|
|
74
|
+
"include/prism/internal/line_offset_list.h",
|
|
75
|
+
"include/prism/internal/list.h",
|
|
76
|
+
"include/prism/internal/magic_comments.h",
|
|
77
|
+
"include/prism/internal/memchr.h",
|
|
78
|
+
"include/prism/internal/node.h",
|
|
79
|
+
"include/prism/internal/options.h",
|
|
80
|
+
"include/prism/internal/parser.h",
|
|
81
|
+
"include/prism/internal/regexp.h",
|
|
82
|
+
"include/prism/internal/serialize.h",
|
|
83
|
+
"include/prism/internal/source.h",
|
|
84
|
+
"include/prism/internal/static_literals.h",
|
|
85
|
+
"include/prism/internal/strncasecmp.h",
|
|
86
|
+
"include/prism/internal/stringy.h",
|
|
87
|
+
"include/prism/internal/strpbrk.h",
|
|
88
|
+
"include/prism/internal/tokens.h",
|
|
89
|
+
"include/prism/arena.h",
|
|
90
|
+
"include/prism/ast.h",
|
|
91
|
+
"include/prism/buffer.h",
|
|
92
|
+
"include/prism/comments.h",
|
|
93
|
+
"include/prism/constant_pool.h",
|
|
94
|
+
"include/prism/diagnostic.h",
|
|
95
|
+
"include/prism/errors_format.h",
|
|
96
|
+
"include/prism/excludes.h",
|
|
97
|
+
"include/prism/integer.h",
|
|
98
|
+
"include/prism/json.h",
|
|
99
|
+
"include/prism/line_offset_list.h",
|
|
100
|
+
"include/prism/magic_comments.h",
|
|
101
|
+
"include/prism/node.h",
|
|
102
|
+
"include/prism/options.h",
|
|
103
|
+
"include/prism/parser.h",
|
|
104
|
+
"include/prism/prettyprint.h",
|
|
105
|
+
"include/prism/serialize.h",
|
|
106
|
+
"include/prism/source.h",
|
|
107
|
+
"include/prism/stream.h",
|
|
108
|
+
"include/prism/string_query.h",
|
|
109
|
+
"include/prism/stringy.h",
|
|
110
|
+
"include/prism/version.h",
|
|
111
|
+
"lib/prism.rb",
|
|
112
|
+
"lib/prism/compiler.rb",
|
|
113
|
+
"lib/prism/desugar_compiler.rb",
|
|
114
|
+
"lib/prism/dispatcher.rb",
|
|
115
|
+
"lib/prism/dot_visitor.rb",
|
|
116
|
+
"lib/prism/dsl.rb",
|
|
117
|
+
"lib/prism/ffi.rb",
|
|
118
|
+
"lib/prism/inspect_visitor.rb",
|
|
119
|
+
"lib/prism/lex_compat.rb",
|
|
120
|
+
"lib/prism/mutation_compiler.rb",
|
|
121
|
+
"lib/prism/node_ext.rb",
|
|
122
|
+
"lib/prism/node_find.rb",
|
|
123
|
+
"lib/prism/node.rb",
|
|
124
|
+
"lib/prism/parse_result.rb",
|
|
125
|
+
"lib/prism/parse_result/errors.rb",
|
|
126
|
+
"lib/prism/parse_result/newlines.rb",
|
|
127
|
+
"lib/prism/pattern.rb",
|
|
128
|
+
"lib/prism/polyfill/append_as_bytes.rb",
|
|
129
|
+
"lib/prism/polyfill/byteindex.rb",
|
|
130
|
+
"lib/prism/polyfill/scan_byte.rb",
|
|
131
|
+
"lib/prism/polyfill/unpack1.rb",
|
|
132
|
+
"lib/prism/polyfill/warn.rb",
|
|
133
|
+
"lib/prism/reflection.rb",
|
|
134
|
+
"lib/prism/relocation.rb",
|
|
135
|
+
"lib/prism/serialize.rb",
|
|
136
|
+
"lib/prism/string_query.rb",
|
|
137
|
+
"lib/prism/translation.rb",
|
|
138
|
+
"lib/prism/translation/parser.rb",
|
|
139
|
+
"lib/prism/translation/parser_current.rb",
|
|
140
|
+
"lib/prism/translation/parser_versions.rb",
|
|
141
|
+
"lib/prism/translation/parser/builder.rb",
|
|
142
|
+
"lib/prism/translation/parser/compiler.rb",
|
|
143
|
+
"lib/prism/translation/parser/lexer.rb",
|
|
144
|
+
"lib/prism/translation/ripper.rb",
|
|
145
|
+
"lib/prism/translation/ripper/filter.rb",
|
|
146
|
+
"lib/prism/translation/ripper/lexer.rb",
|
|
147
|
+
"lib/prism/translation/ripper/sexp.rb",
|
|
148
|
+
"lib/prism/translation/ripper/shim.rb",
|
|
149
|
+
"lib/prism/translation/ruby_parser.rb",
|
|
150
|
+
"lib/prism/visitor.rb",
|
|
151
|
+
"prism.gemspec",
|
|
152
|
+
"rbi/generated/prism.rbi",
|
|
153
|
+
"rbi/generated/prism/compiler.rbi",
|
|
154
|
+
"rbi/generated/prism/desugar_compiler.rbi",
|
|
155
|
+
"rbi/generated/prism/dispatcher.rbi",
|
|
156
|
+
"rbi/generated/prism/dot_visitor.rbi",
|
|
157
|
+
"rbi/generated/prism/dsl.rbi",
|
|
158
|
+
"rbi/generated/prism/inspect_visitor.rbi",
|
|
159
|
+
"rbi/generated/prism/lex_compat.rbi",
|
|
160
|
+
"rbi/generated/prism/mutation_compiler.rbi",
|
|
161
|
+
"rbi/generated/prism/node.rbi",
|
|
162
|
+
"rbi/generated/prism/node_ext.rbi",
|
|
163
|
+
"rbi/generated/prism/node_find.rbi",
|
|
164
|
+
"rbi/generated/prism/parse_result.rbi",
|
|
165
|
+
"rbi/generated/prism/pattern.rbi",
|
|
166
|
+
"rbi/generated/prism/reflection.rbi",
|
|
167
|
+
"rbi/generated/prism/relocation.rbi",
|
|
168
|
+
"rbi/generated/prism/serialize.rbi",
|
|
169
|
+
"rbi/generated/prism/string_query.rbi",
|
|
170
|
+
"rbi/generated/prism/translation.rbi",
|
|
171
|
+
"rbi/generated/prism/visitor.rbi",
|
|
172
|
+
"rbi/generated/prism/parse_result/errors.rbi",
|
|
173
|
+
"rbi/generated/prism/parse_result/newlines.rbi",
|
|
174
|
+
"rbi/prism/translation/parser.rbi",
|
|
175
|
+
"rbi/prism/translation/parser_versions.rbi",
|
|
176
|
+
"rbi/prism/translation/ripper.rbi",
|
|
177
|
+
"rbi/rubyvm/node_find.rbi",
|
|
178
|
+
"sig/generated/prism.rbs",
|
|
179
|
+
"sig/generated/prism/compiler.rbs",
|
|
180
|
+
"sig/generated/prism/desugar_compiler.rbs",
|
|
181
|
+
"sig/generated/prism/dispatcher.rbs",
|
|
182
|
+
"sig/generated/prism/dot_visitor.rbs",
|
|
183
|
+
"sig/generated/prism/dsl.rbs",
|
|
184
|
+
"sig/generated/prism/inspect_visitor.rbs",
|
|
185
|
+
"sig/generated/prism/lex_compat.rbs",
|
|
186
|
+
"sig/generated/prism/mutation_compiler.rbs",
|
|
187
|
+
"sig/generated/prism/node.rbs",
|
|
188
|
+
"sig/generated/prism/node_ext.rbs",
|
|
189
|
+
"sig/generated/prism/node_find.rbs",
|
|
190
|
+
"sig/generated/prism/parse_result.rbs",
|
|
191
|
+
"sig/generated/prism/pattern.rbs",
|
|
192
|
+
"sig/generated/prism/reflection.rbs",
|
|
193
|
+
"sig/generated/prism/relocation.rbs",
|
|
194
|
+
"sig/generated/prism/serialize.rbs",
|
|
195
|
+
"sig/generated/prism/string_query.rbs",
|
|
196
|
+
"sig/generated/prism/translation.rbs",
|
|
197
|
+
"sig/generated/prism/visitor.rbs",
|
|
198
|
+
"sig/generated/prism/parse_result/errors.rbs",
|
|
199
|
+
"sig/generated/prism/parse_result/newlines.rbs",
|
|
200
|
+
"sig/manifest.yaml",
|
|
201
|
+
"src/arena.c",
|
|
202
|
+
"src/buffer.c",
|
|
203
|
+
"src/char.c",
|
|
204
|
+
"src/comments.c",
|
|
205
|
+
"src/constant_pool.c",
|
|
206
|
+
"src/diagnostic.c",
|
|
207
|
+
"src/encoding.c",
|
|
208
|
+
"src/errors_format.c",
|
|
209
|
+
"src/integer.c",
|
|
210
|
+
"src/json.c",
|
|
211
|
+
"src/line_offset_list.c",
|
|
212
|
+
"src/list.c",
|
|
213
|
+
"src/memchr.c",
|
|
214
|
+
"src/node.c",
|
|
215
|
+
"src/options.c",
|
|
216
|
+
"src/parser.c",
|
|
217
|
+
"src/prettyprint.c",
|
|
218
|
+
"src/prism.c",
|
|
219
|
+
"src/regexp.c",
|
|
220
|
+
"src/serialize.c",
|
|
221
|
+
"src/source.c",
|
|
222
|
+
"src/static_literals.c",
|
|
223
|
+
"src/string_query.c",
|
|
224
|
+
"src/stringy.c",
|
|
225
|
+
"src/strncasecmp.c",
|
|
226
|
+
"src/strpbrk.c",
|
|
227
|
+
"src/tokens.c"
|
|
228
|
+
]
|
|
229
|
+
|
|
230
|
+
spec.extensions = ["ext/prism/extconf.rb"]
|
|
231
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
|
232
|
+
spec.metadata["source_code_uri"] = "https://github.com/ruby/prism"
|
|
233
|
+
spec.metadata["changelog_uri"] = "https://github.com/ruby/prism/blob/main/CHANGELOG.md"
|
|
234
|
+
end
|