brakeman 5.1.1 → 5.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +22 -1
- data/README.md +1 -1
- data/bundle/load.rb +5 -5
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/CHANGELOG.md +8 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/FAQ.md +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/Gemfile +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/MIT-LICENSE +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/README.md +19 -13
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/REFERENCE.md +10 -3
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/TODO +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/haml.gemspec +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/attribute_builder.rb +55 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/attribute_compiler.rb +4 -2
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/attribute_parser.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/buffer.rb +0 -56
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/compiler.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/engine.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/error.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/escapable.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/exec.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/filters.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/generator.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers/action_view_extensions.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers/action_view_mods.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers/action_view_xss_mods.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers/safe_erubi_template.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers/safe_erubis_template.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers/xss_mods.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/options.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/parser.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/plugin.rb +18 -1
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/railtie.rb +5 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/sass_rails_filter.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/template/options.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/template.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/temple_engine.rb +2 -1
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/temple_line_counter.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/util.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/version.rb +1 -1
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/yard/default/fulldoc/html/css/common.sass +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/yard/default/layout/html/footer.erb +0 -0
- data/bundle/ruby/2.7.0/gems/{parallel-1.20.1 → parallel-1.21.0}/MIT-LICENSE.txt +0 -0
- data/bundle/ruby/2.7.0/gems/parallel-1.21.0/lib/parallel/processor_count.rb +45 -0
- data/bundle/ruby/2.7.0/gems/parallel-1.21.0/lib/parallel/version.rb +4 -0
- data/bundle/ruby/2.7.0/gems/{parallel-1.20.1 → parallel-1.21.0}/lib/parallel.rb +52 -43
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/History.rdoc +88 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/Manifest.txt +3 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/README.rdoc +1 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/compare/normalize.rb +6 -1
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/debugging.md +0 -0
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/gauntlet.md +106 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/rp_extensions.rb +15 -36
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/rp_stringscanner.rb +33 -0
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby20_parser.rb +7128 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby20_parser.y +335 -252
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby21_parser.rb +7182 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby21_parser.y +330 -249
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby22_parser.rb +7228 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby22_parser.y +334 -251
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby23_parser.rb +7237 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0/lib/ruby26_parser.y → ruby_parser-3.18.1/lib/ruby23_parser.y} +336 -276
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby24_parser.rb +7268 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby24_parser.y +334 -251
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby25_parser.rb +7268 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0/lib/ruby30_parser.y → ruby_parser-3.18.1/lib/ruby25_parser.y} +335 -304
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby26_parser.rb +7287 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0/lib/ruby27_parser.y → ruby_parser-3.18.1/lib/ruby26_parser.y} +334 -288
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby27_parser.rb +8517 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0/lib/ruby_parser.yy → ruby_parser-3.18.1/lib/ruby27_parser.y} +906 -380
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby30_parser.rb +8751 -0
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby30_parser.y +3472 -0
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby3_parser.yy +3476 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby_lexer.rb +261 -609
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby_lexer.rex +27 -20
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby_lexer.rex.rb +59 -23
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby_lexer_strings.rb +638 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby_parser.rb +0 -0
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby_parser.yy +3487 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby_parser_extras.rb +296 -115
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/tools/munge.rb +34 -6
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/tools/ripper.rb +44 -0
- data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/History.rdoc +15 -0
- data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/Manifest.txt +0 -0
- data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/README.rdoc +0 -0
- data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/composite_sexp_processor.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/pt_testcase.rb +7 -2
- data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/sexp.rb +19 -9
- data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/sexp_matcher.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/sexp_processor.rb +1 -1
- data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/strict_sexp.rb +25 -3
- data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/unique.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/CHANGELOG.md +4 -0
- data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/MIT-LICENSE.txt +0 -0
- data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/README.md +1 -1
- data/bundle/ruby/2.7.0/gems/unicode-display_width-1.8.0/data/display_width.marshal.gz +0 -0
- data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/lib/unicode/display_width/constants.rb +2 -2
- data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/lib/unicode/display_width/index.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/lib/unicode/display_width/no_string_ext.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/lib/unicode/display_width/string_ext.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/lib/unicode/display_width.rb +0 -0
- data/lib/brakeman/app_tree.rb +1 -1
- data/lib/brakeman/checks/base_check.rb +10 -0
- data/lib/brakeman/checks/check_eol_rails.rb +23 -0
- data/lib/brakeman/checks/check_eol_ruby.rb +26 -0
- data/lib/brakeman/checks/check_json_parsing.rb +1 -1
- data/lib/brakeman/checks/check_sql.rb +3 -2
- data/lib/brakeman/checks/check_symbol_dos.rb +1 -1
- data/lib/brakeman/checks/eol_check.rb +47 -0
- data/lib/brakeman/options.rb +8 -0
- data/lib/brakeman/processors/alias_processor.rb +7 -1
- data/lib/brakeman/processors/gem_processor.rb +3 -0
- data/lib/brakeman/processors/haml_template_processor.rb +9 -0
- data/lib/brakeman/processors/lib/call_conversion_helper.rb +2 -0
- data/lib/brakeman/processors/lib/rails3_route_processor.rb +2 -0
- data/lib/brakeman/processors/model_processor.rb +1 -0
- data/lib/brakeman/report/ignore/config.rb +1 -1
- data/lib/brakeman/report/report_csv.rb +1 -1
- data/lib/brakeman/report/report_sarif.rb +1 -1
- data/lib/brakeman/report/report_text.rb +1 -1
- data/lib/brakeman/scanner.rb +15 -13
- data/lib/brakeman/tracker/config.rb +8 -1
- data/lib/brakeman/version.rb +1 -1
- data/lib/brakeman/warning_codes.rb +4 -0
- data/lib/brakeman.rb +2 -2
- data/lib/ruby_parser/bm_sexp.rb +11 -1
- metadata +105 -99
- data/bundle/ruby/2.7.0/gems/parallel-1.20.1/lib/parallel/processor_count.rb +0 -42
- data/bundle/ruby/2.7.0/gems/parallel-1.20.1/lib/parallel/version.rb +0 -3
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/rp_stringscanner.rb +0 -64
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby20_parser.rb +0 -7075
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby21_parser.rb +0 -7148
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby22_parser.rb +0 -7185
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby23_parser.rb +0 -7199
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby23_parser.y +0 -2643
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby24_parser.rb +0 -7219
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby25_parser.rb +0 -7218
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby25_parser.y +0 -2651
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby26_parser.rb +0 -7240
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby27_parser.rb +0 -7358
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby30_parser.rb +0 -7358
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/tools/ripper.rb +0 -39
- data/bundle/ruby/2.7.0/gems/unicode-display_width-1.7.0/data/display_width.marshal.gz +0 -0
@@ -18,7 +18,7 @@ token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
|
|
18
18
|
tBACK_REF2 tSYMBEG tSTRING_BEG tXSTRING_BEG tREGEXP_BEG
|
19
19
|
tWORDS_BEG tQWORDS_BEG tSTRING_DBEG tSTRING_DVAR tSTRING_END
|
20
20
|
tSTRING tSYMBOL tNL tEH tCOLON tCOMMA tSPACE tSEMI tLAMBDA
|
21
|
-
tLAMBEG tDSTAR tCHAR tSYMBOLS_BEG tQSYMBOLS_BEG tSTRING_DEND
|
21
|
+
tLAMBEG tDSTAR tCHAR tSYMBOLS_BEG tQSYMBOLS_BEG tSTRING_DEND
|
22
22
|
|
23
23
|
preclow
|
24
24
|
nonassoc tLOWEST
|
@@ -76,7 +76,7 @@ rule
|
|
76
76
|
| klBEGIN
|
77
77
|
{
|
78
78
|
if (self.in_def || self.in_single > 0) then
|
79
|
-
|
79
|
+
debug 11
|
80
80
|
yyerror "BEGIN in method"
|
81
81
|
end
|
82
82
|
self.env.extend
|
@@ -101,7 +101,9 @@ rule
|
|
101
101
|
bodystmt: compstmt opt_rescue k_else
|
102
102
|
{
|
103
103
|
res = _values[-2]
|
104
|
-
|
104
|
+
# TODO: move down to main match so I can just use val
|
105
|
+
|
106
|
+
warn "else without rescue is useless" unless res
|
105
107
|
}
|
106
108
|
compstmt
|
107
109
|
opt_ensure
|
@@ -131,7 +133,7 @@ rule
|
|
131
133
|
| error stmt
|
132
134
|
{
|
133
135
|
result = val[1]
|
134
|
-
|
136
|
+
debug 12
|
135
137
|
}
|
136
138
|
|
137
139
|
stmt_or_begin: stmt
|
@@ -139,6 +141,10 @@ rule
|
|
139
141
|
{
|
140
142
|
yyerror "BEGIN is permitted only at toplevel"
|
141
143
|
}
|
144
|
+
begin_block
|
145
|
+
{
|
146
|
+
result = val[2] # wtf?
|
147
|
+
}
|
142
148
|
|
143
149
|
stmt: kALIAS fitem
|
144
150
|
{
|
@@ -151,12 +157,12 @@ rule
|
|
151
157
|
}
|
152
158
|
| kALIAS tGVAR tGVAR
|
153
159
|
{
|
154
|
-
(_, line), lhs, rhs = val
|
160
|
+
(_, line), (lhs, _), (rhs, _) = val
|
155
161
|
result = s(:valias, lhs.to_sym, rhs.to_sym).line line
|
156
162
|
}
|
157
163
|
| kALIAS tGVAR tBACK_REF
|
158
164
|
{
|
159
|
-
(_, line), lhs, rhs = val
|
165
|
+
(_, line), (lhs, _), (rhs, _) = val
|
160
166
|
result = s(:valias, lhs.to_sym, :"$#{rhs}").line line
|
161
167
|
}
|
162
168
|
| kALIAS tGVAR tNTH_REF
|
@@ -199,7 +205,7 @@ rule
|
|
199
205
|
(_, line), _, stmt, _ = val
|
200
206
|
|
201
207
|
if (self.in_def || self.in_single > 0) then
|
202
|
-
|
208
|
+
debug 13
|
203
209
|
yyerror "END in method; use at_exit"
|
204
210
|
end
|
205
211
|
|
@@ -243,32 +249,31 @@ rule
|
|
243
249
|
}
|
244
250
|
| primary_value call_op tIDENTIFIER tOP_ASGN command_rhs
|
245
251
|
{
|
246
|
-
prim, _, id,
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
result.line = val[0].line
|
252
|
+
prim, (call_op, _), (id, _), (op_asgn, _), rhs = val
|
253
|
+
|
254
|
+
result = s(:op_asgn, prim, rhs, id.to_sym, op_asgn.to_sym)
|
255
|
+
result.sexp_type = :safe_op_asgn if call_op == '&.'
|
256
|
+
result.line prim.line
|
252
257
|
}
|
253
258
|
| primary_value call_op tCONSTANT tOP_ASGN command_rhs
|
254
259
|
{
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
result.line
|
260
|
+
prim, (call_op, _), (id, _), (op_asgn, _), rhs = val
|
261
|
+
|
262
|
+
result = s(:op_asgn, prim, rhs, id.to_sym, op_asgn.to_sym)
|
263
|
+
result.sexp_type = :safe_op_asgn if call_op == '&.'
|
264
|
+
result.line prim.line
|
260
265
|
}
|
261
266
|
| primary_value tCOLON2 tCONSTANT tOP_ASGN command_rhs
|
262
267
|
{
|
263
|
-
lhs1, _, lhs2,
|
268
|
+
lhs1, _, (lhs2, line), (id, _), rhs = val
|
264
269
|
|
265
|
-
result = s(:op_asgn, lhs1, rhs, lhs2.to_sym,
|
270
|
+
result = s(:op_asgn, lhs1, rhs, lhs2.to_sym, id.to_sym).line line
|
266
271
|
}
|
267
272
|
| primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_rhs
|
268
273
|
{
|
269
|
-
lhs1, _, lhs2,
|
274
|
+
lhs1, _, (lhs2, line), (id, _), rhs = val
|
270
275
|
|
271
|
-
result = s(:op_asgn, lhs1, rhs, lhs2.to_sym,
|
276
|
+
result = s(:op_asgn, lhs1, rhs, lhs2.to_sym, id.to_sym).line line
|
272
277
|
}
|
273
278
|
| backref tOP_ASGN command_rhs
|
274
279
|
{
|
@@ -306,7 +311,7 @@ rule
|
|
306
311
|
# TODO: fix line number to tBANG... but causes BAD shift/reduce conflict
|
307
312
|
# REFACTOR: call_uni_op -- see parse26.y
|
308
313
|
}
|
309
|
-
| arg
|
314
|
+
| arg =tLBRACE_ARG
|
310
315
|
|
311
316
|
expr_value: expr
|
312
317
|
{
|
@@ -331,7 +336,7 @@ rule
|
|
331
336
|
block_command: block_call
|
332
337
|
| block_call call_op2 operation2 command_args
|
333
338
|
{
|
334
|
-
blk, _, msg, args = val
|
339
|
+
blk, _, (msg, _line), args = val
|
335
340
|
result = new_call(blk, msg.to_sym, args).line blk.line
|
336
341
|
}
|
337
342
|
|
@@ -345,15 +350,15 @@ rule
|
|
345
350
|
_, line, body, _ = val
|
346
351
|
|
347
352
|
result = body
|
348
|
-
result.line
|
353
|
+
result.line line
|
349
354
|
|
350
355
|
# self.env.unextend
|
351
356
|
}
|
352
357
|
|
353
358
|
fcall: operation
|
354
359
|
{
|
355
|
-
msg, = val
|
356
|
-
result = new_call(nil, msg.to_sym).line
|
360
|
+
(msg, line), = val
|
361
|
+
result = new_call(nil, msg.to_sym).line line
|
357
362
|
}
|
358
363
|
|
359
364
|
command: fcall command_args =tLOWEST
|
@@ -376,12 +381,14 @@ rule
|
|
376
381
|
}
|
377
382
|
| primary_value call_op operation2 command_args =tLOWEST
|
378
383
|
{
|
379
|
-
lhs, callop, op, args = val
|
384
|
+
lhs, callop, (op, _), args = val
|
385
|
+
|
380
386
|
result = new_call lhs, op.to_sym, args, callop
|
387
|
+
result.line lhs.line
|
381
388
|
}
|
382
389
|
| primary_value call_op operation2 command_args cmd_brace_block
|
383
390
|
{
|
384
|
-
recv, _, msg, args, block = val
|
391
|
+
recv, _, (msg, _line), args, block = val
|
385
392
|
call = new_call recv, msg.to_sym, args, val[1]
|
386
393
|
|
387
394
|
block_dup_check call, block
|
@@ -391,11 +398,14 @@ rule
|
|
391
398
|
}
|
392
399
|
| primary_value tCOLON2 operation2 command_args =tLOWEST
|
393
400
|
{
|
394
|
-
|
401
|
+
lhs, _, (id, line), args = val
|
402
|
+
|
403
|
+
result = new_call lhs, id.to_sym, args
|
404
|
+
result.line line
|
395
405
|
}
|
396
406
|
| primary_value tCOLON2 operation2 command_args cmd_brace_block
|
397
407
|
{
|
398
|
-
recv, _, msg, args, block = val
|
408
|
+
recv, _, (msg, _line), args, block = val
|
399
409
|
call = new_call recv, msg.to_sym, args
|
400
410
|
|
401
411
|
block_dup_check call, block
|
@@ -553,25 +563,29 @@ rule
|
|
553
563
|
}
|
554
564
|
| primary_value call_op tIDENTIFIER
|
555
565
|
{
|
556
|
-
|
566
|
+
lhs, call_op, (id, _line) = val
|
567
|
+
|
568
|
+
result = new_attrasgn lhs, id, call_op
|
557
569
|
}
|
558
570
|
| primary_value tCOLON2 tIDENTIFIER
|
559
571
|
{
|
560
|
-
recv, _, id = val
|
572
|
+
recv, _, (id, _line) = val
|
561
573
|
result = new_attrasgn recv, id
|
562
574
|
}
|
563
575
|
| primary_value call_op tCONSTANT
|
564
576
|
{
|
565
|
-
|
577
|
+
lhs, call_op, (id, _line) = val
|
578
|
+
|
579
|
+
result = new_attrasgn lhs, id, call_op
|
566
580
|
}
|
567
581
|
| primary_value tCOLON2 tCONSTANT
|
568
582
|
{
|
569
583
|
if (self.in_def || self.in_single > 0) then
|
570
|
-
|
584
|
+
debug 14
|
571
585
|
yyerror "dynamic constant assignment"
|
572
586
|
end
|
573
587
|
|
574
|
-
expr, _, id = val
|
588
|
+
expr, _, (id, _line) = val
|
575
589
|
l = expr.line
|
576
590
|
|
577
591
|
result = s(:const, s(:colon2, expr, id.to_sym).line(l), nil).line l
|
@@ -579,58 +593,65 @@ rule
|
|
579
593
|
| tCOLON3 tCONSTANT
|
580
594
|
{
|
581
595
|
if (self.in_def || self.in_single > 0) then
|
582
|
-
|
596
|
+
debug 15
|
583
597
|
yyerror "dynamic constant assignment"
|
584
598
|
end
|
585
599
|
|
586
|
-
_, id = val
|
587
|
-
l = lexer.lineno
|
600
|
+
_, (id, l) = val
|
588
601
|
|
589
602
|
result = s(:const, nil, s(:colon3, id.to_sym).line(l)).line l
|
590
603
|
}
|
591
604
|
| backref
|
592
605
|
{
|
593
|
-
|
606
|
+
ref, = val
|
607
|
+
|
608
|
+
self.backref_assign_error ref
|
594
609
|
}
|
595
610
|
|
596
611
|
lhs: user_variable
|
597
612
|
{
|
598
|
-
|
599
|
-
|
600
|
-
result
|
613
|
+
var, = val
|
614
|
+
|
615
|
+
result = self.assignable var
|
601
616
|
}
|
602
617
|
| keyword_variable
|
603
618
|
{
|
604
|
-
|
605
|
-
|
606
|
-
result
|
607
|
-
|
619
|
+
var, = val
|
620
|
+
|
621
|
+
result = self.assignable var
|
622
|
+
|
623
|
+
debug 16
|
608
624
|
}
|
609
625
|
| primary_value tLBRACK2 opt_call_args rbracket
|
610
626
|
{
|
611
627
|
lhs, _, args, _ = val
|
628
|
+
|
612
629
|
result = self.aryset lhs, args
|
613
630
|
}
|
614
631
|
| primary_value call_op tIDENTIFIER # REFACTOR
|
615
632
|
{
|
616
|
-
lhs, op, id = val
|
633
|
+
lhs, op, (id, _line) = val
|
634
|
+
|
617
635
|
result = new_attrasgn lhs, id, op
|
618
636
|
}
|
619
637
|
| primary_value tCOLON2 tIDENTIFIER
|
620
638
|
{
|
621
|
-
lhs, _, id = val
|
639
|
+
lhs, _, (id, _line) = val
|
640
|
+
|
622
641
|
result = new_attrasgn lhs, id
|
623
642
|
}
|
624
643
|
| primary_value call_op tCONSTANT # REFACTOR?
|
625
644
|
{
|
626
|
-
|
645
|
+
lhs, call_op, (id, _line) = val
|
646
|
+
|
647
|
+
result = new_attrasgn lhs, id, call_op
|
627
648
|
}
|
628
649
|
| primary_value tCOLON2 tCONSTANT
|
629
650
|
{
|
630
|
-
expr, _, id = val
|
651
|
+
expr, _, (id, _line) = val
|
631
652
|
|
632
653
|
if (self.in_def || self.in_single > 0) then
|
633
|
-
|
654
|
+
debug 17
|
634
655
|
yyerror "dynamic constant assignment"
|
635
656
|
end
|
636
657
|
|
@@ -639,14 +660,13 @@ rule
|
|
639
660
|
}
|
640
661
|
| tCOLON3 tCONSTANT
|
641
662
|
{
|
642
|
-
_, id = val
|
663
|
+
_, (id, l) = val
|
643
664
|
|
644
665
|
if (self.in_def || self.in_single > 0) then
|
645
|
-
|
666
|
+
debug 18
|
646
667
|
yyerror "dynamic constant assignment"
|
647
668
|
end
|
648
669
|
|
649
|
-
l = lexer.lineno
|
650
670
|
result = s(:const, s(:colon3, id.to_sym).line(l)).line l
|
651
671
|
}
|
652
672
|
| backref
|
@@ -662,16 +682,17 @@ rule
|
|
662
682
|
|
663
683
|
cpath: tCOLON3 cname
|
664
684
|
{
|
665
|
-
_, name = val
|
666
|
-
result = s(:colon3, name.to_sym).line
|
685
|
+
_, (name, line) = val
|
686
|
+
result = s(:colon3, name.to_sym).line line
|
667
687
|
}
|
668
688
|
| cname
|
669
689
|
{
|
670
|
-
|
690
|
+
(id, line), = val
|
691
|
+
result = [id.to_sym, line] # TODO: sexp?
|
671
692
|
}
|
672
693
|
| primary_value tCOLON2 cname
|
673
694
|
{
|
674
|
-
pval, _, name = val
|
695
|
+
pval, _, (name, _line) = val
|
675
696
|
|
676
697
|
result = s(:colon2, pval, name.to_sym)
|
677
698
|
result.line pval.line
|
@@ -681,24 +702,17 @@ rule
|
|
681
702
|
| op
|
682
703
|
{
|
683
704
|
lexer.lex_state = EXPR_END
|
684
|
-
result = val[0]
|
685
705
|
}
|
686
706
|
|
687
707
|
| reswords
|
688
|
-
{
|
689
|
-
(sym, _line), = val
|
690
|
-
lexer.lex_state = EXPR_END
|
691
|
-
result = sym
|
692
|
-
}
|
693
|
-
|
694
|
-
fsym: fname | symbol
|
695
708
|
|
696
|
-
fitem:
|
709
|
+
fitem: fname
|
697
710
|
{
|
698
|
-
id, = val
|
699
|
-
|
711
|
+
(id, line), = val
|
712
|
+
|
713
|
+
result = s(:lit, id.to_sym).line line
|
700
714
|
}
|
701
|
-
|
|
715
|
+
| symbol
|
702
716
|
|
703
717
|
undef_list: fitem
|
704
718
|
{
|
@@ -719,8 +733,6 @@ rule
|
|
719
733
|
| tNEQ | tLSHFT | tRSHFT | tPLUS | tMINUS | tSTAR2
|
720
734
|
| tSTAR | tDIVIDE | tPERCENT | tPOW | tDSTAR | tBANG | tTILDE
|
721
735
|
| tUPLUS | tUMINUS | tAREF | tASET | tBACK_REF2
|
722
|
-
# TODO: tUBANG dead?
|
723
|
-
| tUBANG
|
724
736
|
|
725
737
|
reswords: k__LINE__ | k__FILE__ | k__ENCODING__ | klBEGIN | klEND
|
726
738
|
| kALIAS | kAND | kBEGIN | kBREAK | kCASE
|
@@ -754,24 +766,20 @@ rule
|
|
754
766
|
}
|
755
767
|
| primary_value tCOLON2 tIDENTIFIER tOP_ASGN arg_rhs
|
756
768
|
{
|
757
|
-
lhs, _, id, op, rhs = val
|
769
|
+
lhs, _, (id, _line), (op, _), rhs = val
|
758
770
|
|
759
771
|
result = s(:op_asgn, lhs, rhs, id.to_sym, op.to_sym).line lhs.line
|
760
772
|
}
|
761
773
|
| primary_value tCOLON2 tCONSTANT tOP_ASGN arg_rhs
|
762
774
|
{
|
763
|
-
lhs1, _, lhs2, op, rhs = val
|
775
|
+
lhs1, _, (lhs2, _line), op, rhs = val
|
764
776
|
|
765
777
|
lhs = s(:colon2, lhs1, lhs2.to_sym).line lhs1.line
|
766
778
|
result = new_const_op_asgn [lhs, op, rhs]
|
767
779
|
}
|
768
|
-
| tCOLON3 tCONSTANT
|
769
|
-
{
|
770
|
-
result = self.lexer.lineno
|
771
|
-
}
|
772
|
-
tOP_ASGN arg_rhs
|
780
|
+
| tCOLON3 tCONSTANT tOP_ASGN arg_rhs
|
773
781
|
{
|
774
|
-
_, lhs, line, op, rhs = val
|
782
|
+
_, (lhs, line), op, rhs = val
|
775
783
|
|
776
784
|
lhs = s(:colon3, lhs.to_sym).line line
|
777
785
|
result = new_const_op_asgn [lhs, op, rhs]
|
@@ -785,7 +793,7 @@ rule
|
|
785
793
|
| arg tDOT2 arg
|
786
794
|
{
|
787
795
|
v1, v2 = val[0], val[2]
|
788
|
-
if v1.
|
796
|
+
if v1.sexp_type == :lit and v2.sexp_type == :lit and Integer === v1.last and Integer === v2.last then
|
789
797
|
result = s(:lit, (v1.last)..(v2.last)).line v1.line
|
790
798
|
else
|
791
799
|
result = s(:dot2, v1, v2).line v1.line
|
@@ -794,7 +802,7 @@ rule
|
|
794
802
|
| arg tDOT3 arg
|
795
803
|
{
|
796
804
|
v1, v2 = val[0], val[2]
|
797
|
-
if v1.
|
805
|
+
if v1.sexp_type == :lit and v2.sexp_type == :lit and Integer === v1.last and Integer === v2.last then
|
798
806
|
result = s(:lit, (v1.last)...(v2.last)).line v1.line
|
799
807
|
else
|
800
808
|
result = s(:dot3, v1, v2).line v1.line
|
@@ -828,16 +836,18 @@ rule
|
|
828
836
|
}
|
829
837
|
| tUMINUS_NUM tINTEGER tPOW arg
|
830
838
|
{
|
831
|
-
|
832
|
-
|
839
|
+
_, (num, line), _, arg = val
|
840
|
+
lit = s(:lit, num).line line
|
841
|
+
result = new_call(new_call(lit, :"**", argl(arg)), :"-@")
|
833
842
|
}
|
834
843
|
| tUMINUS_NUM tFLOAT tPOW arg
|
835
844
|
{
|
836
|
-
|
837
|
-
|
845
|
+
_, (num, line), _, arg = val
|
846
|
+
lit = s(:lit, num).line line
|
847
|
+
result = new_call(new_call(lit, :"**", argl(arg)), :"-@")
|
838
848
|
|
839
849
|
## TODO: why is this 2.0 only?
|
840
|
-
|
850
|
+
debug 19
|
841
851
|
}
|
842
852
|
| tUPLUS arg
|
843
853
|
{
|
@@ -935,12 +945,12 @@ rule
|
|
935
945
|
|
936
946
|
rel_expr: arg relop arg =tGT
|
937
947
|
{
|
938
|
-
lhs, op, rhs = val
|
948
|
+
lhs, (op, _), rhs = val
|
939
949
|
result = new_call lhs, op.to_sym, argl(rhs)
|
940
950
|
}
|
941
951
|
| rel_expr relop arg =tGT
|
942
952
|
{
|
943
|
-
lhs, op, rhs = val
|
953
|
+
lhs, (op, _), rhs = val
|
944
954
|
warn "comparison '%s' after comparison", op
|
945
955
|
result = new_call lhs, op.to_sym, argl(rhs)
|
946
956
|
}
|
@@ -1122,8 +1132,9 @@ rule
|
|
1122
1132
|
| backref
|
1123
1133
|
| tFID
|
1124
1134
|
{
|
1125
|
-
msg, = val
|
1135
|
+
(msg, line), = val
|
1126
1136
|
result = new_call nil, msg.to_sym
|
1137
|
+
result.line line
|
1127
1138
|
}
|
1128
1139
|
| k_begin
|
1129
1140
|
{
|
@@ -1165,15 +1176,15 @@ rule
|
|
1165
1176
|
}
|
1166
1177
|
| primary_value tCOLON2 tCONSTANT
|
1167
1178
|
{
|
1168
|
-
expr, _, id = val
|
1179
|
+
expr, _, (id, _line) = val
|
1169
1180
|
|
1170
1181
|
result = s(:colon2, expr, id.to_sym).line expr.line
|
1171
1182
|
}
|
1172
1183
|
| tCOLON3 tCONSTANT
|
1173
1184
|
{
|
1174
|
-
_, id = val
|
1185
|
+
_, (id, line) = val
|
1175
1186
|
|
1176
|
-
result = s(:colon3, id.to_sym).line
|
1187
|
+
result = s(:colon3, id.to_sym).line line
|
1177
1188
|
}
|
1178
1189
|
| tLBRACK { result = lexer.lineno } aref_args tRBRACK
|
1179
1190
|
{
|
@@ -1197,15 +1208,21 @@ rule
|
|
1197
1208
|
}
|
1198
1209
|
| kYIELD tLPAREN2 call_args rparen
|
1199
1210
|
{
|
1200
|
-
|
1211
|
+
(_, line), _, args, _ = val
|
1212
|
+
|
1213
|
+
result = new_yield(args).line line
|
1201
1214
|
}
|
1202
1215
|
| kYIELD tLPAREN2 rparen
|
1203
1216
|
{
|
1204
|
-
|
1217
|
+
(_, line), _, _ = val
|
1218
|
+
|
1219
|
+
result = new_yield.line line
|
1205
1220
|
}
|
1206
1221
|
| kYIELD
|
1207
1222
|
{
|
1208
|
-
|
1223
|
+
(_, line), = val
|
1224
|
+
|
1225
|
+
result = new_yield.line line
|
1209
1226
|
}
|
1210
1227
|
| kDEFINED opt_nl tLPAREN2 expr rparen
|
1211
1228
|
{
|
@@ -1220,7 +1237,7 @@ rule
|
|
1220
1237
|
}
|
1221
1238
|
| kNOT tLPAREN2 rparen
|
1222
1239
|
{
|
1223
|
-
|
1240
|
+
debug 20
|
1224
1241
|
}
|
1225
1242
|
| fcall brace_block
|
1226
1243
|
{
|
@@ -1238,9 +1255,10 @@ rule
|
|
1238
1255
|
iter.insert 1, call # FIX
|
1239
1256
|
result = iter
|
1240
1257
|
}
|
1241
|
-
|
|
1258
|
+
| lambda
|
1242
1259
|
{
|
1243
|
-
|
1260
|
+
expr, = val
|
1261
|
+
result = expr
|
1244
1262
|
}
|
1245
1263
|
| k_if expr_value then compstmt if_tail k_end
|
1246
1264
|
{
|
@@ -1283,7 +1301,6 @@ rule
|
|
1283
1301
|
}
|
1284
1302
|
cpath superclass
|
1285
1303
|
{
|
1286
|
-
self.comments.push self.lexer.comments
|
1287
1304
|
if (self.in_def || self.in_single > 0) then
|
1288
1305
|
yyerror "class definition in method body"
|
1289
1306
|
end
|
@@ -1293,7 +1310,7 @@ rule
|
|
1293
1310
|
{
|
1294
1311
|
result = new_class val
|
1295
1312
|
self.env.unextend
|
1296
|
-
self.lexer.
|
1313
|
+
self.lexer.ignore_body_comments
|
1297
1314
|
}
|
1298
1315
|
| k_class tLSHFT
|
1299
1316
|
{
|
@@ -1314,7 +1331,7 @@ rule
|
|
1314
1331
|
{
|
1315
1332
|
result = new_sclass val
|
1316
1333
|
self.env.unextend
|
1317
|
-
self.lexer.
|
1334
|
+
self.lexer.ignore_body_comments
|
1318
1335
|
}
|
1319
1336
|
| k_module
|
1320
1337
|
{
|
@@ -1322,7 +1339,6 @@ rule
|
|
1322
1339
|
}
|
1323
1340
|
cpath
|
1324
1341
|
{
|
1325
|
-
self.comments.push self.lexer.comments
|
1326
1342
|
yyerror "module definition in method body" if
|
1327
1343
|
self.in_def or self.in_single > 0
|
1328
1344
|
|
@@ -1332,7 +1348,7 @@ rule
|
|
1332
1348
|
{
|
1333
1349
|
result = new_module val
|
1334
1350
|
self.env.unextend
|
1335
|
-
self.lexer.
|
1351
|
+
self.lexer.ignore_body_comments
|
1336
1352
|
}
|
1337
1353
|
| k_def fname
|
1338
1354
|
{
|
@@ -1342,21 +1358,17 @@ rule
|
|
1342
1358
|
self.env.extend
|
1343
1359
|
lexer.cmdarg.push false
|
1344
1360
|
lexer.cond.push false
|
1345
|
-
|
1346
|
-
self.comments.push self.lexer.comments
|
1347
1361
|
}
|
1348
|
-
f_arglist bodystmt
|
1362
|
+
f_arglist bodystmt k_end
|
1349
1363
|
{
|
1350
|
-
in_def = val
|
1351
|
-
|
1352
|
-
result = new_defn val
|
1364
|
+
result, in_def = new_defn val
|
1353
1365
|
|
1354
1366
|
lexer.cond.pop # group = local_pop
|
1355
1367
|
lexer.cmdarg.pop
|
1356
1368
|
self.env.unextend
|
1357
1369
|
self.in_def = in_def
|
1358
1370
|
|
1359
|
-
self.lexer.
|
1371
|
+
self.lexer.ignore_body_comments
|
1360
1372
|
}
|
1361
1373
|
| k_def singleton dot_or_colon
|
1362
1374
|
{
|
@@ -1364,7 +1376,7 @@ rule
|
|
1364
1376
|
}
|
1365
1377
|
fname
|
1366
1378
|
{
|
1367
|
-
result =
|
1379
|
+
result = self.in_def
|
1368
1380
|
|
1369
1381
|
self.in_single += 1 # TODO: remove?
|
1370
1382
|
|
@@ -1374,13 +1386,18 @@ rule
|
|
1374
1386
|
lexer.cond.push false
|
1375
1387
|
|
1376
1388
|
lexer.lex_state = EXPR_ENDFN|EXPR_LABEL
|
1377
|
-
self.comments.push self.lexer.comments
|
1378
1389
|
}
|
1379
1390
|
f_arglist bodystmt k_end
|
1380
1391
|
{
|
1381
|
-
_, _recv, _, _, _name, (in_def, _lineno), _args, _body, _ = val
|
1382
1392
|
|
1383
|
-
|
1393
|
+
# [kdef, recv, _, _, (name, line), in_def, args, body, kend]
|
1394
|
+
# =>
|
1395
|
+
# [kdef, recv, (name, line), in_def, args, body, kend]
|
1396
|
+
|
1397
|
+
val.delete_at 3
|
1398
|
+
val.delete_at 2
|
1399
|
+
|
1400
|
+
result, in_def = new_defs val
|
1384
1401
|
|
1385
1402
|
lexer.cond.pop # group = local_pop
|
1386
1403
|
lexer.cmdarg.pop
|
@@ -1391,7 +1408,7 @@ rule
|
|
1391
1408
|
|
1392
1409
|
# TODO: restore cur_arg ? what's cur_arg?
|
1393
1410
|
|
1394
|
-
self.lexer.
|
1411
|
+
self.lexer.ignore_body_comments
|
1395
1412
|
}
|
1396
1413
|
| kBREAK
|
1397
1414
|
{
|
@@ -1428,8 +1445,17 @@ rule
|
|
1428
1445
|
k_case: kCASE
|
1429
1446
|
k_for: kFOR
|
1430
1447
|
k_class: kCLASS
|
1448
|
+
{
|
1449
|
+
self.comments.push self.lexer.comments
|
1450
|
+
}
|
1431
1451
|
k_module: kMODULE
|
1452
|
+
{
|
1453
|
+
self.comments.push self.lexer.comments
|
1454
|
+
}
|
1432
1455
|
k_def: kDEF
|
1456
|
+
{
|
1457
|
+
self.comments.push self.lexer.comments
|
1458
|
+
}
|
1433
1459
|
k_do: kDO
|
1434
1460
|
k_do_block: kDO_BLOCK
|
1435
1461
|
k_rescue: kRESCUE
|
@@ -1490,51 +1516,42 @@ rule
|
|
1490
1516
|
|
1491
1517
|
result = block_var args
|
1492
1518
|
}
|
1493
|
-
| f_marg_list tCOMMA
|
1519
|
+
| f_marg_list tCOMMA f_rest_marg
|
1494
1520
|
{
|
1495
|
-
args, _,
|
1521
|
+
args, _, rest = val
|
1496
1522
|
|
1497
|
-
result = block_var args,
|
1523
|
+
result = block_var args, rest
|
1498
1524
|
}
|
1499
|
-
| f_marg_list tCOMMA
|
1525
|
+
| f_marg_list tCOMMA f_rest_marg tCOMMA f_marg_list
|
1500
1526
|
{
|
1501
|
-
|
1527
|
+
lhs, _, splat, _, rhs = val
|
1502
1528
|
|
1503
|
-
result = block_var
|
1529
|
+
result = block_var lhs, splat, rhs
|
1504
1530
|
}
|
1505
|
-
|
|
1531
|
+
| f_rest_marg
|
1506
1532
|
{
|
1507
|
-
|
1533
|
+
rest, = val
|
1508
1534
|
|
1509
|
-
result = block_var
|
1535
|
+
result = block_var rest
|
1510
1536
|
}
|
1511
|
-
|
|
1537
|
+
| f_rest_marg tCOMMA f_marg_list
|
1512
1538
|
{
|
1513
|
-
|
1539
|
+
splat, _, rest = val
|
1514
1540
|
|
1515
|
-
result = block_var
|
1541
|
+
result = block_var splat, rest
|
1516
1542
|
}
|
1517
|
-
| tSTAR f_norm_arg
|
1518
|
-
{
|
1519
|
-
_, splat = val
|
1520
1543
|
|
1521
|
-
|
1522
|
-
}
|
1523
|
-
| tSTAR f_norm_arg tCOMMA f_marg_list
|
1544
|
+
f_rest_marg: tSTAR f_norm_arg
|
1524
1545
|
{
|
1525
|
-
_,
|
1546
|
+
_, (id, line) = val
|
1526
1547
|
|
1527
|
-
result =
|
1548
|
+
result = args ["*#{id}".to_sym]
|
1549
|
+
result.line line
|
1528
1550
|
}
|
1529
1551
|
| tSTAR
|
1530
1552
|
{
|
1531
|
-
result =
|
1532
|
-
|
1533
|
-
| tSTAR tCOMMA f_marg_list
|
1534
|
-
{
|
1535
|
-
_, _, args = val
|
1536
|
-
|
1537
|
-
result = block_var :*, args
|
1553
|
+
result = args [:*]
|
1554
|
+
result.line lexer.lineno # FIX: tSTAR -> line
|
1538
1555
|
}
|
1539
1556
|
|
1540
1557
|
block_args_tail: f_block_kwarg tCOMMA f_kwrest opt_f_block_arg
|
@@ -1551,8 +1568,8 @@ rule
|
|
1551
1568
|
}
|
1552
1569
|
| f_block_arg
|
1553
1570
|
{
|
1554
|
-
line =
|
1555
|
-
result = call_args
|
1571
|
+
(id, line), = val
|
1572
|
+
result = call_args [id]
|
1556
1573
|
result.line line
|
1557
1574
|
}
|
1558
1575
|
|
@@ -1661,13 +1678,13 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1661
1678
|
|
1662
1679
|
bvar: tIDENTIFIER
|
1663
1680
|
{
|
1664
|
-
id, = val
|
1665
|
-
line = lexer.lineno
|
1681
|
+
(id, line), = val
|
1666
1682
|
result = s(:shadow, id.to_sym).line line
|
1667
1683
|
}
|
1668
1684
|
| f_bad_arg
|
1669
1685
|
|
1670
|
-
lambda:
|
1686
|
+
lambda: tLAMBDA
|
1687
|
+
{
|
1671
1688
|
self.env.extend :dynamic
|
1672
1689
|
result = [lexer.lineno, lexer.lpar_beg]
|
1673
1690
|
lexer.paren_nest += 1
|
@@ -1679,14 +1696,14 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1679
1696
|
}
|
1680
1697
|
lambda_body
|
1681
1698
|
{
|
1682
|
-
(line, lpar), args, _cmdarg, body = val
|
1699
|
+
_, (line, lpar), args, _cmdarg, body = val
|
1683
1700
|
lexer.lpar_beg = lpar
|
1684
1701
|
|
1685
1702
|
lexer.cmdarg.pop
|
1686
1703
|
|
1687
1704
|
call = s(:lambda).line line
|
1688
1705
|
result = new_iter call, args, body
|
1689
|
-
result.line
|
1706
|
+
result.line line
|
1690
1707
|
self.env.unextend # TODO: dynapush & dynapop
|
1691
1708
|
}
|
1692
1709
|
|
@@ -1721,23 +1738,28 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1721
1738
|
## if (nd_type($1) == NODE_YIELD) {
|
1722
1739
|
## compile_error(PARSER_ARG "block given to yield");
|
1723
1740
|
|
1724
|
-
|
1725
|
-
val[0].block_pass?
|
1741
|
+
cmd, blk = val
|
1726
1742
|
|
1727
|
-
|
1743
|
+
syntax_error "Both block arg and actual block given." if
|
1744
|
+
cmd.block_pass?
|
1728
1745
|
|
1729
|
-
|
1746
|
+
if inverted? val then
|
1747
|
+
val = invert_block_call val
|
1748
|
+
cmd, blk = val
|
1749
|
+
end
|
1730
1750
|
|
1731
1751
|
result = blk
|
1732
1752
|
result.insert 1, cmd
|
1733
1753
|
}
|
1734
1754
|
| block_call call_op2 operation2 opt_paren_args
|
1735
1755
|
{
|
1736
|
-
|
1756
|
+
lhs, _, (id, _line), args = val
|
1757
|
+
|
1758
|
+
result = new_call lhs, id.to_sym, args
|
1737
1759
|
}
|
1738
1760
|
| block_call call_op2 operation2 opt_paren_args brace_block
|
1739
1761
|
{
|
1740
|
-
iter1, _, name, args, iter2 = val
|
1762
|
+
iter1, _, (name, _line), args, iter2 = val
|
1741
1763
|
|
1742
1764
|
call = new_call iter1, name.to_sym, args
|
1743
1765
|
iter2.insert 1, call
|
@@ -1746,7 +1768,7 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1746
1768
|
}
|
1747
1769
|
| block_call call_op2 operation2 command_args do_block
|
1748
1770
|
{
|
1749
|
-
iter1, _, name, args, iter2 = val
|
1771
|
+
iter1, _, (name, _line), args, iter2 = val
|
1750
1772
|
|
1751
1773
|
call = new_call iter1, name.to_sym, args
|
1752
1774
|
iter2.insert 1, call
|
@@ -1754,28 +1776,29 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1754
1776
|
result = iter2
|
1755
1777
|
}
|
1756
1778
|
|
1757
|
-
method_call: fcall
|
1779
|
+
method_call: fcall paren_args
|
1758
1780
|
{
|
1759
|
-
|
1760
|
-
}
|
1761
|
-
paren_args
|
1762
|
-
{
|
1763
|
-
call, lineno, args = val
|
1781
|
+
call, args = val
|
1764
1782
|
|
1765
1783
|
result = call.concat args.sexp_body if args
|
1766
|
-
result.line lineno
|
1767
1784
|
}
|
1768
1785
|
| primary_value call_op operation2 opt_paren_args
|
1769
1786
|
{
|
1770
|
-
|
1787
|
+
recv, call_op, (op, _line), args = val
|
1788
|
+
|
1789
|
+
result = new_call recv, op.to_sym, args, call_op
|
1771
1790
|
}
|
1772
1791
|
| primary_value tCOLON2 operation2 paren_args
|
1773
1792
|
{
|
1774
|
-
|
1793
|
+
recv, _, (op, _line), args = val
|
1794
|
+
|
1795
|
+
result = new_call recv, op.to_sym, args
|
1775
1796
|
}
|
1776
1797
|
| primary_value tCOLON2 operation3
|
1777
1798
|
{
|
1778
|
-
|
1799
|
+
lhs, _, (id, _line) = val
|
1800
|
+
|
1801
|
+
result = new_call lhs, id.to_sym
|
1779
1802
|
}
|
1780
1803
|
| primary_value call_op paren_args
|
1781
1804
|
{
|
@@ -1808,7 +1831,7 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1808
1831
|
_, line, body, _ = val
|
1809
1832
|
|
1810
1833
|
result = body
|
1811
|
-
result.line
|
1834
|
+
result.line line
|
1812
1835
|
|
1813
1836
|
self.env.unextend
|
1814
1837
|
}
|
@@ -1822,7 +1845,7 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1822
1845
|
_, line, body, _ = val
|
1823
1846
|
|
1824
1847
|
result = body
|
1825
|
-
result.line
|
1848
|
+
result.line line
|
1826
1849
|
|
1827
1850
|
self.env.unextend
|
1828
1851
|
}
|
@@ -1851,14 +1874,39 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1851
1874
|
self.env.unextend
|
1852
1875
|
}
|
1853
1876
|
|
1877
|
+
case_args: arg_value
|
1878
|
+
{
|
1879
|
+
arg, = val
|
1880
|
+
|
1881
|
+
result = s(:array, arg).line arg.line
|
1882
|
+
}
|
1883
|
+
| tSTAR arg_value
|
1884
|
+
{
|
1885
|
+
_, arg = val
|
1886
|
+
|
1887
|
+
result = s(:array, s(:splat, arg).line(arg.line)).line arg.line
|
1888
|
+
}
|
1889
|
+
| case_args tCOMMA arg_value
|
1890
|
+
{
|
1891
|
+
args, _, id = val
|
1892
|
+
|
1893
|
+
result = self.list_append args, id
|
1894
|
+
}
|
1895
|
+
| case_args tCOMMA tSTAR arg_value
|
1896
|
+
{
|
1897
|
+
args, _, _, id = val
|
1898
|
+
|
1899
|
+
result = self.list_append args, s(:splat, id).line(id.line)
|
1900
|
+
}
|
1901
|
+
|
1854
1902
|
case_body: k_when
|
1855
1903
|
{
|
1856
1904
|
result = self.lexer.lineno
|
1857
1905
|
}
|
1858
|
-
|
1906
|
+
case_args then compstmt cases
|
1859
1907
|
{
|
1860
1908
|
result = new_when(val[2], val[4])
|
1861
|
-
result.line
|
1909
|
+
result.line val[1]
|
1862
1910
|
result << val[5] if val[5]
|
1863
1911
|
}
|
1864
1912
|
|
@@ -1904,17 +1952,10 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1904
1952
|
|
1905
1953
|
literal: numeric
|
1906
1954
|
{
|
1907
|
-
line =
|
1908
|
-
result = s(:lit,
|
1909
|
-
result.line = line
|
1955
|
+
(lit, line), = val
|
1956
|
+
result = s(:lit, lit).line line
|
1910
1957
|
}
|
1911
1958
|
| symbol
|
1912
|
-
{
|
1913
|
-
line = lexer.lineno
|
1914
|
-
result = s(:lit, val[0])
|
1915
|
-
result.line = line
|
1916
|
-
}
|
1917
|
-
| dsym
|
1918
1959
|
|
1919
1960
|
strings: string
|
1920
1961
|
{
|
@@ -1925,7 +1966,7 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1925
1966
|
|
1926
1967
|
string: tCHAR
|
1927
1968
|
{
|
1928
|
-
|
1969
|
+
debug 37
|
1929
1970
|
}
|
1930
1971
|
| string1
|
1931
1972
|
| string string1
|
@@ -1935,11 +1976,11 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1935
1976
|
|
1936
1977
|
string1: tSTRING_BEG string_contents tSTRING_END
|
1937
1978
|
{
|
1938
|
-
_, str, (_, func) = val
|
1979
|
+
(_, line), str, (_, func) = val
|
1939
1980
|
|
1940
|
-
str = dedent str if func =~ RubyLexer::
|
1981
|
+
str = dedent str if func =~ RubyLexer::STR_FUNC_DEDENT
|
1941
1982
|
|
1942
|
-
result = str
|
1983
|
+
result = str.line line
|
1943
1984
|
}
|
1944
1985
|
| tSTRING
|
1945
1986
|
{
|
@@ -1959,11 +2000,15 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1959
2000
|
|
1960
2001
|
words: tWORDS_BEG tSPACE tSTRING_END
|
1961
2002
|
{
|
1962
|
-
|
2003
|
+
(_, line), _, _ = val
|
2004
|
+
|
2005
|
+
result = s(:array).line line
|
1963
2006
|
}
|
1964
2007
|
| tWORDS_BEG word_list tSTRING_END
|
1965
2008
|
{
|
1966
|
-
|
2009
|
+
(_, line), list, _ = val
|
2010
|
+
|
2011
|
+
result = list.line line
|
1967
2012
|
}
|
1968
2013
|
|
1969
2014
|
word_list: none
|
@@ -1983,18 +2028,20 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1983
2028
|
|
1984
2029
|
symbols: tSYMBOLS_BEG tSPACE tSTRING_END
|
1985
2030
|
{
|
1986
|
-
|
2031
|
+
(_, line), _, _ = val
|
2032
|
+
|
2033
|
+
result = s(:array).line line
|
1987
2034
|
}
|
1988
|
-
| tSYMBOLS_BEG
|
2035
|
+
| tSYMBOLS_BEG symbol_list tSTRING_END
|
1989
2036
|
{
|
1990
|
-
_, line, list, _, = val
|
1991
|
-
list.line
|
2037
|
+
(_, line), list, _, = val
|
2038
|
+
list.line line
|
1992
2039
|
result = list
|
1993
2040
|
}
|
1994
2041
|
|
1995
2042
|
symbol_list: none
|
1996
2043
|
{
|
1997
|
-
result = new_symbol_list
|
2044
|
+
result = new_symbol_list
|
1998
2045
|
}
|
1999
2046
|
| symbol_list word tSPACE
|
2000
2047
|
{
|
@@ -2004,20 +2051,28 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
2004
2051
|
|
2005
2052
|
qwords: tQWORDS_BEG tSPACE tSTRING_END
|
2006
2053
|
{
|
2007
|
-
|
2054
|
+
(_, line), _, _ = val
|
2055
|
+
|
2056
|
+
result = s(:array).line line
|
2008
2057
|
}
|
2009
2058
|
| tQWORDS_BEG qword_list tSTRING_END
|
2010
2059
|
{
|
2011
|
-
|
2060
|
+
(_, line), list, _ = val
|
2061
|
+
|
2062
|
+
result = list.line line
|
2012
2063
|
}
|
2013
2064
|
|
2014
2065
|
qsymbols: tQSYMBOLS_BEG tSPACE tSTRING_END
|
2015
2066
|
{
|
2016
|
-
|
2067
|
+
(_, line), _, _ = val
|
2068
|
+
|
2069
|
+
result = s(:array).line line
|
2017
2070
|
}
|
2018
2071
|
| tQSYMBOLS_BEG qsym_list tSTRING_END
|
2019
2072
|
{
|
2020
|
-
|
2073
|
+
(_, line), list, _ = val
|
2074
|
+
|
2075
|
+
result = list.line line
|
2021
2076
|
}
|
2022
2077
|
|
2023
2078
|
qword_list: none
|
@@ -2040,7 +2095,8 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
2040
2095
|
|
2041
2096
|
string_contents: none
|
2042
2097
|
{
|
2043
|
-
|
2098
|
+
line = prev_value_to_lineno _values.last
|
2099
|
+
result = s(:str, +"").line line
|
2044
2100
|
}
|
2045
2101
|
| string_contents string_content
|
2046
2102
|
{
|
@@ -2115,8 +2171,8 @@ regexp_contents: none
|
|
2115
2171
|
lexer.brace_nest = brace_nest
|
2116
2172
|
lexer.string_nest = string_nest
|
2117
2173
|
|
2118
|
-
lexer.cmdarg.pop
|
2119
2174
|
lexer.cond.pop
|
2175
|
+
lexer.cmdarg.pop
|
2120
2176
|
|
2121
2177
|
lexer.lex_state = oldlex_state
|
2122
2178
|
|
@@ -2131,29 +2187,49 @@ regexp_contents: none
|
|
2131
2187
|
when nil then
|
2132
2188
|
result = s(:evstr).line line
|
2133
2189
|
else
|
2134
|
-
|
2190
|
+
debug 38
|
2135
2191
|
raise "unknown string body: #{stmt.inspect}"
|
2136
2192
|
end
|
2137
2193
|
}
|
2138
2194
|
|
2139
|
-
string_dvar: tGVAR
|
2140
|
-
|
2141
|
-
|
2195
|
+
string_dvar: tGVAR
|
2196
|
+
{
|
2197
|
+
(id, line), = val
|
2198
|
+
result = s(:gvar, id.to_sym).line line
|
2199
|
+
}
|
2200
|
+
| tIVAR
|
2201
|
+
{
|
2202
|
+
(id, line), = val
|
2203
|
+
result = s(:ivar, id.to_sym).line line
|
2204
|
+
}
|
2205
|
+
| tCVAR
|
2206
|
+
{
|
2207
|
+
(id, line), = val
|
2208
|
+
result = s(:cvar, id.to_sym).line line
|
2209
|
+
}
|
2142
2210
|
| backref
|
2143
2211
|
|
2144
|
-
symbol:
|
2212
|
+
symbol: ssym
|
2213
|
+
| dsym
|
2214
|
+
|
2215
|
+
ssym: tSYMBEG sym
|
2145
2216
|
{
|
2217
|
+
_, (id, line) = val
|
2218
|
+
|
2146
2219
|
lexer.lex_state = EXPR_END
|
2147
|
-
result =
|
2220
|
+
result = s(:lit, id.to_sym).line line
|
2148
2221
|
}
|
2149
2222
|
| tSYMBOL
|
2150
2223
|
{
|
2151
|
-
|
2224
|
+
(id, line), = val
|
2225
|
+
|
2226
|
+
lexer.lex_state = EXPR_END
|
2227
|
+
result = s(:lit, id.to_sym).line line
|
2152
2228
|
}
|
2153
2229
|
|
2154
2230
|
sym: fname | tIVAR | tGVAR | tCVAR
|
2155
2231
|
|
2156
|
-
dsym: tSYMBEG
|
2232
|
+
dsym: tSYMBEG string_contents tSTRING_END
|
2157
2233
|
{
|
2158
2234
|
_, result, _ = val
|
2159
2235
|
|
@@ -2169,7 +2245,7 @@ regexp_contents: none
|
|
2169
2245
|
when :evstr then
|
2170
2246
|
result = s(:dsym, "", result).line result.line
|
2171
2247
|
else
|
2172
|
-
|
2248
|
+
debug 39
|
2173
2249
|
end
|
2174
2250
|
}
|
2175
2251
|
|
@@ -2177,11 +2253,13 @@ regexp_contents: none
|
|
2177
2253
|
| tFLOAT
|
2178
2254
|
| tUMINUS_NUM tINTEGER =tLOWEST
|
2179
2255
|
{
|
2180
|
-
|
2256
|
+
_, (num, line) = val
|
2257
|
+
result = [-num, line]
|
2181
2258
|
}
|
2182
2259
|
| tUMINUS_NUM tFLOAT =tLOWEST
|
2183
2260
|
{
|
2184
|
-
|
2261
|
+
_, (num, line) = val
|
2262
|
+
result = [-num, line]
|
2185
2263
|
}
|
2186
2264
|
|
2187
2265
|
user_variable: tIDENTIFIER
|
@@ -2209,8 +2287,10 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2209
2287
|
|
2210
2288
|
var_ref: user_variable
|
2211
2289
|
{
|
2212
|
-
|
2290
|
+
raise "NO: #{val.inspect}" if Sexp === val.first
|
2291
|
+
(var, line), = val
|
2213
2292
|
result = Sexp === var ? var : self.gettable(var)
|
2293
|
+
result.line line
|
2214
2294
|
}
|
2215
2295
|
| keyword_variable
|
2216
2296
|
{
|
@@ -2225,11 +2305,19 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2225
2305
|
| keyword_variable
|
2226
2306
|
{
|
2227
2307
|
result = self.assignable val[0]
|
2228
|
-
|
2308
|
+
debug 40
|
2229
2309
|
}
|
2230
2310
|
|
2231
|
-
backref: tNTH_REF
|
2232
|
-
|
2311
|
+
backref: tNTH_REF
|
2312
|
+
{
|
2313
|
+
(ref, line), = val
|
2314
|
+
result = s(:nth_ref, ref).line line
|
2315
|
+
}
|
2316
|
+
| tBACK_REF
|
2317
|
+
{
|
2318
|
+
(ref, line), = val
|
2319
|
+
result = s(:back_ref, ref).line line
|
2320
|
+
}
|
2233
2321
|
|
2234
2322
|
superclass: tLT
|
2235
2323
|
{
|
@@ -2247,9 +2335,7 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2247
2335
|
|
2248
2336
|
f_arglist: tLPAREN2 f_args rparen
|
2249
2337
|
{
|
2250
|
-
result = val
|
2251
|
-
self.lexer.lex_state = EXPR_BEG
|
2252
|
-
self.lexer.command_start = true
|
2338
|
+
result = end_args val
|
2253
2339
|
}
|
2254
2340
|
| {
|
2255
2341
|
result = self.in_kwarg
|
@@ -2258,12 +2344,7 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2258
2344
|
}
|
2259
2345
|
f_args term
|
2260
2346
|
{
|
2261
|
-
|
2262
|
-
|
2263
|
-
self.in_kwarg = kwarg
|
2264
|
-
result = args
|
2265
|
-
lexer.lex_state = EXPR_BEG
|
2266
|
-
lexer.command_start = true
|
2347
|
+
result = end_args val
|
2267
2348
|
}
|
2268
2349
|
|
2269
2350
|
args_tail: f_kwarg tCOMMA f_kwrest opt_f_block_arg
|
@@ -2348,9 +2429,9 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2348
2429
|
|
|
2349
2430
|
{
|
2350
2431
|
result = args val
|
2432
|
+
# result.line lexer.lineno
|
2351
2433
|
}
|
2352
2434
|
|
2353
|
-
args_forward: tBDOT3
|
2354
2435
|
|
2355
2436
|
f_bad_arg: tCONSTANT
|
2356
2437
|
{
|
@@ -2372,31 +2453,24 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2372
2453
|
f_norm_arg: f_bad_arg
|
2373
2454
|
| tIDENTIFIER
|
2374
2455
|
{
|
2375
|
-
|
2456
|
+
(id, line), = val
|
2457
|
+
identifier = id.to_sym
|
2376
2458
|
self.env[identifier] = :lvar
|
2377
2459
|
|
2378
|
-
result = identifier
|
2460
|
+
result = [identifier, line]
|
2379
2461
|
}
|
2380
2462
|
|
2381
2463
|
f_arg_item: f_norm_arg
|
2382
2464
|
| tLPAREN f_margs rparen
|
2383
2465
|
{
|
2384
|
-
|
2466
|
+
_, margs, _ = val
|
2467
|
+
|
2468
|
+
result = margs
|
2385
2469
|
}
|
2386
2470
|
|
2387
2471
|
f_arg: f_arg_item
|
2388
2472
|
{
|
2389
|
-
|
2390
|
-
|
2391
|
-
case arg
|
2392
|
-
when Symbol then
|
2393
|
-
result = s(:args, arg).line lexer.lineno
|
2394
|
-
when Sexp then
|
2395
|
-
result = arg
|
2396
|
-
else
|
2397
|
-
debug20 32
|
2398
|
-
raise "Unknown f_arg type: #{val.inspect}"
|
2399
|
-
end
|
2473
|
+
result = new_arg val
|
2400
2474
|
}
|
2401
2475
|
| f_arg tCOMMA f_arg_item
|
2402
2476
|
{
|
@@ -2408,7 +2482,7 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2408
2482
|
result = s(:args, list).line list.line
|
2409
2483
|
end
|
2410
2484
|
|
2411
|
-
result << item
|
2485
|
+
result << (Sexp === item ? item : item.first)
|
2412
2486
|
}
|
2413
2487
|
|
2414
2488
|
f_kw: tLABEL arg_value
|
@@ -2449,27 +2523,33 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2449
2523
|
kwrest_mark: tPOW
|
2450
2524
|
| tDSTAR
|
2451
2525
|
|
2526
|
+
|
2452
2527
|
f_kwrest: kwrest_mark tIDENTIFIER
|
2453
2528
|
{
|
2454
|
-
|
2455
|
-
|
2456
|
-
|
2529
|
+
_, (id, line) = val
|
2530
|
+
|
2531
|
+
name = id.to_sym
|
2532
|
+
self.assignable [name, line]
|
2533
|
+
result = [:"**#{name}", line]
|
2457
2534
|
}
|
2458
2535
|
| kwrest_mark
|
2459
2536
|
{
|
2460
|
-
|
2461
|
-
self.env[
|
2537
|
+
id = :"**"
|
2538
|
+
self.env[id] = :lvar # TODO: needed?!?
|
2539
|
+
result = [id, lexer.lineno] # TODO: tPOW/tDSTAR include lineno
|
2462
2540
|
}
|
2463
2541
|
|
2464
2542
|
f_opt: tIDENTIFIER tEQL arg_value
|
2465
2543
|
{
|
2466
|
-
|
2544
|
+
lhs, _, rhs = val
|
2545
|
+
result = self.assignable lhs, rhs
|
2467
2546
|
# TODO: detect duplicate names
|
2468
2547
|
}
|
2469
2548
|
|
2470
2549
|
f_block_opt: tIDENTIFIER tEQL primary_value
|
2471
2550
|
{
|
2472
|
-
|
2551
|
+
lhs, _, rhs = val
|
2552
|
+
result = self.assignable lhs, rhs
|
2473
2553
|
}
|
2474
2554
|
|
2475
2555
|
f_block_optarg: f_block_opt
|
@@ -2499,30 +2579,33 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2499
2579
|
f_rest_arg: restarg_mark tIDENTIFIER
|
2500
2580
|
{
|
2501
2581
|
# TODO: differs from parse.y - needs tests
|
2502
|
-
|
2503
|
-
|
2504
|
-
|
2582
|
+
_, (id, line) = val
|
2583
|
+
name = id.to_sym
|
2584
|
+
self.assignable [name, line]
|
2585
|
+
result = [:"*#{name}", line]
|
2505
2586
|
}
|
2506
2587
|
| restarg_mark
|
2507
2588
|
{
|
2508
2589
|
name = :"*"
|
2509
2590
|
self.env[name] = :lvar
|
2510
|
-
result = name
|
2591
|
+
result = [name, lexer.lineno] # FIX: tSTAR to include lineno
|
2511
2592
|
}
|
2512
2593
|
|
2513
2594
|
blkarg_mark: tAMPER2 | tAMPER
|
2514
2595
|
|
2515
2596
|
f_block_arg: blkarg_mark tIDENTIFIER
|
2516
2597
|
{
|
2517
|
-
|
2598
|
+
_, (id, line) = val
|
2599
|
+
identifier = id.to_sym
|
2518
2600
|
|
2519
2601
|
self.env[identifier] = :lvar
|
2520
|
-
result = "&#{identifier}".to_sym
|
2602
|
+
result = ["&#{identifier}".to_sym, line]
|
2521
2603
|
}
|
2522
2604
|
|
2523
2605
|
opt_f_block_arg: tCOMMA f_block_arg
|
2524
2606
|
{
|
2525
|
-
|
2607
|
+
_, arg = val
|
2608
|
+
result = arg
|
2526
2609
|
}
|
2527
2610
|
|
|
2528
2611
|
{
|