parser 2.5.0.0 → 2.6.0.0
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 +5 -5
- data/.gitignore +1 -0
- data/.travis.yml +41 -17
- data/CHANGELOG.md +88 -2
- data/README.md +4 -2
- data/Rakefile +2 -1
- data/ci/run_rubocop_specs +14 -0
- data/doc/AST_FORMAT.md +71 -14
- data/lib/parser/all.rb +1 -0
- data/lib/parser/ast/processor.rb +5 -0
- data/lib/parser/base.rb +6 -1
- data/lib/parser/builders/default.rb +90 -15
- data/lib/parser/color.rb +32 -0
- data/lib/parser/context.rb +9 -0
- data/lib/parser/current.rb +16 -7
- data/lib/parser/lexer/dedenter.rb +31 -3
- data/lib/parser/lexer/explanation.rb +6 -6
- data/lib/parser/lexer/literal.rb +13 -1
- data/lib/parser/lexer/stack_state.rb +4 -0
- data/lib/parser/lexer.rb +10180 -9297
- data/lib/parser/lexer.rl +81 -25
- data/lib/parser/macruby.rb +2 -2
- data/lib/parser/macruby.y +2 -2
- data/lib/parser/meta.rb +1 -1
- data/lib/parser/ruby18.rb +2 -2
- data/lib/parser/ruby18.y +2 -2
- data/lib/parser/ruby19.rb +2 -2
- data/lib/parser/ruby19.y +2 -2
- data/lib/parser/ruby20.rb +2 -2
- data/lib/parser/ruby20.y +2 -2
- data/lib/parser/ruby21.rb +2 -2
- data/lib/parser/ruby21.y +2 -2
- data/lib/parser/ruby22.rb +2 -2
- data/lib/parser/ruby22.y +2 -2
- data/lib/parser/ruby23.rb +2 -2
- data/lib/parser/ruby23.y +2 -2
- data/lib/parser/ruby24.rb +1740 -1719
- data/lib/parser/ruby24.y +56 -31
- data/lib/parser/ruby25.rb +3226 -3243
- data/lib/parser/ruby25.y +87 -68
- data/lib/parser/ruby26.rb +6674 -0
- data/lib/parser/ruby26.y +2413 -0
- data/lib/parser/rubymotion.rb +2 -2
- data/lib/parser/rubymotion.y +2 -2
- data/lib/parser/runner/ruby_parse.rb +4 -3
- data/lib/parser/runner.rb +5 -0
- data/lib/parser/source/buffer.rb +5 -3
- data/lib/parser/source/comment/associator.rb +3 -3
- data/lib/parser/source/comment.rb +4 -4
- data/lib/parser/source/map/index.rb +33 -0
- data/lib/parser/source/map.rb +1 -1
- data/lib/parser/source/range.rb +1 -1
- data/lib/parser/source/rewriter.rb +1 -1
- data/lib/parser/source/tree_rewriter.rb +3 -3
- data/lib/parser/version.rb +1 -1
- data/lib/parser.rb +1 -0
- data/parser.gemspec +2 -2
- data/test/helper.rb +13 -2
- data/test/parse_helper.rb +5 -1
- data/test/test_current.rb +2 -0
- data/test/test_encoding.rb +9 -0
- data/test/test_lexer.rb +44 -2
- data/test/test_parser.rb +539 -38
- data/test/test_source_buffer.rb +6 -0
- data/test/test_source_rewriter.rb +1 -1
- data/test/test_source_tree_rewriter.rb +5 -9
- metadata +10 -5
data/lib/parser/lexer.rl
CHANGED
|
@@ -379,27 +379,30 @@ class Parser::Lexer
|
|
|
379
379
|
def push_literal(*args)
|
|
380
380
|
new_literal = Literal.new(self, *args)
|
|
381
381
|
@literal_stack.push(new_literal)
|
|
382
|
+
next_state_for_literal(new_literal)
|
|
383
|
+
end
|
|
382
384
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
+
def next_state_for_literal(literal)
|
|
386
|
+
if literal.words? && literal.backslash_delimited?
|
|
387
|
+
if literal.interpolate?
|
|
385
388
|
self.class.lex_en_interp_backslash_delimited_words
|
|
386
389
|
else
|
|
387
390
|
self.class.lex_en_plain_backslash_delimited_words
|
|
388
391
|
end
|
|
389
|
-
elsif
|
|
390
|
-
if
|
|
392
|
+
elsif literal.words? && !literal.backslash_delimited?
|
|
393
|
+
if literal.interpolate?
|
|
391
394
|
self.class.lex_en_interp_words
|
|
392
395
|
else
|
|
393
396
|
self.class.lex_en_plain_words
|
|
394
397
|
end
|
|
395
|
-
elsif !
|
|
396
|
-
if
|
|
398
|
+
elsif !literal.words? && literal.backslash_delimited?
|
|
399
|
+
if literal.interpolate?
|
|
397
400
|
self.class.lex_en_interp_backslash_delimited
|
|
398
401
|
else
|
|
399
402
|
self.class.lex_en_plain_backslash_delimited
|
|
400
403
|
end
|
|
401
404
|
else
|
|
402
|
-
if
|
|
405
|
+
if literal.interpolate?
|
|
403
406
|
self.class.lex_en_interp_string
|
|
404
407
|
else
|
|
405
408
|
self.class.lex_en_plain_string
|
|
@@ -463,6 +466,7 @@ class Parser::Lexer
|
|
|
463
466
|
'if' => :kIF, 'unless' => :kUNLESS,
|
|
464
467
|
'while' => :kWHILE, 'until' => :kUNTIL,
|
|
465
468
|
'rescue' => :kRESCUE, 'defined?' => :kDEFINED,
|
|
469
|
+
'BEGIN' => :klBEGIN, 'END' => :klEND,
|
|
466
470
|
}
|
|
467
471
|
|
|
468
472
|
%w(class module def undef begin end then elsif else ensure case when
|
|
@@ -621,6 +625,7 @@ class Parser::Lexer
|
|
|
621
625
|
| 'r' % { @num_xfrm = lambda { |chars| emit(:tRATIONAL, Rational(chars)) } }
|
|
622
626
|
| 'i' % { @num_xfrm = lambda { |chars| emit(:tIMAGINARY, Complex(0, chars)) } }
|
|
623
627
|
| 'ri' % { @num_xfrm = lambda { |chars| emit(:tIMAGINARY, Complex(0, Rational(chars))) } }
|
|
628
|
+
| 're' % { @num_xfrm = lambda { |chars| emit(:tINTEGER, chars, @ts, @te - 2); p -= 2 } }
|
|
624
629
|
| 'if' % { @num_xfrm = lambda { |chars| emit(:tINTEGER, chars, @ts, @te - 2); p -= 2 } }
|
|
625
630
|
| 'rescue' % { @num_xfrm = lambda { |chars| emit(:tINTEGER, chars, @ts, @te - 6); p -= 6 } };
|
|
626
631
|
|
|
@@ -889,9 +894,26 @@ class Parser::Lexer
|
|
|
889
894
|
end
|
|
890
895
|
else
|
|
891
896
|
# It does not. So this is an actual escape sequence, yay!
|
|
892
|
-
if current_literal.
|
|
897
|
+
if current_literal.squiggly_heredoc? && escaped_char == "\n".freeze
|
|
898
|
+
# Squiggly heredocs like
|
|
899
|
+
# <<~-HERE
|
|
900
|
+
# 1\
|
|
901
|
+
# 2
|
|
902
|
+
# HERE
|
|
903
|
+
# treat '\' as a line continuation, but still dedent the body, so the heredoc above becomes "12\n".
|
|
904
|
+
# This information is emitted as is, without escaping,
|
|
905
|
+
# later this escape sequence (\\\n) gets handled manually in the Lexer::Dedenter
|
|
906
|
+
current_literal.extend_string(tok, @ts, @te)
|
|
907
|
+
elsif current_literal.supports_line_continuation_via_slash? && escaped_char == "\n".freeze
|
|
908
|
+
# Heredocs, regexp and a few other types of literals support line
|
|
909
|
+
# continuation via \\\n sequence. The code like
|
|
910
|
+
# "a\
|
|
911
|
+
# b"
|
|
912
|
+
# must be parsed as "ab"
|
|
913
|
+
current_literal.extend_string(tok.gsub("\\\n".freeze, ''.freeze), @ts, @te)
|
|
914
|
+
elsif current_literal.regexp?
|
|
893
915
|
# Regular expressions should include escape sequences in their
|
|
894
|
-
# escaped form. On the other hand, escaped newlines are removed
|
|
916
|
+
# escaped form. On the other hand, escaped newlines are removed (in cases like "\\C-\\\n\\M-x")
|
|
895
917
|
current_literal.extend_string(tok.gsub("\\\n".freeze, ''.freeze), @ts, @te)
|
|
896
918
|
else
|
|
897
919
|
current_literal.extend_string(@escape || tok, @ts, @te)
|
|
@@ -1017,6 +1039,13 @@ class Parser::Lexer
|
|
|
1017
1039
|
if current_literal.end_interp_brace_and_try_closing
|
|
1018
1040
|
if version?(18, 19)
|
|
1019
1041
|
emit(:tRCURLY, '}'.freeze, p - 1, p)
|
|
1042
|
+
if @version < 24
|
|
1043
|
+
@cond.lexpop
|
|
1044
|
+
@cmdarg.lexpop
|
|
1045
|
+
else
|
|
1046
|
+
@cond.pop
|
|
1047
|
+
@cmdarg.pop
|
|
1048
|
+
end
|
|
1020
1049
|
else
|
|
1021
1050
|
emit(:tSTRING_DEND, '}'.freeze, p - 1, p)
|
|
1022
1051
|
end
|
|
@@ -1025,8 +1054,9 @@ class Parser::Lexer
|
|
|
1025
1054
|
@herebody_s = current_literal.saved_herebody_s
|
|
1026
1055
|
end
|
|
1027
1056
|
|
|
1057
|
+
|
|
1028
1058
|
fhold;
|
|
1029
|
-
fnext *
|
|
1059
|
+
fnext *next_state_for_literal(current_literal);
|
|
1030
1060
|
fbreak;
|
|
1031
1061
|
end
|
|
1032
1062
|
end
|
|
@@ -1045,7 +1075,8 @@ class Parser::Lexer
|
|
|
1045
1075
|
end
|
|
1046
1076
|
|
|
1047
1077
|
current_literal.start_interp_brace
|
|
1048
|
-
|
|
1078
|
+
fnext expr_value;
|
|
1079
|
+
fbreak;
|
|
1049
1080
|
}
|
|
1050
1081
|
|
|
1051
1082
|
# Actual string parsers are simply combined from the primitives defined
|
|
@@ -1433,12 +1464,12 @@ class Parser::Lexer
|
|
|
1433
1464
|
w_space* e_lbrace
|
|
1434
1465
|
=> {
|
|
1435
1466
|
if @lambda_stack.last == @paren_nest
|
|
1436
|
-
|
|
1437
|
-
|
|
1467
|
+
@lambda_stack.pop
|
|
1468
|
+
emit(:tLAMBEG, '{'.freeze, @te - 1, @te)
|
|
1438
1469
|
else
|
|
1439
1470
|
emit(:tLCURLY, '{'.freeze, @te - 1, @te)
|
|
1440
|
-
fnext expr_value; fbreak;
|
|
1441
1471
|
end
|
|
1472
|
+
fnext expr_value; fbreak;
|
|
1442
1473
|
};
|
|
1443
1474
|
|
|
1444
1475
|
#
|
|
@@ -1598,7 +1629,7 @@ class Parser::Lexer
|
|
|
1598
1629
|
else
|
|
1599
1630
|
emit(:tLBRACE_ARG, '{'.freeze)
|
|
1600
1631
|
end
|
|
1601
|
-
fnext expr_value;
|
|
1632
|
+
fnext expr_value; fbreak;
|
|
1602
1633
|
};
|
|
1603
1634
|
|
|
1604
1635
|
'do'
|
|
@@ -1747,6 +1778,14 @@ class Parser::Lexer
|
|
|
1747
1778
|
fgoto *push_literal(type, delimiter, @ts);
|
|
1748
1779
|
};
|
|
1749
1780
|
|
|
1781
|
+
# :!@ is :!
|
|
1782
|
+
# :~@ is :~
|
|
1783
|
+
':' [!~] '@'
|
|
1784
|
+
=> {
|
|
1785
|
+
emit(:tSYMBOL, tok(@ts + 1, @ts + 2))
|
|
1786
|
+
fnext expr_end; fbreak;
|
|
1787
|
+
};
|
|
1788
|
+
|
|
1750
1789
|
':' bareword ambiguous_symbol_suffix
|
|
1751
1790
|
=> {
|
|
1752
1791
|
emit(:tSYMBOL, tok(@ts + 1, tm), @ts, tm)
|
|
@@ -1774,7 +1813,7 @@ class Parser::Lexer
|
|
|
1774
1813
|
value = @escape || tok(@ts + 1)
|
|
1775
1814
|
|
|
1776
1815
|
if version?(18)
|
|
1777
|
-
emit(:tINTEGER, value.
|
|
1816
|
+
emit(:tINTEGER, value.getbyte(0))
|
|
1778
1817
|
else
|
|
1779
1818
|
emit(:tCHARACTER, value)
|
|
1780
1819
|
end
|
|
@@ -2205,22 +2244,39 @@ class Parser::Lexer
|
|
|
2205
2244
|
# OPERATORS
|
|
2206
2245
|
#
|
|
2207
2246
|
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2247
|
+
'*' | '=>'
|
|
2248
|
+
=> {
|
|
2249
|
+
emit_table(PUNCTUATION)
|
|
2250
|
+
fgoto expr_value;
|
|
2251
|
+
};
|
|
2252
|
+
|
|
2253
|
+
# When '|', '~', '!', '=>' are used as operators
|
|
2254
|
+
# they do not accept any symbols (or quoted labels) after.
|
|
2255
|
+
# Other binary operators accept it.
|
|
2256
|
+
( operator_arithmetic | operator_rest ) - ( '|' | '~' | '!' | '*' )
|
|
2257
|
+
=> {
|
|
2258
|
+
emit_table(PUNCTUATION);
|
|
2259
|
+
fnext expr_value; fbreak;
|
|
2260
|
+
};
|
|
2261
|
+
|
|
2262
|
+
( e_lparen | '|' | '~' | '!' )
|
|
2212
2263
|
=> { emit_table(PUNCTUATION)
|
|
2213
2264
|
fnext expr_beg; fbreak; };
|
|
2214
2265
|
|
|
2215
2266
|
e_rbrace | e_rparen | ']'
|
|
2216
2267
|
=> {
|
|
2217
2268
|
emit_table(PUNCTUATION)
|
|
2218
|
-
@cond.lexpop; @cmdarg.pop
|
|
2219
2269
|
|
|
2220
|
-
if
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2270
|
+
if @version < 24
|
|
2271
|
+
@cond.lexpop
|
|
2272
|
+
@cmdarg.lexpop
|
|
2273
|
+
else
|
|
2274
|
+
@cond.pop
|
|
2275
|
+
@cmdarg.pop
|
|
2276
|
+
end
|
|
2277
|
+
|
|
2278
|
+
if tok == '}'.freeze || tok == ']'.freeze
|
|
2279
|
+
if @version >= 25
|
|
2224
2280
|
fnext expr_end;
|
|
2225
2281
|
else
|
|
2226
2282
|
fnext expr_endarg;
|
data/lib/parser/macruby.rb
CHANGED
|
@@ -4695,7 +4695,7 @@ def _reduce_314(val, _values, result)
|
|
|
4695
4695
|
end
|
|
4696
4696
|
|
|
4697
4697
|
def _reduce_315(val, _values, result)
|
|
4698
|
-
|
|
4698
|
+
unless @context.class_definition_allowed?
|
|
4699
4699
|
diagnostic :error, :class_in_def, nil, val[0]
|
|
4700
4700
|
end
|
|
4701
4701
|
|
|
@@ -4738,7 +4738,7 @@ def _reduce_318(val, _values, result)
|
|
|
4738
4738
|
end
|
|
4739
4739
|
|
|
4740
4740
|
def _reduce_319(val, _values, result)
|
|
4741
|
-
|
|
4741
|
+
unless @context.module_definition_allowed?
|
|
4742
4742
|
diagnostic :error, :module_in_def, nil, val[0]
|
|
4743
4743
|
end
|
|
4744
4744
|
|
data/lib/parser/macruby.y
CHANGED
|
@@ -1128,7 +1128,7 @@ rule
|
|
|
1128
1128
|
}
|
|
1129
1129
|
bodystmt kEND
|
|
1130
1130
|
{
|
|
1131
|
-
|
|
1131
|
+
unless @context.class_definition_allowed?
|
|
1132
1132
|
diagnostic :error, :class_in_def, nil, val[0]
|
|
1133
1133
|
end
|
|
1134
1134
|
|
|
@@ -1163,7 +1163,7 @@ rule
|
|
|
1163
1163
|
}
|
|
1164
1164
|
bodystmt kEND
|
|
1165
1165
|
{
|
|
1166
|
-
|
|
1166
|
+
unless @context.module_definition_allowed?
|
|
1167
1167
|
diagnostic :error, :module_in_def, nil, val[0]
|
|
1168
1168
|
end
|
|
1169
1169
|
|
data/lib/parser/meta.rb
CHANGED
|
@@ -22,7 +22,7 @@ module Parser
|
|
|
22
22
|
and not or if when case while until while_post
|
|
23
23
|
until_post for break next redo return resbody
|
|
24
24
|
kwbegin begin retry preexe postexe iflipflop eflipflop
|
|
25
|
-
shadowarg complex rational __FILE__ __LINE__
|
|
25
|
+
shadowarg complex rational __FILE__ __LINE__ __ENCODING__
|
|
26
26
|
).map(&:to_sym).to_set.freeze
|
|
27
27
|
|
|
28
28
|
end # Meta
|
data/lib/parser/ruby18.rb
CHANGED
|
@@ -4573,7 +4573,7 @@ def _reduce_304(val, _values, result)
|
|
|
4573
4573
|
end
|
|
4574
4574
|
|
|
4575
4575
|
def _reduce_305(val, _values, result)
|
|
4576
|
-
|
|
4576
|
+
unless @context.class_definition_allowed?
|
|
4577
4577
|
diagnostic :error, :class_in_def, nil, val[0]
|
|
4578
4578
|
end
|
|
4579
4579
|
|
|
@@ -4612,7 +4612,7 @@ def _reduce_308(val, _values, result)
|
|
|
4612
4612
|
end
|
|
4613
4613
|
|
|
4614
4614
|
def _reduce_309(val, _values, result)
|
|
4615
|
-
|
|
4615
|
+
unless @context.module_definition_allowed?
|
|
4616
4616
|
diagnostic :error, :module_in_def, nil, val[0]
|
|
4617
4617
|
end
|
|
4618
4618
|
|
data/lib/parser/ruby18.y
CHANGED
|
@@ -1128,7 +1128,7 @@ rule
|
|
|
1128
1128
|
}
|
|
1129
1129
|
bodystmt kEND
|
|
1130
1130
|
{
|
|
1131
|
-
|
|
1131
|
+
unless @context.class_definition_allowed?
|
|
1132
1132
|
diagnostic :error, :class_in_def, nil, val[0]
|
|
1133
1133
|
end
|
|
1134
1134
|
|
|
@@ -1159,7 +1159,7 @@ rule
|
|
|
1159
1159
|
}
|
|
1160
1160
|
bodystmt kEND
|
|
1161
1161
|
{
|
|
1162
|
-
|
|
1162
|
+
unless @context.module_definition_allowed?
|
|
1163
1163
|
diagnostic :error, :module_in_def, nil, val[0]
|
|
1164
1164
|
end
|
|
1165
1165
|
|
data/lib/parser/ruby19.rb
CHANGED
|
@@ -4640,7 +4640,7 @@ def _reduce_309(val, _values, result)
|
|
|
4640
4640
|
end
|
|
4641
4641
|
|
|
4642
4642
|
def _reduce_310(val, _values, result)
|
|
4643
|
-
|
|
4643
|
+
unless @context.class_definition_allowed?
|
|
4644
4644
|
diagnostic :error, :class_in_def, nil, val[0]
|
|
4645
4645
|
end
|
|
4646
4646
|
|
|
@@ -4683,7 +4683,7 @@ def _reduce_313(val, _values, result)
|
|
|
4683
4683
|
end
|
|
4684
4684
|
|
|
4685
4685
|
def _reduce_314(val, _values, result)
|
|
4686
|
-
|
|
4686
|
+
unless @context.module_definition_allowed?
|
|
4687
4687
|
diagnostic :error, :module_in_def, nil, val[0]
|
|
4688
4688
|
end
|
|
4689
4689
|
|
data/lib/parser/ruby19.y
CHANGED
|
@@ -1095,7 +1095,7 @@ rule
|
|
|
1095
1095
|
}
|
|
1096
1096
|
bodystmt kEND
|
|
1097
1097
|
{
|
|
1098
|
-
|
|
1098
|
+
unless @context.class_definition_allowed?
|
|
1099
1099
|
diagnostic :error, :class_in_def, nil, val[0]
|
|
1100
1100
|
end
|
|
1101
1101
|
|
|
@@ -1130,7 +1130,7 @@ rule
|
|
|
1130
1130
|
}
|
|
1131
1131
|
bodystmt kEND
|
|
1132
1132
|
{
|
|
1133
|
-
|
|
1133
|
+
unless @context.module_definition_allowed?
|
|
1134
1134
|
diagnostic :error, :module_in_def, nil, val[0]
|
|
1135
1135
|
end
|
|
1136
1136
|
|
data/lib/parser/ruby20.rb
CHANGED
|
@@ -4882,7 +4882,7 @@ def _reduce_317(val, _values, result)
|
|
|
4882
4882
|
end
|
|
4883
4883
|
|
|
4884
4884
|
def _reduce_318(val, _values, result)
|
|
4885
|
-
|
|
4885
|
+
unless @context.class_definition_allowed?
|
|
4886
4886
|
diagnostic :error, :class_in_def, nil, val[0]
|
|
4887
4887
|
end
|
|
4888
4888
|
|
|
@@ -4925,7 +4925,7 @@ def _reduce_321(val, _values, result)
|
|
|
4925
4925
|
end
|
|
4926
4926
|
|
|
4927
4927
|
def _reduce_322(val, _values, result)
|
|
4928
|
-
|
|
4928
|
+
unless @context.module_definition_allowed?
|
|
4929
4929
|
diagnostic :error, :module_in_def, nil, val[0]
|
|
4930
4930
|
end
|
|
4931
4931
|
|
data/lib/parser/ruby20.y
CHANGED
|
@@ -1125,7 +1125,7 @@ rule
|
|
|
1125
1125
|
}
|
|
1126
1126
|
bodystmt kEND
|
|
1127
1127
|
{
|
|
1128
|
-
|
|
1128
|
+
unless @context.class_definition_allowed?
|
|
1129
1129
|
diagnostic :error, :class_in_def, nil, val[0]
|
|
1130
1130
|
end
|
|
1131
1131
|
|
|
@@ -1160,7 +1160,7 @@ rule
|
|
|
1160
1160
|
}
|
|
1161
1161
|
bodystmt kEND
|
|
1162
1162
|
{
|
|
1163
|
-
|
|
1163
|
+
unless @context.module_definition_allowed?
|
|
1164
1164
|
diagnostic :error, :module_in_def, nil, val[0]
|
|
1165
1165
|
end
|
|
1166
1166
|
|
data/lib/parser/ruby21.rb
CHANGED
|
@@ -4915,7 +4915,7 @@ def _reduce_317(val, _values, result)
|
|
|
4915
4915
|
end
|
|
4916
4916
|
|
|
4917
4917
|
def _reduce_318(val, _values, result)
|
|
4918
|
-
|
|
4918
|
+
unless @context.class_definition_allowed?
|
|
4919
4919
|
diagnostic :error, :class_in_def, nil, val[0]
|
|
4920
4920
|
end
|
|
4921
4921
|
|
|
@@ -4958,7 +4958,7 @@ def _reduce_321(val, _values, result)
|
|
|
4958
4958
|
end
|
|
4959
4959
|
|
|
4960
4960
|
def _reduce_322(val, _values, result)
|
|
4961
|
-
|
|
4961
|
+
unless @context.module_definition_allowed?
|
|
4962
4962
|
diagnostic :error, :module_in_def, nil, val[0]
|
|
4963
4963
|
end
|
|
4964
4964
|
|
data/lib/parser/ruby21.y
CHANGED
|
@@ -1115,7 +1115,7 @@ rule
|
|
|
1115
1115
|
}
|
|
1116
1116
|
bodystmt kEND
|
|
1117
1117
|
{
|
|
1118
|
-
|
|
1118
|
+
unless @context.class_definition_allowed?
|
|
1119
1119
|
diagnostic :error, :class_in_def, nil, val[0]
|
|
1120
1120
|
end
|
|
1121
1121
|
|
|
@@ -1150,7 +1150,7 @@ rule
|
|
|
1150
1150
|
}
|
|
1151
1151
|
bodystmt kEND
|
|
1152
1152
|
{
|
|
1153
|
-
|
|
1153
|
+
unless @context.module_definition_allowed?
|
|
1154
1154
|
diagnostic :error, :module_in_def, nil, val[0]
|
|
1155
1155
|
end
|
|
1156
1156
|
|
data/lib/parser/ruby22.rb
CHANGED
|
@@ -4931,7 +4931,7 @@ def _reduce_317(val, _values, result)
|
|
|
4931
4931
|
end
|
|
4932
4932
|
|
|
4933
4933
|
def _reduce_318(val, _values, result)
|
|
4934
|
-
|
|
4934
|
+
unless @context.class_definition_allowed?
|
|
4935
4935
|
diagnostic :error, :class_in_def, nil, val[0]
|
|
4936
4936
|
end
|
|
4937
4937
|
|
|
@@ -4974,7 +4974,7 @@ def _reduce_321(val, _values, result)
|
|
|
4974
4974
|
end
|
|
4975
4975
|
|
|
4976
4976
|
def _reduce_322(val, _values, result)
|
|
4977
|
-
|
|
4977
|
+
unless @context.module_definition_allowed?
|
|
4978
4978
|
diagnostic :error, :module_in_def, nil, val[0]
|
|
4979
4979
|
end
|
|
4980
4980
|
|
data/lib/parser/ruby22.y
CHANGED
|
@@ -1114,7 +1114,7 @@ rule
|
|
|
1114
1114
|
}
|
|
1115
1115
|
bodystmt kEND
|
|
1116
1116
|
{
|
|
1117
|
-
|
|
1117
|
+
unless @context.class_definition_allowed?
|
|
1118
1118
|
diagnostic :error, :class_in_def, nil, val[0]
|
|
1119
1119
|
end
|
|
1120
1120
|
|
|
@@ -1149,7 +1149,7 @@ rule
|
|
|
1149
1149
|
}
|
|
1150
1150
|
bodystmt kEND
|
|
1151
1151
|
{
|
|
1152
|
-
|
|
1152
|
+
unless @context.module_definition_allowed?
|
|
1153
1153
|
diagnostic :error, :module_in_def, nil, val[0]
|
|
1154
1154
|
end
|
|
1155
1155
|
|
data/lib/parser/ruby23.rb
CHANGED
|
@@ -4951,7 +4951,7 @@ def _reduce_317(val, _values, result)
|
|
|
4951
4951
|
end
|
|
4952
4952
|
|
|
4953
4953
|
def _reduce_318(val, _values, result)
|
|
4954
|
-
|
|
4954
|
+
unless @context.class_definition_allowed?
|
|
4955
4955
|
diagnostic :error, :class_in_def, nil, val[0]
|
|
4956
4956
|
end
|
|
4957
4957
|
|
|
@@ -4994,7 +4994,7 @@ def _reduce_321(val, _values, result)
|
|
|
4994
4994
|
end
|
|
4995
4995
|
|
|
4996
4996
|
def _reduce_322(val, _values, result)
|
|
4997
|
-
|
|
4997
|
+
unless @context.module_definition_allowed?
|
|
4998
4998
|
diagnostic :error, :module_in_def, nil, val[0]
|
|
4999
4999
|
end
|
|
5000
5000
|
|
data/lib/parser/ruby23.y
CHANGED
|
@@ -1114,7 +1114,7 @@ rule
|
|
|
1114
1114
|
}
|
|
1115
1115
|
bodystmt kEND
|
|
1116
1116
|
{
|
|
1117
|
-
|
|
1117
|
+
unless @context.class_definition_allowed?
|
|
1118
1118
|
diagnostic :error, :class_in_def, nil, val[0]
|
|
1119
1119
|
end
|
|
1120
1120
|
|
|
@@ -1149,7 +1149,7 @@ rule
|
|
|
1149
1149
|
}
|
|
1150
1150
|
bodystmt kEND
|
|
1151
1151
|
{
|
|
1152
|
-
|
|
1152
|
+
unless @context.module_definition_allowed?
|
|
1153
1153
|
diagnostic :error, :module_in_def, nil, val[0]
|
|
1154
1154
|
end
|
|
1155
1155
|
|