brakeman 5.0.2 → 5.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +46 -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.0}/History.rdoc +76 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/Manifest.txt +3 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/README.rdoc +1 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/compare/normalize.rb +6 -1
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/debugging.md +0 -0
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/gauntlet.md +106 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/lib/rp_extensions.rb +15 -36
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/rp_stringscanner.rb +33 -0
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/ruby20_parser.rb +7122 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/lib/ruby20_parser.y +327 -247
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/ruby21_parser.rb +7176 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/lib/ruby21_parser.y +322 -244
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/ruby22_parser.rb +7222 -0
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/ruby22_parser.y +2718 -0
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/ruby23_parser.rb +7231 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0/lib/ruby26_parser.y → ruby_parser-3.18.0/lib/ruby23_parser.y} +328 -271
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/ruby24_parser.rb +7262 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/lib/ruby24_parser.y +326 -246
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/ruby25_parser.rb +7262 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0/lib/ruby30_parser.y → ruby_parser-3.18.0/lib/ruby25_parser.y} +327 -276
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/ruby26_parser.rb +7281 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0/lib/ruby27_parser.y → ruby_parser-3.18.0/lib/ruby26_parser.y} +326 -260
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/ruby27_parser.rb +8511 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0/lib/ruby_parser.yy → ruby_parser-3.18.0/lib/ruby27_parser.y} +905 -355
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/ruby30_parser.rb +8741 -0
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/ruby30_parser.y +3463 -0
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/ruby3_parser.yy +3467 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/lib/ruby_lexer.rb +261 -609
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/lib/ruby_lexer.rex +27 -20
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/lib/ruby_lexer.rex.rb +59 -23
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/ruby_lexer_strings.rb +638 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/lib/ruby_parser.rb +0 -0
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.0/lib/ruby_parser.yy +3481 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/lib/ruby_parser_extras.rb +296 -115
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/tools/munge.rb +34 -6
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.0}/tools/ripper.rb +15 -10
- 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/check_execute.rb +10 -0
- data/lib/brakeman/checks/check_json_parsing.rb +1 -1
- data/lib/brakeman/checks/check_render.rb +15 -1
- data/lib/brakeman/checks/check_sql.rb +45 -8
- data/lib/brakeman/file_parser.rb +10 -2
- data/lib/brakeman/options.rb +6 -1
- data/lib/brakeman/processors/alias_processor.rb +41 -4
- data/lib/brakeman/processors/haml_template_processor.rb +9 -0
- data/lib/brakeman/processors/lib/call_conversion_helper.rb +2 -6
- data/lib/brakeman/processors/model_processor.rb +32 -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 +22 -3
- data/lib/brakeman/report/report_text.rb +1 -1
- data/lib/brakeman/rescanner.rb +1 -1
- data/lib/brakeman/scanner.rb +13 -13
- data/lib/brakeman/tracker/collection.rb +30 -2
- data/lib/brakeman/tracker/method_info.rb +41 -0
- data/lib/brakeman/util.rb +26 -18
- data/lib/brakeman/version.rb +1 -1
- data/lib/brakeman.rb +4 -2
- data/lib/ruby_parser/bm_sexp.rb +24 -0
- metadata +101 -98
- 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 -7070
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby21_parser.rb +0 -7143
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby22_parser.rb +0 -7180
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby22_parser.y +0 -2638
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby23_parser.rb +0 -7194
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby23_parser.y +0 -2640
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby24_parser.rb +0 -7214
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby25_parser.rb +0 -7213
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby25_parser.y +0 -2648
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby26_parser.rb +0 -7235
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby27_parser.rb +0 -7310
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby30_parser.rb +0 -7310
- data/bundle/ruby/2.7.0/gems/unicode-display_width-1.7.0/data/display_width.marshal.gz +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- racc -*-
|
2
2
|
|
3
|
-
class
|
3
|
+
class Ruby25Parser
|
4
4
|
|
5
5
|
token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
|
6
6
|
kTHEN kELSIF kELSE kCASE kWHEN kWHILE kUNTIL kFOR kBREAK kNEXT
|
@@ -18,11 +18,10 @@ 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
|
tRATIONAL tIMAGINARY
|
23
23
|
tLABEL_END
|
24
24
|
tLONELY
|
25
|
-
tBDOT2 tBDOT3
|
26
25
|
|
27
26
|
preclow
|
28
27
|
nonassoc tLOWEST
|
@@ -80,7 +79,7 @@ rule
|
|
80
79
|
| klBEGIN
|
81
80
|
{
|
82
81
|
if (self.in_def || self.in_single > 0) then
|
83
|
-
|
82
|
+
debug 11
|
84
83
|
yyerror "BEGIN in method"
|
85
84
|
end
|
86
85
|
self.env.extend
|
@@ -105,7 +104,9 @@ rule
|
|
105
104
|
bodystmt: compstmt opt_rescue k_else
|
106
105
|
{
|
107
106
|
res = _values[-2]
|
108
|
-
|
107
|
+
# TODO: move down to main match so I can just use val
|
108
|
+
|
109
|
+
warn "else without rescue is useless" unless res
|
109
110
|
}
|
110
111
|
compstmt
|
111
112
|
opt_ensure
|
@@ -135,7 +136,7 @@ rule
|
|
135
136
|
| error stmt
|
136
137
|
{
|
137
138
|
result = val[1]
|
138
|
-
|
139
|
+
debug 12
|
139
140
|
}
|
140
141
|
|
141
142
|
stmt_or_begin: stmt
|
@@ -143,6 +144,10 @@ rule
|
|
143
144
|
{
|
144
145
|
yyerror "BEGIN is permitted only at toplevel"
|
145
146
|
}
|
147
|
+
begin_block
|
148
|
+
{
|
149
|
+
result = val[2] # wtf?
|
150
|
+
}
|
146
151
|
|
147
152
|
stmt: kALIAS fitem
|
148
153
|
{
|
@@ -155,12 +160,12 @@ rule
|
|
155
160
|
}
|
156
161
|
| kALIAS tGVAR tGVAR
|
157
162
|
{
|
158
|
-
(_, line), lhs, rhs = val
|
163
|
+
(_, line), (lhs, _), (rhs, _) = val
|
159
164
|
result = s(:valias, lhs.to_sym, rhs.to_sym).line line
|
160
165
|
}
|
161
166
|
| kALIAS tGVAR tBACK_REF
|
162
167
|
{
|
163
|
-
(_, line), lhs, rhs = val
|
168
|
+
(_, line), (lhs, _), (rhs, _) = val
|
164
169
|
result = s(:valias, lhs.to_sym, :"$#{rhs}").line line
|
165
170
|
}
|
166
171
|
| kALIAS tGVAR tNTH_REF
|
@@ -203,7 +208,7 @@ rule
|
|
203
208
|
(_, line), _, stmt, _ = val
|
204
209
|
|
205
210
|
if (self.in_def || self.in_single > 0) then
|
206
|
-
|
211
|
+
debug 13
|
207
212
|
yyerror "END in method; use at_exit"
|
208
213
|
end
|
209
214
|
|
@@ -243,32 +248,31 @@ rule
|
|
243
248
|
}
|
244
249
|
| primary_value call_op tIDENTIFIER tOP_ASGN command_rhs
|
245
250
|
{
|
246
|
-
prim, _, id,
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
result.line = val[0].line
|
251
|
+
prim, (call_op, _), (id, _), (op_asgn, _), rhs = val
|
252
|
+
|
253
|
+
result = s(:op_asgn, prim, rhs, id.to_sym, op_asgn.to_sym)
|
254
|
+
result.sexp_type = :safe_op_asgn if call_op == '&.'
|
255
|
+
result.line prim.line
|
252
256
|
}
|
253
257
|
| primary_value call_op tCONSTANT tOP_ASGN command_rhs
|
254
258
|
{
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
result.line
|
259
|
+
prim, (call_op, _), (id, _), (op_asgn, _), rhs = val
|
260
|
+
|
261
|
+
result = s(:op_asgn, prim, rhs, id.to_sym, op_asgn.to_sym)
|
262
|
+
result.sexp_type = :safe_op_asgn if call_op == '&.'
|
263
|
+
result.line prim.line
|
260
264
|
}
|
261
265
|
| primary_value tCOLON2 tCONSTANT tOP_ASGN command_rhs
|
262
266
|
{
|
263
|
-
lhs1, _, lhs2,
|
267
|
+
lhs1, _, (lhs2, line), (id, _), rhs = val
|
264
268
|
|
265
|
-
result = s(:op_asgn, lhs1, rhs, lhs2.to_sym,
|
269
|
+
result = s(:op_asgn, lhs1, rhs, lhs2.to_sym, id.to_sym).line line
|
266
270
|
}
|
267
271
|
| primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_rhs
|
268
272
|
{
|
269
|
-
lhs1, _, lhs2,
|
273
|
+
lhs1, _, (lhs2, line), (id, _), rhs = val
|
270
274
|
|
271
|
-
result = s(:op_asgn, lhs1, rhs, lhs2.to_sym,
|
275
|
+
result = s(:op_asgn, lhs1, rhs, lhs2.to_sym, id.to_sym).line line
|
272
276
|
}
|
273
277
|
| backref tOP_ASGN command_rhs
|
274
278
|
{
|
@@ -314,7 +318,7 @@ rule
|
|
314
318
|
# TODO: fix line number to tBANG... but causes BAD shift/reduce conflict
|
315
319
|
# REFACTOR: call_uni_op -- see parse26.y
|
316
320
|
}
|
317
|
-
| arg
|
321
|
+
| arg =tLBRACE_ARG
|
318
322
|
|
319
323
|
expr_value: expr
|
320
324
|
{
|
@@ -339,7 +343,7 @@ rule
|
|
339
343
|
block_command: block_call
|
340
344
|
| block_call call_op2 operation2 command_args
|
341
345
|
{
|
342
|
-
blk, _, msg, args = val
|
346
|
+
blk, _, (msg, _line), args = val
|
343
347
|
result = new_call(blk, msg.to_sym, args).line blk.line
|
344
348
|
}
|
345
349
|
|
@@ -353,15 +357,15 @@ rule
|
|
353
357
|
_, line, body, _ = val
|
354
358
|
|
355
359
|
result = body
|
356
|
-
result.line
|
360
|
+
result.line line
|
357
361
|
|
358
362
|
# self.env.unextend
|
359
363
|
}
|
360
364
|
|
361
365
|
fcall: operation
|
362
366
|
{
|
363
|
-
msg, = val
|
364
|
-
result = new_call(nil, msg.to_sym).line
|
367
|
+
(msg, line), = val
|
368
|
+
result = new_call(nil, msg.to_sym).line line
|
365
369
|
}
|
366
370
|
|
367
371
|
command: fcall command_args =tLOWEST
|
@@ -384,12 +388,14 @@ rule
|
|
384
388
|
}
|
385
389
|
| primary_value call_op operation2 command_args =tLOWEST
|
386
390
|
{
|
387
|
-
lhs, callop, op, args = val
|
391
|
+
lhs, callop, (op, _), args = val
|
392
|
+
|
388
393
|
result = new_call lhs, op.to_sym, args, callop
|
394
|
+
result.line lhs.line
|
389
395
|
}
|
390
396
|
| primary_value call_op operation2 command_args cmd_brace_block
|
391
397
|
{
|
392
|
-
recv, _, msg, args, block = val
|
398
|
+
recv, _, (msg, _line), args, block = val
|
393
399
|
call = new_call recv, msg.to_sym, args, val[1]
|
394
400
|
|
395
401
|
block_dup_check call, block
|
@@ -399,11 +405,14 @@ rule
|
|
399
405
|
}
|
400
406
|
| primary_value tCOLON2 operation2 command_args =tLOWEST
|
401
407
|
{
|
402
|
-
|
408
|
+
lhs, _, (id, line), args = val
|
409
|
+
|
410
|
+
result = new_call lhs, id.to_sym, args
|
411
|
+
result.line line
|
403
412
|
}
|
404
413
|
| primary_value tCOLON2 operation2 command_args cmd_brace_block
|
405
414
|
{
|
406
|
-
recv, _, msg, args, block = val
|
415
|
+
recv, _, (msg, _line), args, block = val
|
407
416
|
call = new_call recv, msg.to_sym, args
|
408
417
|
|
409
418
|
block_dup_check call, block
|
@@ -561,25 +570,29 @@ rule
|
|
561
570
|
}
|
562
571
|
| primary_value call_op tIDENTIFIER
|
563
572
|
{
|
564
|
-
|
573
|
+
lhs, call_op, (id, _line) = val
|
574
|
+
|
575
|
+
result = new_attrasgn lhs, id, call_op
|
565
576
|
}
|
566
577
|
| primary_value tCOLON2 tIDENTIFIER
|
567
578
|
{
|
568
|
-
recv, _, id = val
|
579
|
+
recv, _, (id, _line) = val
|
569
580
|
result = new_attrasgn recv, id
|
570
581
|
}
|
571
582
|
| primary_value call_op tCONSTANT
|
572
583
|
{
|
573
|
-
|
584
|
+
lhs, call_op, (id, _line) = val
|
585
|
+
|
586
|
+
result = new_attrasgn lhs, id, call_op
|
574
587
|
}
|
575
588
|
| primary_value tCOLON2 tCONSTANT
|
576
589
|
{
|
577
590
|
if (self.in_def || self.in_single > 0) then
|
578
|
-
|
591
|
+
debug 14
|
579
592
|
yyerror "dynamic constant assignment"
|
580
593
|
end
|
581
594
|
|
582
|
-
expr, _, id = val
|
595
|
+
expr, _, (id, _line) = val
|
583
596
|
l = expr.line
|
584
597
|
|
585
598
|
result = s(:const, s(:colon2, expr, id.to_sym).line(l), nil).line l
|
@@ -587,58 +600,65 @@ rule
|
|
587
600
|
| tCOLON3 tCONSTANT
|
588
601
|
{
|
589
602
|
if (self.in_def || self.in_single > 0) then
|
590
|
-
|
603
|
+
debug 15
|
591
604
|
yyerror "dynamic constant assignment"
|
592
605
|
end
|
593
606
|
|
594
|
-
_, id = val
|
595
|
-
l = lexer.lineno
|
607
|
+
_, (id, l) = val
|
596
608
|
|
597
609
|
result = s(:const, nil, s(:colon3, id.to_sym).line(l)).line l
|
598
610
|
}
|
599
611
|
| backref
|
600
612
|
{
|
601
|
-
|
613
|
+
ref, = val
|
614
|
+
|
615
|
+
self.backref_assign_error ref
|
602
616
|
}
|
603
617
|
|
604
618
|
lhs: user_variable
|
605
619
|
{
|
606
|
-
|
607
|
-
|
608
|
-
result
|
620
|
+
var, = val
|
621
|
+
|
622
|
+
result = self.assignable var
|
609
623
|
}
|
610
624
|
| keyword_variable
|
611
625
|
{
|
612
|
-
|
613
|
-
|
614
|
-
result
|
615
|
-
|
626
|
+
var, = val
|
627
|
+
|
628
|
+
result = self.assignable var
|
629
|
+
|
630
|
+
debug 16
|
616
631
|
}
|
617
632
|
| primary_value tLBRACK2 opt_call_args rbracket
|
618
633
|
{
|
619
634
|
lhs, _, args, _ = val
|
635
|
+
|
620
636
|
result = self.aryset lhs, args
|
621
637
|
}
|
622
638
|
| primary_value call_op tIDENTIFIER # REFACTOR
|
623
639
|
{
|
624
|
-
lhs, op, id = val
|
640
|
+
lhs, op, (id, _line) = val
|
641
|
+
|
625
642
|
result = new_attrasgn lhs, id, op
|
626
643
|
}
|
627
644
|
| primary_value tCOLON2 tIDENTIFIER
|
628
645
|
{
|
629
|
-
lhs, _, id = val
|
646
|
+
lhs, _, (id, _line) = val
|
647
|
+
|
630
648
|
result = new_attrasgn lhs, id
|
631
649
|
}
|
632
650
|
| primary_value call_op tCONSTANT # REFACTOR?
|
633
651
|
{
|
634
|
-
|
652
|
+
lhs, call_op, (id, _line) = val
|
653
|
+
|
654
|
+
result = new_attrasgn lhs, id, call_op
|
635
655
|
}
|
636
656
|
| primary_value tCOLON2 tCONSTANT
|
637
657
|
{
|
638
|
-
expr, _, id = val
|
658
|
+
expr, _, (id, _line) = val
|
639
659
|
|
640
660
|
if (self.in_def || self.in_single > 0) then
|
641
|
-
|
661
|
+
debug 17
|
642
662
|
yyerror "dynamic constant assignment"
|
643
663
|
end
|
644
664
|
|
@@ -647,14 +667,13 @@ rule
|
|
647
667
|
}
|
648
668
|
| tCOLON3 tCONSTANT
|
649
669
|
{
|
650
|
-
_, id = val
|
670
|
+
_, (id, l) = val
|
651
671
|
|
652
672
|
if (self.in_def || self.in_single > 0) then
|
653
|
-
|
673
|
+
debug 18
|
654
674
|
yyerror "dynamic constant assignment"
|
655
675
|
end
|
656
676
|
|
657
|
-
l = lexer.lineno
|
658
677
|
result = s(:const, s(:colon3, id.to_sym).line(l)).line l
|
659
678
|
}
|
660
679
|
| backref
|
@@ -670,16 +689,17 @@ rule
|
|
670
689
|
|
671
690
|
cpath: tCOLON3 cname
|
672
691
|
{
|
673
|
-
_, name = val
|
674
|
-
result = s(:colon3, name.to_sym).line
|
692
|
+
_, (name, line) = val
|
693
|
+
result = s(:colon3, name.to_sym).line line
|
675
694
|
}
|
676
695
|
| cname
|
677
696
|
{
|
678
|
-
|
697
|
+
(id, line), = val
|
698
|
+
result = [id.to_sym, line] # TODO: sexp?
|
679
699
|
}
|
680
700
|
| primary_value tCOLON2 cname
|
681
701
|
{
|
682
|
-
pval, _, name = val
|
702
|
+
pval, _, (name, _line) = val
|
683
703
|
|
684
704
|
result = s(:colon2, pval, name.to_sym)
|
685
705
|
result.line pval.line
|
@@ -689,24 +709,17 @@ rule
|
|
689
709
|
| op
|
690
710
|
{
|
691
711
|
lexer.lex_state = EXPR_END
|
692
|
-
result = val[0]
|
693
712
|
}
|
694
713
|
|
695
714
|
| reswords
|
696
|
-
{
|
697
|
-
(sym, _line), = val
|
698
|
-
lexer.lex_state = EXPR_END
|
699
|
-
result = sym
|
700
|
-
}
|
701
715
|
|
702
|
-
|
703
|
-
|
704
|
-
fitem: fsym
|
716
|
+
fitem: fname
|
705
717
|
{
|
706
|
-
id, = val
|
707
|
-
|
718
|
+
(id, line), = val
|
719
|
+
|
720
|
+
result = s(:lit, id.to_sym).line line
|
708
721
|
}
|
709
|
-
|
|
722
|
+
| symbol
|
710
723
|
|
711
724
|
undef_list: fitem
|
712
725
|
{
|
@@ -727,8 +740,6 @@ rule
|
|
727
740
|
| tNEQ | tLSHFT | tRSHFT | tPLUS | tMINUS | tSTAR2
|
728
741
|
| tSTAR | tDIVIDE | tPERCENT | tPOW | tDSTAR | tBANG | tTILDE
|
729
742
|
| tUPLUS | tUMINUS | tAREF | tASET | tBACK_REF2
|
730
|
-
# TODO: tUBANG dead?
|
731
|
-
| tUBANG
|
732
743
|
|
733
744
|
reswords: k__LINE__ | k__FILE__ | k__ENCODING__ | klBEGIN | klEND
|
734
745
|
| kALIAS | kAND | kBEGIN | kBREAK | kCASE
|
@@ -762,24 +773,20 @@ rule
|
|
762
773
|
}
|
763
774
|
| primary_value tCOLON2 tIDENTIFIER tOP_ASGN arg_rhs
|
764
775
|
{
|
765
|
-
lhs, _, id, op, rhs = val
|
776
|
+
lhs, _, (id, _line), (op, _), rhs = val
|
766
777
|
|
767
778
|
result = s(:op_asgn, lhs, rhs, id.to_sym, op.to_sym).line lhs.line
|
768
779
|
}
|
769
780
|
| primary_value tCOLON2 tCONSTANT tOP_ASGN arg_rhs
|
770
781
|
{
|
771
|
-
lhs1, _, lhs2, op, rhs = val
|
782
|
+
lhs1, _, (lhs2, _line), op, rhs = val
|
772
783
|
|
773
784
|
lhs = s(:colon2, lhs1, lhs2.to_sym).line lhs1.line
|
774
785
|
result = new_const_op_asgn [lhs, op, rhs]
|
775
786
|
}
|
776
|
-
| tCOLON3 tCONSTANT
|
777
|
-
{
|
778
|
-
result = self.lexer.lineno
|
779
|
-
}
|
780
|
-
tOP_ASGN arg_rhs
|
787
|
+
| tCOLON3 tCONSTANT tOP_ASGN arg_rhs
|
781
788
|
{
|
782
|
-
_, lhs, line, op, rhs = val
|
789
|
+
_, (lhs, line), op, rhs = val
|
783
790
|
|
784
791
|
lhs = s(:colon3, lhs.to_sym).line line
|
785
792
|
result = new_const_op_asgn [lhs, op, rhs]
|
@@ -793,7 +800,7 @@ rule
|
|
793
800
|
| arg tDOT2 arg
|
794
801
|
{
|
795
802
|
v1, v2 = val[0], val[2]
|
796
|
-
if v1.
|
803
|
+
if v1.sexp_type == :lit and v2.sexp_type == :lit and Integer === v1.last and Integer === v2.last then
|
797
804
|
result = s(:lit, (v1.last)..(v2.last)).line v1.line
|
798
805
|
else
|
799
806
|
result = s(:dot2, v1, v2).line v1.line
|
@@ -802,41 +809,13 @@ rule
|
|
802
809
|
| arg tDOT3 arg
|
803
810
|
{
|
804
811
|
v1, v2 = val[0], val[2]
|
805
|
-
if v1.
|
812
|
+
if v1.sexp_type == :lit and v2.sexp_type == :lit and Integer === v1.last and Integer === v2.last then
|
806
813
|
result = s(:lit, (v1.last)...(v2.last)).line v1.line
|
807
814
|
else
|
808
815
|
result = s(:dot3, v1, v2).line v1.line
|
809
816
|
end
|
810
817
|
}
|
811
|
-
| arg tDOT2
|
812
|
-
{
|
813
|
-
v1, _ = val
|
814
|
-
v2 = nil
|
815
818
|
|
816
|
-
result = s(:dot2, v1, v2).line v1.line
|
817
|
-
}
|
818
|
-
| arg tDOT3
|
819
|
-
{
|
820
|
-
v1, _ = val
|
821
|
-
v2 = nil
|
822
|
-
|
823
|
-
result = s(:dot3, v1, v2).line v1.line
|
824
|
-
}
|
825
|
-
|
826
|
-
| tBDOT2 arg
|
827
|
-
{
|
828
|
-
_, v2, = val
|
829
|
-
v1 = nil
|
830
|
-
|
831
|
-
result = s(:dot2, v1, v2).line v2.line
|
832
|
-
}
|
833
|
-
| tBDOT3 arg
|
834
|
-
{
|
835
|
-
_, v2 = val
|
836
|
-
v1 = nil
|
837
|
-
|
838
|
-
result = s(:dot3, v1, v2).line v2.line
|
839
|
-
}
|
840
819
|
|
841
820
|
| arg tPLUS arg
|
842
821
|
{
|
@@ -864,8 +843,9 @@ rule
|
|
864
843
|
}
|
865
844
|
| tUMINUS_NUM simple_numeric tPOW arg
|
866
845
|
{
|
867
|
-
|
868
|
-
|
846
|
+
_, (num, line), _, arg = val
|
847
|
+
lit = s(:lit, num).line line
|
848
|
+
result = new_call(new_call(lit, :"**", argl(arg)), :"-@")
|
869
849
|
|
870
850
|
}
|
871
851
|
| tUPLUS arg
|
@@ -964,12 +944,12 @@ rule
|
|
964
944
|
|
965
945
|
rel_expr: arg relop arg =tGT
|
966
946
|
{
|
967
|
-
lhs, op, rhs = val
|
947
|
+
lhs, (op, _), rhs = val
|
968
948
|
result = new_call lhs, op.to_sym, argl(rhs)
|
969
949
|
}
|
970
950
|
| rel_expr relop arg =tGT
|
971
951
|
{
|
972
|
-
lhs, op, rhs = val
|
952
|
+
lhs, (op, _), rhs = val
|
973
953
|
warn "comparison '%s' after comparison", op
|
974
954
|
result = new_call lhs, op.to_sym, argl(rhs)
|
975
955
|
}
|
@@ -1160,8 +1140,9 @@ rule
|
|
1160
1140
|
| backref
|
1161
1141
|
| tFID
|
1162
1142
|
{
|
1163
|
-
msg, = val
|
1143
|
+
(msg, line), = val
|
1164
1144
|
result = new_call nil, msg.to_sym
|
1145
|
+
result.line line
|
1165
1146
|
}
|
1166
1147
|
| k_begin
|
1167
1148
|
{
|
@@ -1203,15 +1184,15 @@ rule
|
|
1203
1184
|
}
|
1204
1185
|
| primary_value tCOLON2 tCONSTANT
|
1205
1186
|
{
|
1206
|
-
expr, _, id = val
|
1187
|
+
expr, _, (id, _line) = val
|
1207
1188
|
|
1208
1189
|
result = s(:colon2, expr, id.to_sym).line expr.line
|
1209
1190
|
}
|
1210
1191
|
| tCOLON3 tCONSTANT
|
1211
1192
|
{
|
1212
|
-
_, id = val
|
1193
|
+
_, (id, line) = val
|
1213
1194
|
|
1214
|
-
result = s(:colon3, id.to_sym).line
|
1195
|
+
result = s(:colon3, id.to_sym).line line
|
1215
1196
|
}
|
1216
1197
|
| tLBRACK { result = lexer.lineno } aref_args tRBRACK
|
1217
1198
|
{
|
@@ -1258,7 +1239,7 @@ rule
|
|
1258
1239
|
}
|
1259
1240
|
| kNOT tLPAREN2 rparen
|
1260
1241
|
{
|
1261
|
-
|
1242
|
+
debug 20
|
1262
1243
|
}
|
1263
1244
|
| fcall brace_block
|
1264
1245
|
{
|
@@ -1276,9 +1257,10 @@ rule
|
|
1276
1257
|
iter.insert 1, call # FIX
|
1277
1258
|
result = iter
|
1278
1259
|
}
|
1279
|
-
|
|
1260
|
+
| lambda
|
1280
1261
|
{
|
1281
|
-
|
1262
|
+
expr, = val
|
1263
|
+
result = expr
|
1282
1264
|
}
|
1283
1265
|
| k_if expr_value then compstmt if_tail k_end
|
1284
1266
|
{
|
@@ -1321,7 +1303,6 @@ rule
|
|
1321
1303
|
}
|
1322
1304
|
cpath superclass
|
1323
1305
|
{
|
1324
|
-
self.comments.push self.lexer.comments
|
1325
1306
|
if (self.in_def || self.in_single > 0) then
|
1326
1307
|
yyerror "class definition in method body"
|
1327
1308
|
end
|
@@ -1331,7 +1312,7 @@ rule
|
|
1331
1312
|
{
|
1332
1313
|
result = new_class val
|
1333
1314
|
self.env.unextend
|
1334
|
-
self.lexer.
|
1315
|
+
self.lexer.ignore_body_comments
|
1335
1316
|
}
|
1336
1317
|
| k_class tLSHFT
|
1337
1318
|
{
|
@@ -1352,7 +1333,7 @@ rule
|
|
1352
1333
|
{
|
1353
1334
|
result = new_sclass val
|
1354
1335
|
self.env.unextend
|
1355
|
-
self.lexer.
|
1336
|
+
self.lexer.ignore_body_comments
|
1356
1337
|
}
|
1357
1338
|
| k_module
|
1358
1339
|
{
|
@@ -1360,7 +1341,6 @@ rule
|
|
1360
1341
|
}
|
1361
1342
|
cpath
|
1362
1343
|
{
|
1363
|
-
self.comments.push self.lexer.comments
|
1364
1344
|
yyerror "module definition in method body" if
|
1365
1345
|
self.in_def or self.in_single > 0
|
1366
1346
|
|
@@ -1370,7 +1350,7 @@ rule
|
|
1370
1350
|
{
|
1371
1351
|
result = new_module val
|
1372
1352
|
self.env.unextend
|
1373
|
-
self.lexer.
|
1353
|
+
self.lexer.ignore_body_comments
|
1374
1354
|
}
|
1375
1355
|
| k_def fname
|
1376
1356
|
{
|
@@ -1380,21 +1360,17 @@ rule
|
|
1380
1360
|
self.env.extend
|
1381
1361
|
lexer.cmdarg.push false
|
1382
1362
|
lexer.cond.push false
|
1383
|
-
|
1384
|
-
self.comments.push self.lexer.comments
|
1385
1363
|
}
|
1386
|
-
f_arglist bodystmt
|
1364
|
+
f_arglist bodystmt k_end
|
1387
1365
|
{
|
1388
|
-
in_def = val
|
1389
|
-
|
1390
|
-
result = new_defn val
|
1366
|
+
result, in_def = new_defn val
|
1391
1367
|
|
1392
1368
|
lexer.cond.pop # group = local_pop
|
1393
1369
|
lexer.cmdarg.pop
|
1394
1370
|
self.env.unextend
|
1395
1371
|
self.in_def = in_def
|
1396
1372
|
|
1397
|
-
self.lexer.
|
1373
|
+
self.lexer.ignore_body_comments
|
1398
1374
|
}
|
1399
1375
|
| k_def singleton dot_or_colon
|
1400
1376
|
{
|
@@ -1402,7 +1378,7 @@ rule
|
|
1402
1378
|
}
|
1403
1379
|
fname
|
1404
1380
|
{
|
1405
|
-
result =
|
1381
|
+
result = self.in_def
|
1406
1382
|
|
1407
1383
|
self.in_single += 1 # TODO: remove?
|
1408
1384
|
|
@@ -1412,13 +1388,18 @@ rule
|
|
1412
1388
|
lexer.cond.push false
|
1413
1389
|
|
1414
1390
|
lexer.lex_state = EXPR_ENDFN|EXPR_LABEL
|
1415
|
-
self.comments.push self.lexer.comments
|
1416
1391
|
}
|
1417
1392
|
f_arglist bodystmt k_end
|
1418
1393
|
{
|
1419
|
-
_, _recv, _, _, _name, (in_def, _lineno), _args, _body, _ = val
|
1420
1394
|
|
1421
|
-
|
1395
|
+
# [kdef, recv, _, _, (name, line), in_def, args, body, kend]
|
1396
|
+
# =>
|
1397
|
+
# [kdef, recv, (name, line), in_def, args, body, kend]
|
1398
|
+
|
1399
|
+
val.delete_at 3
|
1400
|
+
val.delete_at 2
|
1401
|
+
|
1402
|
+
result, in_def = new_defs val
|
1422
1403
|
|
1423
1404
|
lexer.cond.pop # group = local_pop
|
1424
1405
|
lexer.cmdarg.pop
|
@@ -1429,7 +1410,7 @@ rule
|
|
1429
1410
|
|
1430
1411
|
# TODO: restore cur_arg ? what's cur_arg?
|
1431
1412
|
|
1432
|
-
self.lexer.
|
1413
|
+
self.lexer.ignore_body_comments
|
1433
1414
|
}
|
1434
1415
|
| kBREAK
|
1435
1416
|
{
|
@@ -1466,8 +1447,17 @@ rule
|
|
1466
1447
|
k_case: kCASE
|
1467
1448
|
k_for: kFOR
|
1468
1449
|
k_class: kCLASS
|
1450
|
+
{
|
1451
|
+
self.comments.push self.lexer.comments
|
1452
|
+
}
|
1469
1453
|
k_module: kMODULE
|
1454
|
+
{
|
1455
|
+
self.comments.push self.lexer.comments
|
1456
|
+
}
|
1470
1457
|
k_def: kDEF
|
1458
|
+
{
|
1459
|
+
self.comments.push self.lexer.comments
|
1460
|
+
}
|
1471
1461
|
k_do: kDO
|
1472
1462
|
k_do_block: kDO_BLOCK
|
1473
1463
|
k_rescue: kRESCUE
|
@@ -1528,51 +1518,42 @@ rule
|
|
1528
1518
|
|
1529
1519
|
result = block_var args
|
1530
1520
|
}
|
1531
|
-
| f_marg_list tCOMMA
|
1521
|
+
| f_marg_list tCOMMA f_rest_marg
|
1532
1522
|
{
|
1533
|
-
args, _,
|
1523
|
+
args, _, rest = val
|
1534
1524
|
|
1535
|
-
result = block_var args,
|
1525
|
+
result = block_var args, rest
|
1536
1526
|
}
|
1537
|
-
| f_marg_list tCOMMA
|
1527
|
+
| f_marg_list tCOMMA f_rest_marg tCOMMA f_marg_list
|
1538
1528
|
{
|
1539
|
-
|
1529
|
+
lhs, _, splat, _, rhs = val
|
1540
1530
|
|
1541
|
-
result = block_var
|
1531
|
+
result = block_var lhs, splat, rhs
|
1542
1532
|
}
|
1543
|
-
|
|
1533
|
+
| f_rest_marg
|
1544
1534
|
{
|
1545
|
-
|
1535
|
+
rest, = val
|
1546
1536
|
|
1547
|
-
result = block_var
|
1537
|
+
result = block_var rest
|
1548
1538
|
}
|
1549
|
-
|
|
1539
|
+
| f_rest_marg tCOMMA f_marg_list
|
1550
1540
|
{
|
1551
|
-
|
1541
|
+
splat, _, rest = val
|
1552
1542
|
|
1553
|
-
result = block_var
|
1543
|
+
result = block_var splat, rest
|
1554
1544
|
}
|
1555
|
-
| tSTAR f_norm_arg
|
1556
|
-
{
|
1557
|
-
_, splat = val
|
1558
1545
|
|
1559
|
-
|
1560
|
-
}
|
1561
|
-
| tSTAR f_norm_arg tCOMMA f_marg_list
|
1546
|
+
f_rest_marg: tSTAR f_norm_arg
|
1562
1547
|
{
|
1563
|
-
_,
|
1548
|
+
_, (id, line) = val
|
1564
1549
|
|
1565
|
-
result =
|
1550
|
+
result = args ["*#{id}".to_sym]
|
1551
|
+
result.line line
|
1566
1552
|
}
|
1567
1553
|
| tSTAR
|
1568
1554
|
{
|
1569
|
-
result =
|
1570
|
-
|
1571
|
-
| tSTAR tCOMMA f_marg_list
|
1572
|
-
{
|
1573
|
-
_, _, args = val
|
1574
|
-
|
1575
|
-
result = block_var :*, args
|
1555
|
+
result = args [:*]
|
1556
|
+
result.line lexer.lineno # FIX: tSTAR -> line
|
1576
1557
|
}
|
1577
1558
|
|
1578
1559
|
block_args_tail: f_block_kwarg tCOMMA f_kwrest opt_f_block_arg
|
@@ -1589,8 +1570,8 @@ rule
|
|
1589
1570
|
}
|
1590
1571
|
| f_block_arg
|
1591
1572
|
{
|
1592
|
-
line =
|
1593
|
-
result = call_args
|
1573
|
+
(id, line), = val
|
1574
|
+
result = call_args [id]
|
1594
1575
|
result.line line
|
1595
1576
|
}
|
1596
1577
|
|
@@ -1699,13 +1680,13 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1699
1680
|
|
1700
1681
|
bvar: tIDENTIFIER
|
1701
1682
|
{
|
1702
|
-
id, = val
|
1703
|
-
line = lexer.lineno
|
1683
|
+
(id, line), = val
|
1704
1684
|
result = s(:shadow, id.to_sym).line line
|
1705
1685
|
}
|
1706
1686
|
| f_bad_arg
|
1707
1687
|
|
1708
|
-
lambda:
|
1688
|
+
lambda: tLAMBDA
|
1689
|
+
{
|
1709
1690
|
self.env.extend :dynamic
|
1710
1691
|
result = [lexer.lineno, lexer.lpar_beg]
|
1711
1692
|
lexer.paren_nest += 1
|
@@ -1717,14 +1698,14 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1717
1698
|
}
|
1718
1699
|
lambda_body
|
1719
1700
|
{
|
1720
|
-
(line, lpar), args, _cmdarg, body = val
|
1701
|
+
_, (line, lpar), args, _cmdarg, body = val
|
1721
1702
|
lexer.lpar_beg = lpar
|
1722
1703
|
|
1723
1704
|
lexer.cmdarg.pop
|
1724
1705
|
|
1725
1706
|
call = s(:lambda).line line
|
1726
1707
|
result = new_iter call, args, body
|
1727
|
-
result.line
|
1708
|
+
result.line line
|
1728
1709
|
self.env.unextend # TODO: dynapush & dynapop
|
1729
1710
|
}
|
1730
1711
|
|
@@ -1759,23 +1740,28 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1759
1740
|
## if (nd_type($1) == NODE_YIELD) {
|
1760
1741
|
## compile_error(PARSER_ARG "block given to yield");
|
1761
1742
|
|
1762
|
-
|
1763
|
-
val[0].block_pass?
|
1743
|
+
cmd, blk = val
|
1764
1744
|
|
1765
|
-
|
1745
|
+
syntax_error "Both block arg and actual block given." if
|
1746
|
+
cmd.block_pass?
|
1766
1747
|
|
1767
|
-
|
1748
|
+
if inverted? val then
|
1749
|
+
val = invert_block_call val
|
1750
|
+
cmd, blk = val
|
1751
|
+
end
|
1768
1752
|
|
1769
1753
|
result = blk
|
1770
1754
|
result.insert 1, cmd
|
1771
1755
|
}
|
1772
1756
|
| block_call call_op2 operation2 opt_paren_args
|
1773
1757
|
{
|
1774
|
-
|
1758
|
+
lhs, _, (id, _line), args = val
|
1759
|
+
|
1760
|
+
result = new_call lhs, id.to_sym, args
|
1775
1761
|
}
|
1776
1762
|
| block_call call_op2 operation2 opt_paren_args brace_block
|
1777
1763
|
{
|
1778
|
-
iter1, _, name, args, iter2 = val
|
1764
|
+
iter1, _, (name, _line), args, iter2 = val
|
1779
1765
|
|
1780
1766
|
call = new_call iter1, name.to_sym, args
|
1781
1767
|
iter2.insert 1, call
|
@@ -1784,7 +1770,7 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1784
1770
|
}
|
1785
1771
|
| block_call call_op2 operation2 command_args do_block
|
1786
1772
|
{
|
1787
|
-
iter1, _, name, args, iter2 = val
|
1773
|
+
iter1, _, (name, _line), args, iter2 = val
|
1788
1774
|
|
1789
1775
|
call = new_call iter1, name.to_sym, args
|
1790
1776
|
iter2.insert 1, call
|
@@ -1792,28 +1778,29 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1792
1778
|
result = iter2
|
1793
1779
|
}
|
1794
1780
|
|
1795
|
-
method_call: fcall
|
1796
|
-
{
|
1797
|
-
result = self.lexer.lineno
|
1798
|
-
}
|
1799
|
-
paren_args
|
1781
|
+
method_call: fcall paren_args
|
1800
1782
|
{
|
1801
|
-
call,
|
1783
|
+
call, args = val
|
1802
1784
|
|
1803
1785
|
result = call.concat args.sexp_body if args
|
1804
|
-
result.line lineno
|
1805
1786
|
}
|
1806
1787
|
| primary_value call_op operation2 opt_paren_args
|
1807
1788
|
{
|
1808
|
-
|
1789
|
+
recv, call_op, (op, _line), args = val
|
1790
|
+
|
1791
|
+
result = new_call recv, op.to_sym, args, call_op
|
1809
1792
|
}
|
1810
1793
|
| primary_value tCOLON2 operation2 paren_args
|
1811
1794
|
{
|
1812
|
-
|
1795
|
+
recv, _, (op, _line), args = val
|
1796
|
+
|
1797
|
+
result = new_call recv, op.to_sym, args
|
1813
1798
|
}
|
1814
1799
|
| primary_value tCOLON2 operation3
|
1815
1800
|
{
|
1816
|
-
|
1801
|
+
lhs, _, (id, _line) = val
|
1802
|
+
|
1803
|
+
result = new_call lhs, id.to_sym
|
1817
1804
|
}
|
1818
1805
|
| primary_value call_op paren_args
|
1819
1806
|
{
|
@@ -1846,7 +1833,7 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1846
1833
|
_, line, body, _ = val
|
1847
1834
|
|
1848
1835
|
result = body
|
1849
|
-
result.line
|
1836
|
+
result.line line
|
1850
1837
|
|
1851
1838
|
self.env.unextend
|
1852
1839
|
}
|
@@ -1860,7 +1847,7 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1860
1847
|
_, line, body, _ = val
|
1861
1848
|
|
1862
1849
|
result = body
|
1863
|
-
result.line
|
1850
|
+
result.line line
|
1864
1851
|
|
1865
1852
|
self.env.unextend
|
1866
1853
|
}
|
@@ -1889,14 +1876,39 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1889
1876
|
self.env.unextend
|
1890
1877
|
}
|
1891
1878
|
|
1879
|
+
case_args: arg_value
|
1880
|
+
{
|
1881
|
+
arg, = val
|
1882
|
+
|
1883
|
+
result = s(:array, arg).line arg.line
|
1884
|
+
}
|
1885
|
+
| tSTAR arg_value
|
1886
|
+
{
|
1887
|
+
_, arg = val
|
1888
|
+
|
1889
|
+
result = s(:array, s(:splat, arg).line(arg.line)).line arg.line
|
1890
|
+
}
|
1891
|
+
| case_args tCOMMA arg_value
|
1892
|
+
{
|
1893
|
+
args, _, id = val
|
1894
|
+
|
1895
|
+
result = self.list_append args, id
|
1896
|
+
}
|
1897
|
+
| case_args tCOMMA tSTAR arg_value
|
1898
|
+
{
|
1899
|
+
args, _, _, id = val
|
1900
|
+
|
1901
|
+
result = self.list_append args, s(:splat, id).line(id.line)
|
1902
|
+
}
|
1903
|
+
|
1892
1904
|
case_body: k_when
|
1893
1905
|
{
|
1894
1906
|
result = self.lexer.lineno
|
1895
1907
|
}
|
1896
|
-
|
1908
|
+
case_args then compstmt cases
|
1897
1909
|
{
|
1898
1910
|
result = new_when(val[2], val[4])
|
1899
|
-
result.line
|
1911
|
+
result.line val[1]
|
1900
1912
|
result << val[5] if val[5]
|
1901
1913
|
}
|
1902
1914
|
|
@@ -1942,17 +1954,10 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1942
1954
|
|
1943
1955
|
literal: numeric
|
1944
1956
|
{
|
1945
|
-
line =
|
1946
|
-
result = s(:lit,
|
1947
|
-
result.line = line
|
1957
|
+
(lit, line), = val
|
1958
|
+
result = s(:lit, lit).line line
|
1948
1959
|
}
|
1949
1960
|
| symbol
|
1950
|
-
{
|
1951
|
-
line = lexer.lineno
|
1952
|
-
result = s(:lit, val[0])
|
1953
|
-
result.line = line
|
1954
|
-
}
|
1955
|
-
| dsym
|
1956
1961
|
|
1957
1962
|
strings: string
|
1958
1963
|
{
|
@@ -1963,7 +1968,7 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1963
1968
|
|
1964
1969
|
string: tCHAR
|
1965
1970
|
{
|
1966
|
-
|
1971
|
+
debug 37
|
1967
1972
|
}
|
1968
1973
|
| string1
|
1969
1974
|
| string string1
|
@@ -1973,11 +1978,11 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1973
1978
|
|
1974
1979
|
string1: tSTRING_BEG string_contents tSTRING_END
|
1975
1980
|
{
|
1976
|
-
_, str, (_, func) = val
|
1981
|
+
(_, line), str, (_, func) = val
|
1977
1982
|
|
1978
|
-
str = dedent str if func =~ RubyLexer::
|
1983
|
+
str = dedent str if func =~ RubyLexer::STR_FUNC_DEDENT
|
1979
1984
|
|
1980
|
-
result = str
|
1985
|
+
result = str.line line
|
1981
1986
|
}
|
1982
1987
|
| tSTRING
|
1983
1988
|
{
|
@@ -1997,11 +2002,15 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1997
2002
|
|
1998
2003
|
words: tWORDS_BEG tSPACE tSTRING_END
|
1999
2004
|
{
|
2000
|
-
|
2005
|
+
(_, line), _, _ = val
|
2006
|
+
|
2007
|
+
result = s(:array).line line
|
2001
2008
|
}
|
2002
2009
|
| tWORDS_BEG word_list tSTRING_END
|
2003
2010
|
{
|
2004
|
-
|
2011
|
+
(_, line), list, _ = val
|
2012
|
+
|
2013
|
+
result = list.line line
|
2005
2014
|
}
|
2006
2015
|
|
2007
2016
|
word_list: none
|
@@ -2021,18 +2030,20 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
2021
2030
|
|
2022
2031
|
symbols: tSYMBOLS_BEG tSPACE tSTRING_END
|
2023
2032
|
{
|
2024
|
-
|
2033
|
+
(_, line), _, _ = val
|
2034
|
+
|
2035
|
+
result = s(:array).line line
|
2025
2036
|
}
|
2026
|
-
| tSYMBOLS_BEG
|
2037
|
+
| tSYMBOLS_BEG symbol_list tSTRING_END
|
2027
2038
|
{
|
2028
|
-
_, line, list, _, = val
|
2029
|
-
list.line
|
2039
|
+
(_, line), list, _, = val
|
2040
|
+
list.line line
|
2030
2041
|
result = list
|
2031
2042
|
}
|
2032
2043
|
|
2033
2044
|
symbol_list: none
|
2034
2045
|
{
|
2035
|
-
result = new_symbol_list
|
2046
|
+
result = new_symbol_list
|
2036
2047
|
}
|
2037
2048
|
| symbol_list word tSPACE
|
2038
2049
|
{
|
@@ -2042,20 +2053,28 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
2042
2053
|
|
2043
2054
|
qwords: tQWORDS_BEG tSPACE tSTRING_END
|
2044
2055
|
{
|
2045
|
-
|
2056
|
+
(_, line), _, _ = val
|
2057
|
+
|
2058
|
+
result = s(:array).line line
|
2046
2059
|
}
|
2047
2060
|
| tQWORDS_BEG qword_list tSTRING_END
|
2048
2061
|
{
|
2049
|
-
|
2062
|
+
(_, line), list, _ = val
|
2063
|
+
|
2064
|
+
result = list.line line
|
2050
2065
|
}
|
2051
2066
|
|
2052
2067
|
qsymbols: tQSYMBOLS_BEG tSPACE tSTRING_END
|
2053
2068
|
{
|
2054
|
-
|
2069
|
+
(_, line), _, _ = val
|
2070
|
+
|
2071
|
+
result = s(:array).line line
|
2055
2072
|
}
|
2056
2073
|
| tQSYMBOLS_BEG qsym_list tSTRING_END
|
2057
2074
|
{
|
2058
|
-
|
2075
|
+
(_, line), list, _ = val
|
2076
|
+
|
2077
|
+
result = list.line line
|
2059
2078
|
}
|
2060
2079
|
|
2061
2080
|
qword_list: none
|
@@ -2078,7 +2097,8 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
2078
2097
|
|
2079
2098
|
string_contents: none
|
2080
2099
|
{
|
2081
|
-
|
2100
|
+
line = prev_value_to_lineno _values.last
|
2101
|
+
result = s(:str, +"").line line
|
2082
2102
|
}
|
2083
2103
|
| string_contents string_content
|
2084
2104
|
{
|
@@ -2153,8 +2173,8 @@ regexp_contents: none
|
|
2153
2173
|
lexer.brace_nest = brace_nest
|
2154
2174
|
lexer.string_nest = string_nest
|
2155
2175
|
|
2156
|
-
lexer.cmdarg.pop
|
2157
2176
|
lexer.cond.pop
|
2177
|
+
lexer.cmdarg.pop
|
2158
2178
|
|
2159
2179
|
lexer.lex_state = oldlex_state
|
2160
2180
|
|
@@ -2169,29 +2189,49 @@ regexp_contents: none
|
|
2169
2189
|
when nil then
|
2170
2190
|
result = s(:evstr).line line
|
2171
2191
|
else
|
2172
|
-
|
2192
|
+
debug 38
|
2173
2193
|
raise "unknown string body: #{stmt.inspect}"
|
2174
2194
|
end
|
2175
2195
|
}
|
2176
2196
|
|
2177
|
-
string_dvar: tGVAR
|
2178
|
-
|
2179
|
-
|
2197
|
+
string_dvar: tGVAR
|
2198
|
+
{
|
2199
|
+
(id, line), = val
|
2200
|
+
result = s(:gvar, id.to_sym).line line
|
2201
|
+
}
|
2202
|
+
| tIVAR
|
2203
|
+
{
|
2204
|
+
(id, line), = val
|
2205
|
+
result = s(:ivar, id.to_sym).line line
|
2206
|
+
}
|
2207
|
+
| tCVAR
|
2208
|
+
{
|
2209
|
+
(id, line), = val
|
2210
|
+
result = s(:cvar, id.to_sym).line line
|
2211
|
+
}
|
2180
2212
|
| backref
|
2181
2213
|
|
2182
|
-
symbol:
|
2214
|
+
symbol: ssym
|
2215
|
+
| dsym
|
2216
|
+
|
2217
|
+
ssym: tSYMBEG sym
|
2183
2218
|
{
|
2219
|
+
_, (id, line) = val
|
2220
|
+
|
2184
2221
|
lexer.lex_state = EXPR_END
|
2185
|
-
result =
|
2222
|
+
result = s(:lit, id.to_sym).line line
|
2186
2223
|
}
|
2187
2224
|
| tSYMBOL
|
2188
2225
|
{
|
2189
|
-
|
2226
|
+
(id, line), = val
|
2227
|
+
|
2228
|
+
lexer.lex_state = EXPR_END
|
2229
|
+
result = s(:lit, id.to_sym).line line
|
2190
2230
|
}
|
2191
2231
|
|
2192
2232
|
sym: fname | tIVAR | tGVAR | tCVAR
|
2193
2233
|
|
2194
|
-
dsym: tSYMBEG
|
2234
|
+
dsym: tSYMBEG string_contents tSTRING_END
|
2195
2235
|
{
|
2196
2236
|
_, result, _ = val
|
2197
2237
|
|
@@ -2207,14 +2247,15 @@ regexp_contents: none
|
|
2207
2247
|
when :evstr then
|
2208
2248
|
result = s(:dsym, "", result).line result.line
|
2209
2249
|
else
|
2210
|
-
|
2250
|
+
debug 39
|
2211
2251
|
end
|
2212
2252
|
}
|
2213
2253
|
|
2214
2254
|
numeric: simple_numeric
|
2215
|
-
| tUMINUS_NUM simple_numeric
|
2255
|
+
| tUMINUS_NUM simple_numeric =tLOWEST
|
2216
2256
|
{
|
2217
|
-
|
2257
|
+
_, (num, line) = val
|
2258
|
+
result = [-num, line]
|
2218
2259
|
}
|
2219
2260
|
|
2220
2261
|
simple_numeric: tINTEGER
|
@@ -2247,8 +2288,10 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2247
2288
|
|
2248
2289
|
var_ref: user_variable
|
2249
2290
|
{
|
2250
|
-
|
2291
|
+
raise "NO: #{val.inspect}" if Sexp === val.first
|
2292
|
+
(var, line), = val
|
2251
2293
|
result = Sexp === var ? var : self.gettable(var)
|
2294
|
+
result.line line
|
2252
2295
|
}
|
2253
2296
|
| keyword_variable
|
2254
2297
|
{
|
@@ -2263,11 +2306,19 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2263
2306
|
| keyword_variable
|
2264
2307
|
{
|
2265
2308
|
result = self.assignable val[0]
|
2266
|
-
|
2309
|
+
debug 40
|
2267
2310
|
}
|
2268
2311
|
|
2269
|
-
backref: tNTH_REF
|
2270
|
-
|
2312
|
+
backref: tNTH_REF
|
2313
|
+
{
|
2314
|
+
(ref, line), = val
|
2315
|
+
result = s(:nth_ref, ref).line line
|
2316
|
+
}
|
2317
|
+
| tBACK_REF
|
2318
|
+
{
|
2319
|
+
(ref, line), = val
|
2320
|
+
result = s(:back_ref, ref).line line
|
2321
|
+
}
|
2271
2322
|
|
2272
2323
|
superclass: tLT
|
2273
2324
|
{
|
@@ -2285,9 +2336,7 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2285
2336
|
|
2286
2337
|
f_arglist: tLPAREN2 f_args rparen
|
2287
2338
|
{
|
2288
|
-
result = val
|
2289
|
-
self.lexer.lex_state = EXPR_BEG
|
2290
|
-
self.lexer.command_start = true
|
2339
|
+
result = end_args val
|
2291
2340
|
}
|
2292
2341
|
| {
|
2293
2342
|
result = self.in_kwarg
|
@@ -2296,12 +2345,7 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2296
2345
|
}
|
2297
2346
|
f_args term
|
2298
2347
|
{
|
2299
|
-
|
2300
|
-
|
2301
|
-
self.in_kwarg = kwarg
|
2302
|
-
result = args
|
2303
|
-
lexer.lex_state = EXPR_BEG
|
2304
|
-
lexer.command_start = true
|
2348
|
+
result = end_args val
|
2305
2349
|
}
|
2306
2350
|
|
2307
2351
|
args_tail: f_kwarg tCOMMA f_kwrest opt_f_block_arg
|
@@ -2386,8 +2430,10 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2386
2430
|
|
|
2387
2431
|
{
|
2388
2432
|
result = args val
|
2433
|
+
# result.line lexer.lineno
|
2389
2434
|
}
|
2390
2435
|
|
2436
|
+
|
2391
2437
|
f_bad_arg: tCONSTANT
|
2392
2438
|
{
|
2393
2439
|
yyerror "formal argument cannot be a constant"
|
@@ -2408,10 +2454,11 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2408
2454
|
f_norm_arg: f_bad_arg
|
2409
2455
|
| tIDENTIFIER
|
2410
2456
|
{
|
2411
|
-
|
2457
|
+
(id, line), = val
|
2458
|
+
identifier = id.to_sym
|
2412
2459
|
self.env[identifier] = :lvar
|
2413
2460
|
|
2414
|
-
result = identifier
|
2461
|
+
result = [identifier, line]
|
2415
2462
|
}
|
2416
2463
|
|
2417
2464
|
f_arg_asgn: f_norm_arg
|
@@ -2419,22 +2466,14 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2419
2466
|
f_arg_item: f_arg_asgn
|
2420
2467
|
| tLPAREN f_margs rparen
|
2421
2468
|
{
|
2422
|
-
|
2469
|
+
_, margs, _ = val
|
2470
|
+
|
2471
|
+
result = margs
|
2423
2472
|
}
|
2424
2473
|
|
2425
2474
|
f_arg: f_arg_item
|
2426
2475
|
{
|
2427
|
-
|
2428
|
-
|
2429
|
-
case arg
|
2430
|
-
when Symbol then
|
2431
|
-
result = s(:args, arg).line lexer.lineno
|
2432
|
-
when Sexp then
|
2433
|
-
result = arg
|
2434
|
-
else
|
2435
|
-
debug20 32
|
2436
|
-
raise "Unknown f_arg type: #{val.inspect}"
|
2437
|
-
end
|
2476
|
+
result = new_arg val
|
2438
2477
|
}
|
2439
2478
|
| f_arg tCOMMA f_arg_item
|
2440
2479
|
{
|
@@ -2446,7 +2485,7 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2446
2485
|
result = s(:args, list).line list.line
|
2447
2486
|
end
|
2448
2487
|
|
2449
|
-
result << item
|
2488
|
+
result << (Sexp === item ? item : item.first)
|
2450
2489
|
}
|
2451
2490
|
|
2452
2491
|
f_label: tLABEL
|
@@ -2507,26 +2546,33 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2507
2546
|
kwrest_mark: tPOW
|
2508
2547
|
| tDSTAR
|
2509
2548
|
|
2549
|
+
|
2510
2550
|
f_kwrest: kwrest_mark tIDENTIFIER
|
2511
2551
|
{
|
2512
|
-
|
2513
|
-
|
2514
|
-
|
2552
|
+
_, (id, line) = val
|
2553
|
+
|
2554
|
+
name = id.to_sym
|
2555
|
+
self.assignable [name, line]
|
2556
|
+
result = [:"**#{name}", line]
|
2515
2557
|
}
|
2516
2558
|
| kwrest_mark
|
2517
2559
|
{
|
2518
|
-
|
2560
|
+
id = :"**"
|
2561
|
+
self.env[id] = :lvar # TODO: needed?!?
|
2562
|
+
result = [id, lexer.lineno] # TODO: tPOW/tDSTAR include lineno
|
2519
2563
|
}
|
2520
2564
|
|
2521
2565
|
f_opt: f_arg_asgn tEQL arg_value
|
2522
2566
|
{
|
2523
|
-
|
2567
|
+
lhs, _, rhs = val
|
2568
|
+
result = self.assignable lhs, rhs
|
2524
2569
|
# TODO: detect duplicate names
|
2525
2570
|
}
|
2526
2571
|
|
2527
2572
|
f_block_opt: f_arg_asgn tEQL primary_value
|
2528
2573
|
{
|
2529
|
-
|
2574
|
+
lhs, _, rhs = val
|
2575
|
+
result = self.assignable lhs, rhs
|
2530
2576
|
}
|
2531
2577
|
|
2532
2578
|
f_block_optarg: f_block_opt
|
@@ -2556,30 +2602,33 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2556
2602
|
f_rest_arg: restarg_mark tIDENTIFIER
|
2557
2603
|
{
|
2558
2604
|
# TODO: differs from parse.y - needs tests
|
2559
|
-
|
2560
|
-
|
2561
|
-
|
2605
|
+
_, (id, line) = val
|
2606
|
+
name = id.to_sym
|
2607
|
+
self.assignable [name, line]
|
2608
|
+
result = [:"*#{name}", line]
|
2562
2609
|
}
|
2563
2610
|
| restarg_mark
|
2564
2611
|
{
|
2565
2612
|
name = :"*"
|
2566
2613
|
self.env[name] = :lvar
|
2567
|
-
result = name
|
2614
|
+
result = [name, lexer.lineno] # FIX: tSTAR to include lineno
|
2568
2615
|
}
|
2569
2616
|
|
2570
2617
|
blkarg_mark: tAMPER2 | tAMPER
|
2571
2618
|
|
2572
2619
|
f_block_arg: blkarg_mark tIDENTIFIER
|
2573
2620
|
{
|
2574
|
-
|
2621
|
+
_, (id, line) = val
|
2622
|
+
identifier = id.to_sym
|
2575
2623
|
|
2576
2624
|
self.env[identifier] = :lvar
|
2577
|
-
result = "&#{identifier}".to_sym
|
2625
|
+
result = ["&#{identifier}".to_sym, line]
|
2578
2626
|
}
|
2579
2627
|
|
2580
2628
|
opt_f_block_arg: tCOMMA f_block_arg
|
2581
2629
|
{
|
2582
|
-
|
2630
|
+
_, arg = val
|
2631
|
+
result = arg
|
2583
2632
|
}
|
2584
2633
|
|
|
2585
2634
|
{
|
@@ -2628,9 +2677,11 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2628
2677
|
}
|
2629
2678
|
| tSTRING_BEG string_contents tLABEL_END arg_value
|
2630
2679
|
{
|
2631
|
-
_, sym, _, value = val
|
2680
|
+
(_, line), sym, _, value = val
|
2681
|
+
|
2632
2682
|
sym.sexp_type = :dsym
|
2633
|
-
|
2683
|
+
|
2684
|
+
result = s(:array, sym, value).line line
|
2634
2685
|
}
|
2635
2686
|
| tDSTAR arg_value
|
2636
2687
|
{
|