jruby-prism-parser 0.24.0-java → 1.4.0-java
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/BSDmakefile +58 -0
- data/CHANGELOG.md +269 -1
- data/CONTRIBUTING.md +0 -4
- data/Makefile +25 -18
- data/README.md +57 -6
- data/config.yml +1724 -140
- data/docs/build_system.md +39 -11
- data/docs/configuration.md +4 -0
- data/docs/cruby_compilation.md +1 -1
- data/docs/fuzzing.md +1 -1
- data/docs/parser_translation.md +14 -9
- data/docs/parsing_rules.md +4 -1
- data/docs/releasing.md +8 -10
- data/docs/relocation.md +34 -0
- data/docs/ripper_translation.md +72 -0
- data/docs/ruby_api.md +2 -1
- data/docs/serialization.md +29 -5
- data/ext/prism/api_node.c +3395 -1999
- data/ext/prism/api_pack.c +9 -0
- data/ext/prism/extconf.rb +55 -34
- data/ext/prism/extension.c +597 -346
- data/ext/prism/extension.h +6 -5
- data/include/prism/ast.h +2612 -455
- data/include/prism/defines.h +160 -2
- data/include/prism/diagnostic.h +188 -76
- data/include/prism/encoding.h +22 -4
- data/include/prism/node.h +89 -17
- data/include/prism/options.h +224 -12
- data/include/prism/pack.h +11 -0
- data/include/prism/parser.h +267 -66
- data/include/prism/prettyprint.h +8 -0
- data/include/prism/regexp.h +18 -8
- data/include/prism/static_literals.h +121 -0
- data/include/prism/util/pm_buffer.h +75 -2
- data/include/prism/util/pm_char.h +1 -2
- data/include/prism/util/pm_constant_pool.h +18 -9
- data/include/prism/util/pm_integer.h +126 -0
- data/include/prism/util/pm_list.h +1 -1
- data/include/prism/util/pm_newline_list.h +19 -0
- data/include/prism/util/pm_string.h +48 -8
- data/include/prism/version.h +3 -3
- data/include/prism.h +99 -5
- data/jruby-prism.jar +0 -0
- data/lib/prism/compiler.rb +11 -1
- data/lib/prism/desugar_compiler.rb +113 -74
- data/lib/prism/dispatcher.rb +45 -1
- data/lib/prism/dot_visitor.rb +201 -77
- data/lib/prism/dsl.rb +673 -461
- data/lib/prism/ffi.rb +233 -45
- data/lib/prism/inspect_visitor.rb +2389 -0
- data/lib/prism/lex_compat.rb +35 -16
- data/lib/prism/mutation_compiler.rb +24 -8
- data/lib/prism/node.rb +7731 -8460
- data/lib/prism/node_ext.rb +328 -32
- data/lib/prism/pack.rb +4 -0
- data/lib/prism/parse_result/comments.rb +34 -24
- data/lib/prism/parse_result/errors.rb +65 -0
- data/lib/prism/parse_result/newlines.rb +102 -12
- data/lib/prism/parse_result.rb +448 -44
- data/lib/prism/pattern.rb +28 -10
- data/lib/prism/polyfill/append_as_bytes.rb +15 -0
- data/lib/prism/polyfill/byteindex.rb +13 -0
- data/lib/prism/polyfill/unpack1.rb +14 -0
- data/lib/prism/reflection.rb +413 -0
- data/lib/prism/relocation.rb +504 -0
- data/lib/prism/serialize.rb +1940 -1198
- data/lib/prism/string_query.rb +30 -0
- data/lib/prism/translation/parser/builder.rb +61 -0
- data/lib/prism/translation/parser/compiler.rb +569 -195
- data/lib/prism/translation/parser/lexer.rb +516 -39
- data/lib/prism/translation/parser.rb +177 -12
- data/lib/prism/translation/parser33.rb +1 -1
- data/lib/prism/translation/parser34.rb +1 -1
- data/lib/prism/translation/parser35.rb +12 -0
- data/lib/prism/translation/ripper/sexp.rb +125 -0
- data/lib/prism/translation/ripper/shim.rb +5 -0
- data/lib/prism/translation/ripper.rb +3224 -462
- data/lib/prism/translation/ruby_parser.rb +194 -69
- data/lib/prism/translation.rb +4 -1
- data/lib/prism/version.rb +1 -1
- data/lib/prism/visitor.rb +13 -0
- data/lib/prism.rb +17 -27
- data/prism.gemspec +57 -17
- data/rbi/prism/compiler.rbi +12 -0
- data/rbi/prism/dsl.rbi +524 -0
- data/rbi/prism/inspect_visitor.rbi +12 -0
- data/rbi/prism/node.rbi +8722 -0
- data/rbi/prism/node_ext.rbi +107 -0
- data/rbi/prism/parse_result.rbi +404 -0
- data/rbi/prism/reflection.rbi +58 -0
- data/rbi/prism/string_query.rbi +12 -0
- data/rbi/prism/translation/parser.rbi +11 -0
- data/rbi/prism/translation/parser33.rbi +6 -0
- data/rbi/prism/translation/parser34.rbi +6 -0
- data/rbi/prism/translation/parser35.rbi +6 -0
- data/rbi/prism/translation/ripper.rbi +15 -0
- data/rbi/prism/visitor.rbi +473 -0
- data/rbi/prism.rbi +44 -7745
- data/sig/prism/compiler.rbs +9 -0
- data/sig/prism/dispatcher.rbs +16 -0
- data/sig/prism/dot_visitor.rbs +6 -0
- data/sig/prism/dsl.rbs +351 -0
- data/sig/prism/inspect_visitor.rbs +22 -0
- data/sig/prism/lex_compat.rbs +10 -0
- data/sig/prism/mutation_compiler.rbs +159 -0
- data/sig/prism/node.rbs +3614 -0
- data/sig/prism/node_ext.rbs +82 -0
- data/sig/prism/pack.rbs +43 -0
- data/sig/prism/parse_result.rbs +192 -0
- data/sig/prism/pattern.rbs +13 -0
- data/sig/prism/reflection.rbs +50 -0
- data/sig/prism/relocation.rbs +185 -0
- data/sig/prism/serialize.rbs +8 -0
- data/sig/prism/string_query.rbs +11 -0
- data/sig/prism/visitor.rbs +169 -0
- data/sig/prism.rbs +248 -4767
- data/src/diagnostic.c +672 -230
- data/src/encoding.c +211 -108
- data/src/node.c +7541 -1653
- data/src/options.c +135 -20
- data/src/pack.c +33 -17
- data/src/prettyprint.c +1543 -1485
- data/src/prism.c +7813 -3050
- data/src/regexp.c +225 -73
- data/src/serialize.c +101 -77
- data/src/static_literals.c +617 -0
- data/src/token_type.c +14 -13
- data/src/util/pm_buffer.c +187 -20
- data/src/util/pm_char.c +5 -5
- data/src/util/pm_constant_pool.c +39 -19
- data/src/util/pm_integer.c +670 -0
- data/src/util/pm_list.c +1 -1
- data/src/util/pm_newline_list.c +43 -5
- data/src/util/pm_string.c +213 -33
- data/src/util/pm_strncasecmp.c +13 -1
- data/src/util/pm_strpbrk.c +32 -6
- metadata +55 -19
- data/docs/ripper.md +0 -36
- data/include/prism/util/pm_state_stack.h +0 -42
- data/include/prism/util/pm_string_list.h +0 -44
- data/lib/prism/debug.rb +0 -206
- data/lib/prism/node_inspector.rb +0 -68
- data/lib/prism/translation/parser/rubocop.rb +0 -45
- data/rbi/prism_static.rbi +0 -207
- data/sig/prism_static.rbs +0 -201
- data/src/util/pm_state_stack.c +0 -25
- data/src/util/pm_string_list.c +0 -28
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Prism
|
4
|
-
class ParseResult
|
4
|
+
class ParseResult < Result
|
5
5
|
# The :line tracepoint event gets fired whenever the Ruby VM encounters an
|
6
6
|
# expression on a new line. The types of expressions that can trigger this
|
7
7
|
# event are:
|
@@ -17,21 +17,27 @@ module Prism
|
|
17
17
|
# Note that the logic in this file should be kept in sync with the Java
|
18
18
|
# MarkNewlinesVisitor, since that visitor is responsible for marking the
|
19
19
|
# newlines for JRuby/TruffleRuby.
|
20
|
+
#
|
21
|
+
# This file is autoloaded only when `mark_newlines!` is called, so the
|
22
|
+
# re-opening of the various nodes in this file will only be performed in
|
23
|
+
# that case. We do that to avoid storing the extra `@newline` instance
|
24
|
+
# variable on every node if we don't need it.
|
20
25
|
class Newlines < Visitor
|
21
26
|
# Create a new Newlines visitor with the given newline offsets.
|
22
|
-
def initialize(
|
23
|
-
@
|
27
|
+
def initialize(lines)
|
28
|
+
# @type var lines: Integer
|
29
|
+
@lines = Array.new(1 + lines, false)
|
24
30
|
end
|
25
31
|
|
26
32
|
# Permit block/lambda nodes to mark newlines within themselves.
|
27
33
|
def visit_block_node(node)
|
28
|
-
|
29
|
-
@
|
34
|
+
old_lines = @lines
|
35
|
+
@lines = Array.new(old_lines.size, false)
|
30
36
|
|
31
37
|
begin
|
32
38
|
super(node)
|
33
39
|
ensure
|
34
|
-
@
|
40
|
+
@lines = old_lines
|
35
41
|
end
|
36
42
|
end
|
37
43
|
|
@@ -39,7 +45,7 @@ module Prism
|
|
39
45
|
|
40
46
|
# Mark if/unless nodes as newlines.
|
41
47
|
def visit_if_node(node)
|
42
|
-
node.
|
48
|
+
node.newline_flag!(@lines)
|
43
49
|
super(node)
|
44
50
|
end
|
45
51
|
|
@@ -48,17 +54,101 @@ module Prism
|
|
48
54
|
# Permit statements lists to mark newlines within themselves.
|
49
55
|
def visit_statements_node(node)
|
50
56
|
node.body.each do |child|
|
51
|
-
child.
|
57
|
+
child.newline_flag!(@lines)
|
52
58
|
end
|
53
59
|
super(node)
|
54
60
|
end
|
55
61
|
end
|
62
|
+
end
|
63
|
+
|
64
|
+
class Node
|
65
|
+
def newline_flag? # :nodoc:
|
66
|
+
!!defined?(@newline_flag)
|
67
|
+
end
|
68
|
+
|
69
|
+
def newline_flag!(lines) # :nodoc:
|
70
|
+
line = location.start_line
|
71
|
+
unless lines[line]
|
72
|
+
lines[line] = true
|
73
|
+
@newline_flag = true
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
class BeginNode < Node
|
79
|
+
def newline_flag!(lines) # :nodoc:
|
80
|
+
# Never mark BeginNode with a newline flag, mark children instead.
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
class ParenthesesNode < Node
|
85
|
+
def newline_flag!(lines) # :nodoc:
|
86
|
+
# Never mark ParenthesesNode with a newline flag, mark children instead.
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
class IfNode < Node
|
91
|
+
def newline_flag!(lines) # :nodoc:
|
92
|
+
predicate.newline_flag!(lines)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
class UnlessNode < Node
|
97
|
+
def newline_flag!(lines) # :nodoc:
|
98
|
+
predicate.newline_flag!(lines)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
class UntilNode < Node
|
103
|
+
def newline_flag!(lines) # :nodoc:
|
104
|
+
predicate.newline_flag!(lines)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
class WhileNode < Node
|
109
|
+
def newline_flag!(lines) # :nodoc:
|
110
|
+
predicate.newline_flag!(lines)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
class RescueModifierNode < Node
|
115
|
+
def newline_flag!(lines) # :nodoc:
|
116
|
+
expression.newline_flag!(lines)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
class InterpolatedMatchLastLineNode < Node
|
121
|
+
def newline_flag!(lines) # :nodoc:
|
122
|
+
first = parts.first
|
123
|
+
first.newline_flag!(lines) if first
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
class InterpolatedRegularExpressionNode < Node
|
128
|
+
def newline_flag!(lines) # :nodoc:
|
129
|
+
first = parts.first
|
130
|
+
first.newline_flag!(lines) if first
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
class InterpolatedStringNode < Node
|
135
|
+
def newline_flag!(lines) # :nodoc:
|
136
|
+
first = parts.first
|
137
|
+
first.newline_flag!(lines) if first
|
138
|
+
end
|
139
|
+
end
|
56
140
|
|
57
|
-
|
141
|
+
class InterpolatedSymbolNode < Node
|
142
|
+
def newline_flag!(lines) # :nodoc:
|
143
|
+
first = parts.first
|
144
|
+
first.newline_flag!(lines) if first
|
145
|
+
end
|
146
|
+
end
|
58
147
|
|
59
|
-
|
60
|
-
def
|
61
|
-
|
148
|
+
class InterpolatedXStringNode < Node
|
149
|
+
def newline_flag!(lines) # :nodoc:
|
150
|
+
first = parts.first
|
151
|
+
first.newline_flag!(lines) if first
|
62
152
|
end
|
63
153
|
end
|
64
154
|
end
|