prism 1.9.0 → 2.0.0.rc2
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 +4 -4
- data/CHANGELOG.md +88 -0
- data/CODE_OF_CONDUCT.md +1 -1
- data/LICENSE.md +1 -1
- data/Makefile +41 -12
- data/README.md +35 -97
- data/config.yml +174 -161
- data/docs/build_system.md +2 -2
- data/docs/configuration.md +5 -4
- data/docs/encoding.md +2 -2
- data/docs/fuzzing.md +4 -11
- data/docs/javascript.md +19 -4
- data/docs/mapping.md +1 -1
- data/docs/releasing.md +77 -5
- data/docs/relocation.md +2 -4
- data/docs/serialization.md +22 -24
- data/docs/testing.md +46 -29
- data/ext/prism/api_node.c +1461 -1401
- data/ext/prism/extconf.rb +3 -4
- data/ext/prism/extension.c +796 -422
- data/ext/prism/extension.h +3 -3
- data/include/prism/arena.h +37 -0
- data/include/prism/ast.h +2727 -610
- data/include/prism/buffer.h +52 -0
- data/include/prism/comments.h +55 -0
- data/include/prism/compiler/accel.h +26 -0
- data/include/prism/compiler/align.h +36 -0
- data/include/prism/compiler/assume.h +25 -0
- data/include/prism/compiler/bswap.h +46 -0
- data/include/prism/compiler/endianness.h +34 -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 +38 -403
- 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 +94 -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/{encoding.h → internal/encoding.h} +27 -68
- 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/{util/pm_list.h → internal/list.h} +11 -52
- 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 +1004 -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/{static_literals.h → internal/static_literals.h} +26 -47
- data/include/prism/internal/stringy.h +35 -0
- data/include/prism/{util/pm_strncasecmp.h → internal/strncasecmp.h} +3 -17
- data/include/prism/{util/pm_strpbrk.h → internal/strpbrk.h} +7 -20
- data/include/prism/internal/tokens.h +11 -0
- data/include/prism/internal/xxh3.h +16 -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 +18 -53
- data/include/prism/options.h +146 -280
- data/include/prism/parser.h +356 -867
- data/include/prism/prettyprint.h +6 -9
- 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 +74 -0
- data/include/prism/stringy.h +72 -0
- data/include/prism/version.h +12 -3
- data/include/prism.h +43 -320
- data/lib/prism/compiler.rb +319 -305
- data/lib/prism/desugar_compiler.rb +105 -34
- data/lib/prism/dispatcher.rb +646 -473
- data/lib/prism/dot_visitor.rb +592 -511
- data/lib/prism/dsl.rb +391 -25
- data/lib/prism/ffi.rb +258 -90
- data/lib/prism/inspect_visitor.rb +357 -325
- data/lib/prism/lex_compat.rb +254 -212
- data/lib/prism/mutation_compiler.rb +313 -305
- data/lib/prism/node.rb +20966 -6992
- data/lib/prism/node_ext.rb +180 -187
- data/lib/prism/node_find.rb +215 -0
- data/lib/prism/parse_result/errors.rb +7 -1
- data/lib/prism/parse_result/newlines.rb +276 -8
- data/lib/prism/parse_result.rb +468 -139
- data/lib/prism/pattern.rb +65 -20
- data/lib/prism/reflection.rb +23 -12
- data/lib/prism/relocation.rb +149 -87
- data/lib/prism/serialize.rb +3460 -539
- data/lib/prism/string_query.rb +24 -1
- data/lib/prism/translation/parser/builder.rb +10 -2
- data/lib/prism/translation/parser/compiler.rb +44 -52
- data/lib/prism/translation/parser/lexer.rb +41 -92
- data/lib/prism/translation/parser.rb +1 -1
- data/lib/prism/translation/parser_current.rb +1 -1
- data/lib/prism/translation/ripper/lexer.rb +8 -10
- data/lib/prism/translation/ripper/sexp.rb +2 -10
- data/lib/prism/translation/ripper/shim.rb +2 -0
- data/lib/prism/translation/ripper.rb +967 -209
- data/lib/prism/translation/ruby_parser.rb +73 -316
- data/lib/prism/translation.rb +2 -0
- data/lib/prism/visitor.rb +632 -5
- data/lib/prism.rb +79 -9
- data/prism.gemspec +128 -62
- 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 +14407 -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 +776 -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 +184 -0
- data/rbi/generated/prism/string_query.rbi +43 -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_versions.rbi +5 -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/{prism → generated/prism}/mutation_compiler.rbs +309 -4
- data/sig/generated/prism/node.rbs +20896 -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 +871 -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 +198 -0
- data/sig/generated/prism/string_query.rbs +43 -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/{util/pm_buffer.c → buffer.c} +53 -21
- data/src/{util/pm_char.c → char.c} +28 -57
- data/src/comments.c +454 -0
- data/src/constant_pool.c +406 -0
- data/src/diagnostic.c +97 -65
- data/src/encoding.c +8 -3
- data/src/errors_format.c +519 -0
- data/src/{util/pm_integer.c → integer.c} +33 -22
- data/src/json.c +5733 -0
- data/src/line_offset_list.c +100 -0
- data/src/list.c +24 -0
- data/src/{util/pm_memchr.c → memchr.c} +8 -6
- data/src/node.c +3504 -7674
- data/src/options.c +162 -49
- data/src/parser.c +367 -0
- data/src/prettyprint.c +421 -354
- data/src/prism.c +8402 -7161
- data/src/regexp.c +961 -45
- data/src/serialize.c +460 -424
- data/src/source.c +518 -0
- data/src/static_literals.c +111 -43
- data/src/string_query.c +180 -0
- data/src/stringy.c +91 -0
- data/src/{util/pm_strncasecmp.c → strncasecmp.c} +5 -4
- data/src/strpbrk.c +447 -0
- data/src/{token_type.c → tokens.c} +39 -18
- data/src/xxh3.c +292 -0
- metadata +128 -63
- data/ext/prism/api_pack.c +0 -276
- data/include/prism/defines.h +0 -260
- data/include/prism/pack.h +0 -163
- data/include/prism/regexp.h +0 -43
- data/include/prism/util/pm_buffer.h +0 -236
- data/include/prism/util/pm_char.h +0 -204
- data/include/prism/util/pm_constant_pool.h +0 -218
- data/include/prism/util/pm_integer.h +0 -130
- data/include/prism/util/pm_memchr.h +0 -29
- data/include/prism/util/pm_newline_list.h +0 -113
- data/include/prism/util/pm_string.h +0 -200
- data/lib/prism/pack.rb +0 -230
- data/lib/prism/parse_result/comments.rb +0 -188
- data/rbi/prism/compiler.rbi +0 -12
- data/rbi/prism/dsl.rbi +0 -524
- data/rbi/prism/inspect_visitor.rbi +0 -12
- data/rbi/prism/node.rbi +0 -8750
- data/rbi/prism/node_ext.rbi +0 -107
- data/rbi/prism/parse_result.rbi +0 -404
- data/rbi/prism/reflection.rbi +0 -58
- data/rbi/prism/string_query.rbi +0 -12
- data/rbi/prism/visitor.rbi +0 -473
- data/rbi/prism.rbi +0 -63
- data/sig/prism/compiler.rbs +0 -9
- data/sig/prism/dispatcher.rbs +0 -19
- data/sig/prism/dot_visitor.rbs +0 -6
- data/sig/prism/dsl.rbs +0 -351
- data/sig/prism/inspect_visitor.rbs +0 -22
- data/sig/prism/lex_compat.rbs +0 -10
- data/sig/prism/node.rbs +0 -4042
- data/sig/prism/node_ext.rbs +0 -149
- data/sig/prism/pack.rbs +0 -43
- data/sig/prism/parse_result/comments.rbs +0 -38
- data/sig/prism/parse_result.rbs +0 -197
- data/sig/prism/pattern.rbs +0 -13
- data/sig/prism/reflection.rbs +0 -50
- data/sig/prism/relocation.rbs +0 -185
- data/sig/prism/serialize.rbs +0 -8
- data/sig/prism/string_query.rbs +0 -11
- data/sig/prism/visitor.rbs +0 -169
- data/sig/prism.rbs +0 -272
- data/src/pack.c +0 -509
- data/src/util/pm_constant_pool.c +0 -342
- data/src/util/pm_list.c +0 -49
- data/src/util/pm_newline_list.c +0 -125
- data/src/util/pm_string.c +0 -381
- data/src/util/pm_strpbrk.c +0 -206
data/lib/prism.rb
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
# :markup: markdown
|
|
3
|
+
#--
|
|
4
|
+
# rbs_inline: enabled
|
|
3
5
|
|
|
4
6
|
# The Prism Ruby parser.
|
|
5
7
|
#
|
|
@@ -21,7 +23,7 @@ module Prism
|
|
|
21
23
|
autoload :InspectVisitor, "prism/inspect_visitor"
|
|
22
24
|
autoload :LexCompat, "prism/lex_compat"
|
|
23
25
|
autoload :MutationCompiler, "prism/mutation_compiler"
|
|
24
|
-
autoload :
|
|
26
|
+
autoload :NodeFind, "prism/node_find"
|
|
25
27
|
autoload :Pattern, "prism/pattern"
|
|
26
28
|
autoload :Reflection, "prism/reflection"
|
|
27
29
|
autoload :Relocation, "prism/relocation"
|
|
@@ -33,19 +35,24 @@ module Prism
|
|
|
33
35
|
# Some of these constants are not meant to be exposed, so marking them as
|
|
34
36
|
# private here.
|
|
35
37
|
|
|
36
|
-
|
|
38
|
+
if RUBY_ENGINE != "jruby"
|
|
39
|
+
private_constant :LexCompat
|
|
40
|
+
private_constant :NodeFind
|
|
41
|
+
end
|
|
37
42
|
|
|
38
43
|
# Raised when requested to parse as the currently running Ruby version but Prism has no support for it.
|
|
39
44
|
class CurrentVersionError < ArgumentError
|
|
40
45
|
# Initialize a new exception for the given ruby version string.
|
|
46
|
+
#
|
|
47
|
+
#: (String version) -> void
|
|
41
48
|
def initialize(version)
|
|
42
49
|
message = +"invalid version: Requested to parse as `version: 'current'`; "
|
|
43
|
-
|
|
50
|
+
major, minor, =
|
|
44
51
|
if version.match?(/\A\d+\.\d+.\d+\z/)
|
|
45
52
|
version.split(".").map(&:to_i)
|
|
46
53
|
end
|
|
47
54
|
|
|
48
|
-
if
|
|
55
|
+
if major && minor && ((major < 3) || (major == 3 && minor < 3))
|
|
49
56
|
message << " #{version} is below the minimum supported syntax."
|
|
50
57
|
else
|
|
51
58
|
message << " #{version} is unknown. Please update the `prism` gem."
|
|
@@ -56,23 +63,63 @@ module Prism
|
|
|
56
63
|
end
|
|
57
64
|
|
|
58
65
|
# :call-seq:
|
|
59
|
-
#
|
|
66
|
+
# lex_compat(source, **options) -> LexCompat::Result
|
|
60
67
|
#
|
|
61
68
|
# Returns a parse result whose value is an array of tokens that closely
|
|
62
|
-
# resembles the return value of Ripper
|
|
69
|
+
# resembles the return value of Ripper.lex.
|
|
70
|
+
#
|
|
71
|
+
# For supported options, see Prism.parse.
|
|
63
72
|
#
|
|
64
|
-
|
|
73
|
+
#: (String source, **untyped options) -> LexCompat::Result
|
|
65
74
|
def self.lex_compat(source, **options)
|
|
66
75
|
LexCompat.new(source, **options).result # steep:ignore
|
|
67
76
|
end
|
|
68
77
|
|
|
69
78
|
# :call-seq:
|
|
70
|
-
#
|
|
79
|
+
# load(source, serialized, freeze) -> ParseResult
|
|
71
80
|
#
|
|
72
81
|
# Load the serialized AST using the source as a reference into a tree.
|
|
82
|
+
#
|
|
83
|
+
#: (String source, String serialized, ?bool freeze) -> ParseResult
|
|
73
84
|
def self.load(source, serialized, freeze = false)
|
|
74
85
|
Serialize.load_parse(source, serialized, freeze)
|
|
75
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
|
|
76
123
|
end
|
|
77
124
|
|
|
78
125
|
require_relative "prism/polyfill/byteindex"
|
|
@@ -89,7 +136,30 @@ if RUBY_ENGINE == "ruby" and !ENV["PRISM_FFI_BACKEND"]
|
|
|
89
136
|
# The C extension is the default backend on CRuby.
|
|
90
137
|
Prism::BACKEND = :CEXT
|
|
91
138
|
|
|
92
|
-
|
|
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
|
|
93
163
|
else
|
|
94
164
|
# The FFI backend is used on other Ruby implementations.
|
|
95
165
|
Prism::BACKEND = :FFI
|
data/prism.gemspec
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |spec|
|
|
4
4
|
spec.name = "prism"
|
|
5
|
-
spec.version = "
|
|
6
|
-
spec.authors = ["
|
|
7
|
-
spec.email = ["ruby@
|
|
5
|
+
spec.version = "2.0.0.rc2"
|
|
6
|
+
spec.authors = ["Ruby developers"]
|
|
7
|
+
spec.email = ["ruby-core@ruby-lang.org"]
|
|
8
8
|
|
|
9
9
|
spec.summary = "Prism Ruby parser"
|
|
10
10
|
spec.homepage = "https://github.com/ruby/prism"
|
|
@@ -42,31 +42,74 @@ Gem::Specification.new do |spec|
|
|
|
42
42
|
"docs/serialization.md",
|
|
43
43
|
"docs/testing.md",
|
|
44
44
|
"ext/prism/api_node.c",
|
|
45
|
-
"ext/prism/
|
|
45
|
+
"ext/prism/extconf.rb",
|
|
46
46
|
"ext/prism/extension.c",
|
|
47
47
|
"ext/prism/extension.h",
|
|
48
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/bswap.h",
|
|
53
|
+
"include/prism/compiler/endianness.h",
|
|
54
|
+
"include/prism/compiler/exported.h",
|
|
55
|
+
"include/prism/compiler/fallthrough.h",
|
|
56
|
+
"include/prism/compiler/filesystem.h",
|
|
57
|
+
"include/prism/compiler/flex_array.h",
|
|
58
|
+
"include/prism/compiler/force_inline.h",
|
|
59
|
+
"include/prism/compiler/format.h",
|
|
60
|
+
"include/prism/compiler/inline.h",
|
|
61
|
+
"include/prism/compiler/nodiscard.h",
|
|
62
|
+
"include/prism/compiler/nonnull.h",
|
|
63
|
+
"include/prism/compiler/unused.h",
|
|
64
|
+
"include/prism/internal/allocator.h",
|
|
65
|
+
"include/prism/internal/allocator_debug.h",
|
|
66
|
+
"include/prism/internal/arena.h",
|
|
67
|
+
"include/prism/internal/bit.h",
|
|
68
|
+
"include/prism/internal/buffer.h",
|
|
69
|
+
"include/prism/internal/char.h",
|
|
70
|
+
"include/prism/internal/comments.h",
|
|
71
|
+
"include/prism/internal/constant_pool.h",
|
|
72
|
+
"include/prism/internal/diagnostic.h",
|
|
73
|
+
"include/prism/internal/encoding.h",
|
|
74
|
+
"include/prism/internal/integer.h",
|
|
75
|
+
"include/prism/internal/isinf.h",
|
|
76
|
+
"include/prism/internal/line_offset_list.h",
|
|
77
|
+
"include/prism/internal/list.h",
|
|
78
|
+
"include/prism/internal/magic_comments.h",
|
|
79
|
+
"include/prism/internal/memchr.h",
|
|
80
|
+
"include/prism/internal/node.h",
|
|
81
|
+
"include/prism/internal/options.h",
|
|
82
|
+
"include/prism/internal/parser.h",
|
|
83
|
+
"include/prism/internal/regexp.h",
|
|
84
|
+
"include/prism/internal/serialize.h",
|
|
85
|
+
"include/prism/internal/source.h",
|
|
86
|
+
"include/prism/internal/static_literals.h",
|
|
87
|
+
"include/prism/internal/strncasecmp.h",
|
|
88
|
+
"include/prism/internal/stringy.h",
|
|
89
|
+
"include/prism/internal/strpbrk.h",
|
|
90
|
+
"include/prism/internal/tokens.h",
|
|
91
|
+
"include/prism/internal/xxh3.h",
|
|
92
|
+
"include/prism/arena.h",
|
|
49
93
|
"include/prism/ast.h",
|
|
50
|
-
"include/prism/
|
|
94
|
+
"include/prism/buffer.h",
|
|
95
|
+
"include/prism/comments.h",
|
|
96
|
+
"include/prism/constant_pool.h",
|
|
51
97
|
"include/prism/diagnostic.h",
|
|
52
|
-
"include/prism/
|
|
98
|
+
"include/prism/errors_format.h",
|
|
99
|
+
"include/prism/excludes.h",
|
|
100
|
+
"include/prism/integer.h",
|
|
101
|
+
"include/prism/json.h",
|
|
102
|
+
"include/prism/line_offset_list.h",
|
|
103
|
+
"include/prism/magic_comments.h",
|
|
53
104
|
"include/prism/node.h",
|
|
54
105
|
"include/prism/options.h",
|
|
55
|
-
"include/prism/pack.h",
|
|
56
106
|
"include/prism/parser.h",
|
|
57
107
|
"include/prism/prettyprint.h",
|
|
58
|
-
"include/prism/
|
|
59
|
-
"include/prism/
|
|
60
|
-
"include/prism/
|
|
61
|
-
"include/prism/
|
|
62
|
-
"include/prism/
|
|
63
|
-
"include/prism/util/pm_integer.h",
|
|
64
|
-
"include/prism/util/pm_list.h",
|
|
65
|
-
"include/prism/util/pm_memchr.h",
|
|
66
|
-
"include/prism/util/pm_newline_list.h",
|
|
67
|
-
"include/prism/util/pm_strncasecmp.h",
|
|
68
|
-
"include/prism/util/pm_string.h",
|
|
69
|
-
"include/prism/util/pm_strpbrk.h",
|
|
108
|
+
"include/prism/serialize.h",
|
|
109
|
+
"include/prism/source.h",
|
|
110
|
+
"include/prism/stream.h",
|
|
111
|
+
"include/prism/string_query.h",
|
|
112
|
+
"include/prism/stringy.h",
|
|
70
113
|
"include/prism/version.h",
|
|
71
114
|
"lib/prism.rb",
|
|
72
115
|
"lib/prism/compiler.rb",
|
|
@@ -79,10 +122,9 @@ Gem::Specification.new do |spec|
|
|
|
79
122
|
"lib/prism/lex_compat.rb",
|
|
80
123
|
"lib/prism/mutation_compiler.rb",
|
|
81
124
|
"lib/prism/node_ext.rb",
|
|
125
|
+
"lib/prism/node_find.rb",
|
|
82
126
|
"lib/prism/node.rb",
|
|
83
|
-
"lib/prism/pack.rb",
|
|
84
127
|
"lib/prism/parse_result.rb",
|
|
85
|
-
"lib/prism/parse_result/comments.rb",
|
|
86
128
|
"lib/prism/parse_result/errors.rb",
|
|
87
129
|
"lib/prism/parse_result/newlines.rb",
|
|
88
130
|
"lib/prism/pattern.rb",
|
|
@@ -110,59 +152,83 @@ Gem::Specification.new do |spec|
|
|
|
110
152
|
"lib/prism/translation/ruby_parser.rb",
|
|
111
153
|
"lib/prism/visitor.rb",
|
|
112
154
|
"prism.gemspec",
|
|
113
|
-
"rbi/prism.rbi",
|
|
114
|
-
"rbi/prism/compiler.rbi",
|
|
115
|
-
"rbi/prism/
|
|
116
|
-
"rbi/prism/
|
|
117
|
-
"rbi/prism/
|
|
118
|
-
"rbi/prism/
|
|
119
|
-
"rbi/prism/
|
|
120
|
-
"rbi/prism/
|
|
121
|
-
"rbi/prism/
|
|
155
|
+
"rbi/generated/prism.rbi",
|
|
156
|
+
"rbi/generated/prism/compiler.rbi",
|
|
157
|
+
"rbi/generated/prism/desugar_compiler.rbi",
|
|
158
|
+
"rbi/generated/prism/dispatcher.rbi",
|
|
159
|
+
"rbi/generated/prism/dot_visitor.rbi",
|
|
160
|
+
"rbi/generated/prism/dsl.rbi",
|
|
161
|
+
"rbi/generated/prism/inspect_visitor.rbi",
|
|
162
|
+
"rbi/generated/prism/lex_compat.rbi",
|
|
163
|
+
"rbi/generated/prism/mutation_compiler.rbi",
|
|
164
|
+
"rbi/generated/prism/node.rbi",
|
|
165
|
+
"rbi/generated/prism/node_ext.rbi",
|
|
166
|
+
"rbi/generated/prism/node_find.rbi",
|
|
167
|
+
"rbi/generated/prism/parse_result.rbi",
|
|
168
|
+
"rbi/generated/prism/pattern.rbi",
|
|
169
|
+
"rbi/generated/prism/reflection.rbi",
|
|
170
|
+
"rbi/generated/prism/relocation.rbi",
|
|
171
|
+
"rbi/generated/prism/serialize.rbi",
|
|
172
|
+
"rbi/generated/prism/string_query.rbi",
|
|
173
|
+
"rbi/generated/prism/translation.rbi",
|
|
174
|
+
"rbi/generated/prism/visitor.rbi",
|
|
175
|
+
"rbi/generated/prism/parse_result/errors.rbi",
|
|
176
|
+
"rbi/generated/prism/parse_result/newlines.rbi",
|
|
122
177
|
"rbi/prism/translation/parser.rbi",
|
|
123
178
|
"rbi/prism/translation/parser_versions.rbi",
|
|
124
179
|
"rbi/prism/translation/ripper.rbi",
|
|
125
|
-
"rbi/
|
|
126
|
-
"sig/prism.rbs",
|
|
127
|
-
"sig/prism/compiler.rbs",
|
|
128
|
-
"sig/prism/
|
|
129
|
-
"sig/prism/
|
|
130
|
-
"sig/prism/
|
|
131
|
-
"sig/prism/
|
|
132
|
-
"sig/prism/
|
|
133
|
-
"sig/prism/
|
|
134
|
-
"sig/prism/
|
|
135
|
-
"sig/prism/node.rbs",
|
|
136
|
-
"sig/prism/
|
|
137
|
-
"sig/prism/
|
|
138
|
-
"sig/prism/parse_result
|
|
139
|
-
"sig/prism/pattern.rbs",
|
|
140
|
-
"sig/prism/reflection.rbs",
|
|
141
|
-
"sig/prism/relocation.rbs",
|
|
142
|
-
"sig/prism/serialize.rbs",
|
|
143
|
-
"sig/prism/string_query.rbs",
|
|
144
|
-
"sig/prism/
|
|
180
|
+
"rbi/rubyvm/node_find.rbi",
|
|
181
|
+
"sig/generated/prism.rbs",
|
|
182
|
+
"sig/generated/prism/compiler.rbs",
|
|
183
|
+
"sig/generated/prism/desugar_compiler.rbs",
|
|
184
|
+
"sig/generated/prism/dispatcher.rbs",
|
|
185
|
+
"sig/generated/prism/dot_visitor.rbs",
|
|
186
|
+
"sig/generated/prism/dsl.rbs",
|
|
187
|
+
"sig/generated/prism/inspect_visitor.rbs",
|
|
188
|
+
"sig/generated/prism/lex_compat.rbs",
|
|
189
|
+
"sig/generated/prism/mutation_compiler.rbs",
|
|
190
|
+
"sig/generated/prism/node.rbs",
|
|
191
|
+
"sig/generated/prism/node_ext.rbs",
|
|
192
|
+
"sig/generated/prism/node_find.rbs",
|
|
193
|
+
"sig/generated/prism/parse_result.rbs",
|
|
194
|
+
"sig/generated/prism/pattern.rbs",
|
|
195
|
+
"sig/generated/prism/reflection.rbs",
|
|
196
|
+
"sig/generated/prism/relocation.rbs",
|
|
197
|
+
"sig/generated/prism/serialize.rbs",
|
|
198
|
+
"sig/generated/prism/string_query.rbs",
|
|
199
|
+
"sig/generated/prism/translation.rbs",
|
|
200
|
+
"sig/generated/prism/visitor.rbs",
|
|
201
|
+
"sig/generated/prism/parse_result/errors.rbs",
|
|
202
|
+
"sig/generated/prism/parse_result/newlines.rbs",
|
|
203
|
+
"sig/manifest.yaml",
|
|
204
|
+
"src/arena.c",
|
|
205
|
+
"src/buffer.c",
|
|
206
|
+
"src/char.c",
|
|
207
|
+
"src/comments.c",
|
|
208
|
+
"src/constant_pool.c",
|
|
145
209
|
"src/diagnostic.c",
|
|
146
210
|
"src/encoding.c",
|
|
211
|
+
"src/errors_format.c",
|
|
212
|
+
"src/integer.c",
|
|
213
|
+
"src/json.c",
|
|
214
|
+
"src/line_offset_list.c",
|
|
215
|
+
"src/list.c",
|
|
216
|
+
"src/memchr.c",
|
|
147
217
|
"src/node.c",
|
|
148
218
|
"src/options.c",
|
|
149
|
-
"src/
|
|
219
|
+
"src/parser.c",
|
|
150
220
|
"src/prettyprint.c",
|
|
151
221
|
"src/prism.c",
|
|
152
222
|
"src/regexp.c",
|
|
153
223
|
"src/serialize.c",
|
|
224
|
+
"src/source.c",
|
|
154
225
|
"src/static_literals.c",
|
|
155
|
-
"src/
|
|
156
|
-
"src/
|
|
157
|
-
"src/
|
|
158
|
-
"src/
|
|
159
|
-
"src/
|
|
160
|
-
"src/
|
|
161
|
-
"src/util/pm_memchr.c",
|
|
162
|
-
"src/util/pm_newline_list.c",
|
|
163
|
-
"src/util/pm_string.c",
|
|
164
|
-
"src/util/pm_strncasecmp.c",
|
|
165
|
-
"src/util/pm_strpbrk.c"
|
|
226
|
+
"src/string_query.c",
|
|
227
|
+
"src/stringy.c",
|
|
228
|
+
"src/strncasecmp.c",
|
|
229
|
+
"src/strpbrk.c",
|
|
230
|
+
"src/tokens.c",
|
|
231
|
+
"src/xxh3.c"
|
|
166
232
|
]
|
|
167
233
|
|
|
168
234
|
spec.extensions = ["ext/prism/extconf.rb"]
|