brakeman 5.0.4 → 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 +40 -1
- data/README.md +1 -1
- data/bundle/load.rb +5 -4
- 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.21.0/MIT-LICENSE.txt +20 -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.21.0/lib/parallel.rb +532 -0
- 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 +326 -249
- 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 +321 -246
- 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.16.0 → ruby_parser-3.18.0}/lib/ruby22_parser.y +325 -248
- 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/ruby24_parser.y → ruby_parser-3.18.0/lib/ruby23_parser.y} +326 -257
- 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/lib/ruby30_parser.y → ruby_parser-3.18.0/lib/ruby24_parser.y} +327 -302
- 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/ruby26_parser.y → ruby_parser-3.18.0/lib/ruby25_parser.y} +326 -264
- 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} +325 -285
- 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} +897 -377
- 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.18.0/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/check_detailed_exceptions.rb +1 -1
- data/lib/brakeman/checks/check_evaluation.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 +58 -8
- data/lib/brakeman/checks/check_verb_confusion.rb +1 -1
- data/lib/brakeman/file_parser.rb +45 -15
- data/lib/brakeman/options.rb +7 -2
- data/lib/brakeman/processors/alias_processor.rb +91 -9
- data/lib/brakeman/processors/controller_alias_processor.rb +6 -43
- data/lib/brakeman/processors/haml_template_processor.rb +9 -0
- data/lib/brakeman/processors/lib/call_conversion_helper.rb +12 -6
- data/lib/brakeman/processors/library_processor.rb +9 -0
- data/lib/brakeman/processors/model_processor.rb +32 -0
- data/lib/brakeman/report/ignore/config.rb +1 -1
- data/lib/brakeman/report/ignore/interactive.rb +1 -1
- data/lib/brakeman/report/report_csv.rb +1 -1
- data/lib/brakeman/report/report_github.rb +31 -0
- data/lib/brakeman/report/report_sarif.rb +22 -3
- data/lib/brakeman/report/report_text.rb +1 -1
- data/lib/brakeman/report.rb +4 -1
- data/lib/brakeman/rescanner.rb +1 -1
- data/lib/brakeman/scanner.rb +16 -13
- data/lib/brakeman/tracker/collection.rb +57 -7
- data/lib/brakeman/tracker/method_info.rb +70 -0
- data/lib/brakeman/tracker.rb +33 -4
- data/lib/brakeman/util.rb +34 -18
- data/lib/brakeman/version.rb +1 -1
- data/lib/brakeman.rb +8 -2
- data/lib/ruby_parser/bm_sexp.rb +24 -0
- metadata +103 -94
- 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
@@ -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
|
-
|
702
|
-
fsym: fname | symbol
|
703
715
|
|
704
|
-
fitem:
|
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
|
787
|
+
| tCOLON3 tCONSTANT tOP_ASGN arg_rhs
|
777
788
|
{
|
778
|
-
|
779
|
-
}
|
780
|
-
tOP_ASGN arg_rhs
|
781
|
-
{
|
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,26 +809,12 @@ 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
|
-
|
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
818
|
|
826
819
|
|
827
820
|
| arg tPLUS arg
|
@@ -850,8 +843,9 @@ rule
|
|
850
843
|
}
|
851
844
|
| tUMINUS_NUM simple_numeric tPOW arg
|
852
845
|
{
|
853
|
-
|
854
|
-
|
846
|
+
_, (num, line), _, arg = val
|
847
|
+
lit = s(:lit, num).line line
|
848
|
+
result = new_call(new_call(lit, :"**", argl(arg)), :"-@")
|
855
849
|
|
856
850
|
}
|
857
851
|
| tUPLUS arg
|
@@ -950,12 +944,12 @@ rule
|
|
950
944
|
|
951
945
|
rel_expr: arg relop arg =tGT
|
952
946
|
{
|
953
|
-
lhs, op, rhs = val
|
947
|
+
lhs, (op, _), rhs = val
|
954
948
|
result = new_call lhs, op.to_sym, argl(rhs)
|
955
949
|
}
|
956
950
|
| rel_expr relop arg =tGT
|
957
951
|
{
|
958
|
-
lhs, op, rhs = val
|
952
|
+
lhs, (op, _), rhs = val
|
959
953
|
warn "comparison '%s' after comparison", op
|
960
954
|
result = new_call lhs, op.to_sym, argl(rhs)
|
961
955
|
}
|
@@ -1146,8 +1140,9 @@ rule
|
|
1146
1140
|
| backref
|
1147
1141
|
| tFID
|
1148
1142
|
{
|
1149
|
-
msg, = val
|
1143
|
+
(msg, line), = val
|
1150
1144
|
result = new_call nil, msg.to_sym
|
1145
|
+
result.line line
|
1151
1146
|
}
|
1152
1147
|
| k_begin
|
1153
1148
|
{
|
@@ -1189,15 +1184,15 @@ rule
|
|
1189
1184
|
}
|
1190
1185
|
| primary_value tCOLON2 tCONSTANT
|
1191
1186
|
{
|
1192
|
-
expr, _, id = val
|
1187
|
+
expr, _, (id, _line) = val
|
1193
1188
|
|
1194
1189
|
result = s(:colon2, expr, id.to_sym).line expr.line
|
1195
1190
|
}
|
1196
1191
|
| tCOLON3 tCONSTANT
|
1197
1192
|
{
|
1198
|
-
_, id = val
|
1193
|
+
_, (id, line) = val
|
1199
1194
|
|
1200
|
-
result = s(:colon3, id.to_sym).line
|
1195
|
+
result = s(:colon3, id.to_sym).line line
|
1201
1196
|
}
|
1202
1197
|
| tLBRACK { result = lexer.lineno } aref_args tRBRACK
|
1203
1198
|
{
|
@@ -1244,7 +1239,7 @@ rule
|
|
1244
1239
|
}
|
1245
1240
|
| kNOT tLPAREN2 rparen
|
1246
1241
|
{
|
1247
|
-
|
1242
|
+
debug 20
|
1248
1243
|
}
|
1249
1244
|
| fcall brace_block
|
1250
1245
|
{
|
@@ -1262,9 +1257,10 @@ rule
|
|
1262
1257
|
iter.insert 1, call # FIX
|
1263
1258
|
result = iter
|
1264
1259
|
}
|
1265
|
-
|
|
1260
|
+
| lambda
|
1266
1261
|
{
|
1267
|
-
|
1262
|
+
expr, = val
|
1263
|
+
result = expr
|
1268
1264
|
}
|
1269
1265
|
| k_if expr_value then compstmt if_tail k_end
|
1270
1266
|
{
|
@@ -1307,7 +1303,6 @@ rule
|
|
1307
1303
|
}
|
1308
1304
|
cpath superclass
|
1309
1305
|
{
|
1310
|
-
self.comments.push self.lexer.comments
|
1311
1306
|
if (self.in_def || self.in_single > 0) then
|
1312
1307
|
yyerror "class definition in method body"
|
1313
1308
|
end
|
@@ -1317,7 +1312,7 @@ rule
|
|
1317
1312
|
{
|
1318
1313
|
result = new_class val
|
1319
1314
|
self.env.unextend
|
1320
|
-
self.lexer.
|
1315
|
+
self.lexer.ignore_body_comments
|
1321
1316
|
}
|
1322
1317
|
| k_class tLSHFT
|
1323
1318
|
{
|
@@ -1338,7 +1333,7 @@ rule
|
|
1338
1333
|
{
|
1339
1334
|
result = new_sclass val
|
1340
1335
|
self.env.unextend
|
1341
|
-
self.lexer.
|
1336
|
+
self.lexer.ignore_body_comments
|
1342
1337
|
}
|
1343
1338
|
| k_module
|
1344
1339
|
{
|
@@ -1346,7 +1341,6 @@ rule
|
|
1346
1341
|
}
|
1347
1342
|
cpath
|
1348
1343
|
{
|
1349
|
-
self.comments.push self.lexer.comments
|
1350
1344
|
yyerror "module definition in method body" if
|
1351
1345
|
self.in_def or self.in_single > 0
|
1352
1346
|
|
@@ -1356,7 +1350,7 @@ rule
|
|
1356
1350
|
{
|
1357
1351
|
result = new_module val
|
1358
1352
|
self.env.unextend
|
1359
|
-
self.lexer.
|
1353
|
+
self.lexer.ignore_body_comments
|
1360
1354
|
}
|
1361
1355
|
| k_def fname
|
1362
1356
|
{
|
@@ -1366,21 +1360,17 @@ rule
|
|
1366
1360
|
self.env.extend
|
1367
1361
|
lexer.cmdarg.push false
|
1368
1362
|
lexer.cond.push false
|
1369
|
-
|
1370
|
-
self.comments.push self.lexer.comments
|
1371
1363
|
}
|
1372
|
-
f_arglist bodystmt
|
1364
|
+
f_arglist bodystmt k_end
|
1373
1365
|
{
|
1374
|
-
in_def = val
|
1375
|
-
|
1376
|
-
result = new_defn val
|
1366
|
+
result, in_def = new_defn val
|
1377
1367
|
|
1378
1368
|
lexer.cond.pop # group = local_pop
|
1379
1369
|
lexer.cmdarg.pop
|
1380
1370
|
self.env.unextend
|
1381
1371
|
self.in_def = in_def
|
1382
1372
|
|
1383
|
-
self.lexer.
|
1373
|
+
self.lexer.ignore_body_comments
|
1384
1374
|
}
|
1385
1375
|
| k_def singleton dot_or_colon
|
1386
1376
|
{
|
@@ -1388,7 +1378,7 @@ rule
|
|
1388
1378
|
}
|
1389
1379
|
fname
|
1390
1380
|
{
|
1391
|
-
result =
|
1381
|
+
result = self.in_def
|
1392
1382
|
|
1393
1383
|
self.in_single += 1 # TODO: remove?
|
1394
1384
|
|
@@ -1398,13 +1388,18 @@ rule
|
|
1398
1388
|
lexer.cond.push false
|
1399
1389
|
|
1400
1390
|
lexer.lex_state = EXPR_ENDFN|EXPR_LABEL
|
1401
|
-
self.comments.push self.lexer.comments
|
1402
1391
|
}
|
1403
1392
|
f_arglist bodystmt k_end
|
1404
1393
|
{
|
1405
|
-
_, _recv, _, _, _name, (in_def, _lineno), _args, _body, _ = val
|
1406
1394
|
|
1407
|
-
|
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
|
1408
1403
|
|
1409
1404
|
lexer.cond.pop # group = local_pop
|
1410
1405
|
lexer.cmdarg.pop
|
@@ -1415,7 +1410,7 @@ rule
|
|
1415
1410
|
|
1416
1411
|
# TODO: restore cur_arg ? what's cur_arg?
|
1417
1412
|
|
1418
|
-
self.lexer.
|
1413
|
+
self.lexer.ignore_body_comments
|
1419
1414
|
}
|
1420
1415
|
| kBREAK
|
1421
1416
|
{
|
@@ -1452,8 +1447,17 @@ rule
|
|
1452
1447
|
k_case: kCASE
|
1453
1448
|
k_for: kFOR
|
1454
1449
|
k_class: kCLASS
|
1450
|
+
{
|
1451
|
+
self.comments.push self.lexer.comments
|
1452
|
+
}
|
1455
1453
|
k_module: kMODULE
|
1454
|
+
{
|
1455
|
+
self.comments.push self.lexer.comments
|
1456
|
+
}
|
1456
1457
|
k_def: kDEF
|
1458
|
+
{
|
1459
|
+
self.comments.push self.lexer.comments
|
1460
|
+
}
|
1457
1461
|
k_do: kDO
|
1458
1462
|
k_do_block: kDO_BLOCK
|
1459
1463
|
k_rescue: kRESCUE
|
@@ -1514,51 +1518,42 @@ rule
|
|
1514
1518
|
|
1515
1519
|
result = block_var args
|
1516
1520
|
}
|
1517
|
-
| f_marg_list tCOMMA
|
1521
|
+
| f_marg_list tCOMMA f_rest_marg
|
1518
1522
|
{
|
1519
|
-
args, _,
|
1523
|
+
args, _, rest = val
|
1520
1524
|
|
1521
|
-
result = block_var args,
|
1525
|
+
result = block_var args, rest
|
1522
1526
|
}
|
1523
|
-
| f_marg_list tCOMMA
|
1527
|
+
| f_marg_list tCOMMA f_rest_marg tCOMMA f_marg_list
|
1524
1528
|
{
|
1525
|
-
|
1529
|
+
lhs, _, splat, _, rhs = val
|
1526
1530
|
|
1527
|
-
result = block_var
|
1531
|
+
result = block_var lhs, splat, rhs
|
1528
1532
|
}
|
1529
|
-
|
|
1533
|
+
| f_rest_marg
|
1530
1534
|
{
|
1531
|
-
|
1535
|
+
rest, = val
|
1532
1536
|
|
1533
|
-
result = block_var
|
1537
|
+
result = block_var rest
|
1534
1538
|
}
|
1535
|
-
|
|
1539
|
+
| f_rest_marg tCOMMA f_marg_list
|
1536
1540
|
{
|
1537
|
-
|
1541
|
+
splat, _, rest = val
|
1538
1542
|
|
1539
|
-
result = block_var
|
1543
|
+
result = block_var splat, rest
|
1540
1544
|
}
|
1541
|
-
| tSTAR f_norm_arg
|
1542
|
-
{
|
1543
|
-
_, splat = val
|
1544
1545
|
|
1545
|
-
|
1546
|
-
}
|
1547
|
-
| tSTAR f_norm_arg tCOMMA f_marg_list
|
1546
|
+
f_rest_marg: tSTAR f_norm_arg
|
1548
1547
|
{
|
1549
|
-
_,
|
1548
|
+
_, (id, line) = val
|
1550
1549
|
|
1551
|
-
result =
|
1550
|
+
result = args ["*#{id}".to_sym]
|
1551
|
+
result.line line
|
1552
1552
|
}
|
1553
1553
|
| tSTAR
|
1554
1554
|
{
|
1555
|
-
result =
|
1556
|
-
|
1557
|
-
| tSTAR tCOMMA f_marg_list
|
1558
|
-
{
|
1559
|
-
_, _, args = val
|
1560
|
-
|
1561
|
-
result = block_var :*, args
|
1555
|
+
result = args [:*]
|
1556
|
+
result.line lexer.lineno # FIX: tSTAR -> line
|
1562
1557
|
}
|
1563
1558
|
|
1564
1559
|
block_args_tail: f_block_kwarg tCOMMA f_kwrest opt_f_block_arg
|
@@ -1575,8 +1570,8 @@ rule
|
|
1575
1570
|
}
|
1576
1571
|
| f_block_arg
|
1577
1572
|
{
|
1578
|
-
line =
|
1579
|
-
result = call_args
|
1573
|
+
(id, line), = val
|
1574
|
+
result = call_args [id]
|
1580
1575
|
result.line line
|
1581
1576
|
}
|
1582
1577
|
|
@@ -1685,13 +1680,13 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1685
1680
|
|
1686
1681
|
bvar: tIDENTIFIER
|
1687
1682
|
{
|
1688
|
-
id, = val
|
1689
|
-
line = lexer.lineno
|
1683
|
+
(id, line), = val
|
1690
1684
|
result = s(:shadow, id.to_sym).line line
|
1691
1685
|
}
|
1692
1686
|
| f_bad_arg
|
1693
1687
|
|
1694
|
-
lambda:
|
1688
|
+
lambda: tLAMBDA
|
1689
|
+
{
|
1695
1690
|
self.env.extend :dynamic
|
1696
1691
|
result = [lexer.lineno, lexer.lpar_beg]
|
1697
1692
|
lexer.paren_nest += 1
|
@@ -1703,14 +1698,14 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1703
1698
|
}
|
1704
1699
|
lambda_body
|
1705
1700
|
{
|
1706
|
-
(line, lpar), args, _cmdarg, body = val
|
1701
|
+
_, (line, lpar), args, _cmdarg, body = val
|
1707
1702
|
lexer.lpar_beg = lpar
|
1708
1703
|
|
1709
1704
|
lexer.cmdarg.pop
|
1710
1705
|
|
1711
1706
|
call = s(:lambda).line line
|
1712
1707
|
result = new_iter call, args, body
|
1713
|
-
result.line
|
1708
|
+
result.line line
|
1714
1709
|
self.env.unextend # TODO: dynapush & dynapop
|
1715
1710
|
}
|
1716
1711
|
|
@@ -1745,23 +1740,28 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1745
1740
|
## if (nd_type($1) == NODE_YIELD) {
|
1746
1741
|
## compile_error(PARSER_ARG "block given to yield");
|
1747
1742
|
|
1748
|
-
|
1749
|
-
val[0].block_pass?
|
1743
|
+
cmd, blk = val
|
1750
1744
|
|
1751
|
-
|
1745
|
+
syntax_error "Both block arg and actual block given." if
|
1746
|
+
cmd.block_pass?
|
1752
1747
|
|
1753
|
-
|
1748
|
+
if inverted? val then
|
1749
|
+
val = invert_block_call val
|
1750
|
+
cmd, blk = val
|
1751
|
+
end
|
1754
1752
|
|
1755
1753
|
result = blk
|
1756
1754
|
result.insert 1, cmd
|
1757
1755
|
}
|
1758
1756
|
| block_call call_op2 operation2 opt_paren_args
|
1759
1757
|
{
|
1760
|
-
|
1758
|
+
lhs, _, (id, _line), args = val
|
1759
|
+
|
1760
|
+
result = new_call lhs, id.to_sym, args
|
1761
1761
|
}
|
1762
1762
|
| block_call call_op2 operation2 opt_paren_args brace_block
|
1763
1763
|
{
|
1764
|
-
iter1, _, name, args, iter2 = val
|
1764
|
+
iter1, _, (name, _line), args, iter2 = val
|
1765
1765
|
|
1766
1766
|
call = new_call iter1, name.to_sym, args
|
1767
1767
|
iter2.insert 1, call
|
@@ -1770,7 +1770,7 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1770
1770
|
}
|
1771
1771
|
| block_call call_op2 operation2 command_args do_block
|
1772
1772
|
{
|
1773
|
-
iter1, _, name, args, iter2 = val
|
1773
|
+
iter1, _, (name, _line), args, iter2 = val
|
1774
1774
|
|
1775
1775
|
call = new_call iter1, name.to_sym, args
|
1776
1776
|
iter2.insert 1, call
|
@@ -1778,28 +1778,29 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1778
1778
|
result = iter2
|
1779
1779
|
}
|
1780
1780
|
|
1781
|
-
method_call: fcall
|
1781
|
+
method_call: fcall paren_args
|
1782
1782
|
{
|
1783
|
-
|
1784
|
-
}
|
1785
|
-
paren_args
|
1786
|
-
{
|
1787
|
-
call, lineno, args = val
|
1783
|
+
call, args = val
|
1788
1784
|
|
1789
1785
|
result = call.concat args.sexp_body if args
|
1790
|
-
result.line lineno
|
1791
1786
|
}
|
1792
1787
|
| primary_value call_op operation2 opt_paren_args
|
1793
1788
|
{
|
1794
|
-
|
1789
|
+
recv, call_op, (op, _line), args = val
|
1790
|
+
|
1791
|
+
result = new_call recv, op.to_sym, args, call_op
|
1795
1792
|
}
|
1796
1793
|
| primary_value tCOLON2 operation2 paren_args
|
1797
1794
|
{
|
1798
|
-
|
1795
|
+
recv, _, (op, _line), args = val
|
1796
|
+
|
1797
|
+
result = new_call recv, op.to_sym, args
|
1799
1798
|
}
|
1800
1799
|
| primary_value tCOLON2 operation3
|
1801
1800
|
{
|
1802
|
-
|
1801
|
+
lhs, _, (id, _line) = val
|
1802
|
+
|
1803
|
+
result = new_call lhs, id.to_sym
|
1803
1804
|
}
|
1804
1805
|
| primary_value call_op paren_args
|
1805
1806
|
{
|
@@ -1832,7 +1833,7 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1832
1833
|
_, line, body, _ = val
|
1833
1834
|
|
1834
1835
|
result = body
|
1835
|
-
result.line
|
1836
|
+
result.line line
|
1836
1837
|
|
1837
1838
|
self.env.unextend
|
1838
1839
|
}
|
@@ -1846,7 +1847,7 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1846
1847
|
_, line, body, _ = val
|
1847
1848
|
|
1848
1849
|
result = body
|
1849
|
-
result.line
|
1850
|
+
result.line line
|
1850
1851
|
|
1851
1852
|
self.env.unextend
|
1852
1853
|
}
|
@@ -1875,14 +1876,39 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1875
1876
|
self.env.unextend
|
1876
1877
|
}
|
1877
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
|
+
|
1878
1904
|
case_body: k_when
|
1879
1905
|
{
|
1880
1906
|
result = self.lexer.lineno
|
1881
1907
|
}
|
1882
|
-
|
1908
|
+
case_args then compstmt cases
|
1883
1909
|
{
|
1884
1910
|
result = new_when(val[2], val[4])
|
1885
|
-
result.line
|
1911
|
+
result.line val[1]
|
1886
1912
|
result << val[5] if val[5]
|
1887
1913
|
}
|
1888
1914
|
|
@@ -1928,17 +1954,10 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1928
1954
|
|
1929
1955
|
literal: numeric
|
1930
1956
|
{
|
1931
|
-
line =
|
1932
|
-
result = s(:lit,
|
1933
|
-
result.line = line
|
1957
|
+
(lit, line), = val
|
1958
|
+
result = s(:lit, lit).line line
|
1934
1959
|
}
|
1935
1960
|
| symbol
|
1936
|
-
{
|
1937
|
-
line = lexer.lineno
|
1938
|
-
result = s(:lit, val[0])
|
1939
|
-
result.line = line
|
1940
|
-
}
|
1941
|
-
| dsym
|
1942
1961
|
|
1943
1962
|
strings: string
|
1944
1963
|
{
|
@@ -1949,7 +1968,7 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1949
1968
|
|
1950
1969
|
string: tCHAR
|
1951
1970
|
{
|
1952
|
-
|
1971
|
+
debug 37
|
1953
1972
|
}
|
1954
1973
|
| string1
|
1955
1974
|
| string string1
|
@@ -1959,11 +1978,11 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1959
1978
|
|
1960
1979
|
string1: tSTRING_BEG string_contents tSTRING_END
|
1961
1980
|
{
|
1962
|
-
_, str, (_, func) = val
|
1981
|
+
(_, line), str, (_, func) = val
|
1963
1982
|
|
1964
|
-
str = dedent str if func =~ RubyLexer::
|
1983
|
+
str = dedent str if func =~ RubyLexer::STR_FUNC_DEDENT
|
1965
1984
|
|
1966
|
-
result = str
|
1985
|
+
result = str.line line
|
1967
1986
|
}
|
1968
1987
|
| tSTRING
|
1969
1988
|
{
|
@@ -1983,11 +2002,15 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1983
2002
|
|
1984
2003
|
words: tWORDS_BEG tSPACE tSTRING_END
|
1985
2004
|
{
|
1986
|
-
|
2005
|
+
(_, line), _, _ = val
|
2006
|
+
|
2007
|
+
result = s(:array).line line
|
1987
2008
|
}
|
1988
2009
|
| tWORDS_BEG word_list tSTRING_END
|
1989
2010
|
{
|
1990
|
-
|
2011
|
+
(_, line), list, _ = val
|
2012
|
+
|
2013
|
+
result = list.line line
|
1991
2014
|
}
|
1992
2015
|
|
1993
2016
|
word_list: none
|
@@ -2007,18 +2030,20 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
2007
2030
|
|
2008
2031
|
symbols: tSYMBOLS_BEG tSPACE tSTRING_END
|
2009
2032
|
{
|
2010
|
-
|
2033
|
+
(_, line), _, _ = val
|
2034
|
+
|
2035
|
+
result = s(:array).line line
|
2011
2036
|
}
|
2012
|
-
| tSYMBOLS_BEG
|
2037
|
+
| tSYMBOLS_BEG symbol_list tSTRING_END
|
2013
2038
|
{
|
2014
|
-
_, line, list, _, = val
|
2015
|
-
list.line
|
2039
|
+
(_, line), list, _, = val
|
2040
|
+
list.line line
|
2016
2041
|
result = list
|
2017
2042
|
}
|
2018
2043
|
|
2019
2044
|
symbol_list: none
|
2020
2045
|
{
|
2021
|
-
result = new_symbol_list
|
2046
|
+
result = new_symbol_list
|
2022
2047
|
}
|
2023
2048
|
| symbol_list word tSPACE
|
2024
2049
|
{
|
@@ -2028,20 +2053,28 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
2028
2053
|
|
2029
2054
|
qwords: tQWORDS_BEG tSPACE tSTRING_END
|
2030
2055
|
{
|
2031
|
-
|
2056
|
+
(_, line), _, _ = val
|
2057
|
+
|
2058
|
+
result = s(:array).line line
|
2032
2059
|
}
|
2033
2060
|
| tQWORDS_BEG qword_list tSTRING_END
|
2034
2061
|
{
|
2035
|
-
|
2062
|
+
(_, line), list, _ = val
|
2063
|
+
|
2064
|
+
result = list.line line
|
2036
2065
|
}
|
2037
2066
|
|
2038
2067
|
qsymbols: tQSYMBOLS_BEG tSPACE tSTRING_END
|
2039
2068
|
{
|
2040
|
-
|
2069
|
+
(_, line), _, _ = val
|
2070
|
+
|
2071
|
+
result = s(:array).line line
|
2041
2072
|
}
|
2042
2073
|
| tQSYMBOLS_BEG qsym_list tSTRING_END
|
2043
2074
|
{
|
2044
|
-
|
2075
|
+
(_, line), list, _ = val
|
2076
|
+
|
2077
|
+
result = list.line line
|
2045
2078
|
}
|
2046
2079
|
|
2047
2080
|
qword_list: none
|
@@ -2064,7 +2097,8 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
2064
2097
|
|
2065
2098
|
string_contents: none
|
2066
2099
|
{
|
2067
|
-
|
2100
|
+
line = prev_value_to_lineno _values.last
|
2101
|
+
result = s(:str, +"").line line
|
2068
2102
|
}
|
2069
2103
|
| string_contents string_content
|
2070
2104
|
{
|
@@ -2139,8 +2173,8 @@ regexp_contents: none
|
|
2139
2173
|
lexer.brace_nest = brace_nest
|
2140
2174
|
lexer.string_nest = string_nest
|
2141
2175
|
|
2142
|
-
lexer.cmdarg.pop
|
2143
2176
|
lexer.cond.pop
|
2177
|
+
lexer.cmdarg.pop
|
2144
2178
|
|
2145
2179
|
lexer.lex_state = oldlex_state
|
2146
2180
|
|
@@ -2155,29 +2189,49 @@ regexp_contents: none
|
|
2155
2189
|
when nil then
|
2156
2190
|
result = s(:evstr).line line
|
2157
2191
|
else
|
2158
|
-
|
2192
|
+
debug 38
|
2159
2193
|
raise "unknown string body: #{stmt.inspect}"
|
2160
2194
|
end
|
2161
2195
|
}
|
2162
2196
|
|
2163
|
-
string_dvar: tGVAR
|
2164
|
-
|
2165
|
-
|
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
|
+
}
|
2166
2212
|
| backref
|
2167
2213
|
|
2168
|
-
symbol:
|
2214
|
+
symbol: ssym
|
2215
|
+
| dsym
|
2216
|
+
|
2217
|
+
ssym: tSYMBEG sym
|
2169
2218
|
{
|
2219
|
+
_, (id, line) = val
|
2220
|
+
|
2170
2221
|
lexer.lex_state = EXPR_END
|
2171
|
-
result =
|
2222
|
+
result = s(:lit, id.to_sym).line line
|
2172
2223
|
}
|
2173
2224
|
| tSYMBOL
|
2174
2225
|
{
|
2175
|
-
|
2226
|
+
(id, line), = val
|
2227
|
+
|
2228
|
+
lexer.lex_state = EXPR_END
|
2229
|
+
result = s(:lit, id.to_sym).line line
|
2176
2230
|
}
|
2177
2231
|
|
2178
2232
|
sym: fname | tIVAR | tGVAR | tCVAR
|
2179
2233
|
|
2180
|
-
dsym: tSYMBEG
|
2234
|
+
dsym: tSYMBEG string_contents tSTRING_END
|
2181
2235
|
{
|
2182
2236
|
_, result, _ = val
|
2183
2237
|
|
@@ -2193,14 +2247,15 @@ regexp_contents: none
|
|
2193
2247
|
when :evstr then
|
2194
2248
|
result = s(:dsym, "", result).line result.line
|
2195
2249
|
else
|
2196
|
-
|
2250
|
+
debug 39
|
2197
2251
|
end
|
2198
2252
|
}
|
2199
2253
|
|
2200
2254
|
numeric: simple_numeric
|
2201
|
-
| tUMINUS_NUM simple_numeric
|
2255
|
+
| tUMINUS_NUM simple_numeric =tLOWEST
|
2202
2256
|
{
|
2203
|
-
|
2257
|
+
_, (num, line) = val
|
2258
|
+
result = [-num, line]
|
2204
2259
|
}
|
2205
2260
|
|
2206
2261
|
simple_numeric: tINTEGER
|
@@ -2233,8 +2288,10 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2233
2288
|
|
2234
2289
|
var_ref: user_variable
|
2235
2290
|
{
|
2236
|
-
|
2291
|
+
raise "NO: #{val.inspect}" if Sexp === val.first
|
2292
|
+
(var, line), = val
|
2237
2293
|
result = Sexp === var ? var : self.gettable(var)
|
2294
|
+
result.line line
|
2238
2295
|
}
|
2239
2296
|
| keyword_variable
|
2240
2297
|
{
|
@@ -2249,11 +2306,19 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2249
2306
|
| keyword_variable
|
2250
2307
|
{
|
2251
2308
|
result = self.assignable val[0]
|
2252
|
-
|
2309
|
+
debug 40
|
2253
2310
|
}
|
2254
2311
|
|
2255
|
-
backref: tNTH_REF
|
2256
|
-
|
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
|
+
}
|
2257
2322
|
|
2258
2323
|
superclass: tLT
|
2259
2324
|
{
|
@@ -2271,9 +2336,7 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2271
2336
|
|
2272
2337
|
f_arglist: tLPAREN2 f_args rparen
|
2273
2338
|
{
|
2274
|
-
result = val
|
2275
|
-
self.lexer.lex_state = EXPR_BEG
|
2276
|
-
self.lexer.command_start = true
|
2339
|
+
result = end_args val
|
2277
2340
|
}
|
2278
2341
|
| {
|
2279
2342
|
result = self.in_kwarg
|
@@ -2282,12 +2345,7 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2282
2345
|
}
|
2283
2346
|
f_args term
|
2284
2347
|
{
|
2285
|
-
|
2286
|
-
|
2287
|
-
self.in_kwarg = kwarg
|
2288
|
-
result = args
|
2289
|
-
lexer.lex_state = EXPR_BEG
|
2290
|
-
lexer.command_start = true
|
2348
|
+
result = end_args val
|
2291
2349
|
}
|
2292
2350
|
|
2293
2351
|
args_tail: f_kwarg tCOMMA f_kwrest opt_f_block_arg
|
@@ -2372,9 +2430,9 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2372
2430
|
|
|
2373
2431
|
{
|
2374
2432
|
result = args val
|
2433
|
+
# result.line lexer.lineno
|
2375
2434
|
}
|
2376
2435
|
|
2377
|
-
args_forward: tBDOT3
|
2378
2436
|
|
2379
2437
|
f_bad_arg: tCONSTANT
|
2380
2438
|
{
|
@@ -2396,10 +2454,11 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2396
2454
|
f_norm_arg: f_bad_arg
|
2397
2455
|
| tIDENTIFIER
|
2398
2456
|
{
|
2399
|
-
|
2457
|
+
(id, line), = val
|
2458
|
+
identifier = id.to_sym
|
2400
2459
|
self.env[identifier] = :lvar
|
2401
2460
|
|
2402
|
-
result = identifier
|
2461
|
+
result = [identifier, line]
|
2403
2462
|
}
|
2404
2463
|
|
2405
2464
|
f_arg_asgn: f_norm_arg
|
@@ -2407,22 +2466,14 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2407
2466
|
f_arg_item: f_arg_asgn
|
2408
2467
|
| tLPAREN f_margs rparen
|
2409
2468
|
{
|
2410
|
-
|
2469
|
+
_, margs, _ = val
|
2470
|
+
|
2471
|
+
result = margs
|
2411
2472
|
}
|
2412
2473
|
|
2413
2474
|
f_arg: f_arg_item
|
2414
2475
|
{
|
2415
|
-
|
2416
|
-
|
2417
|
-
case arg
|
2418
|
-
when Symbol then
|
2419
|
-
result = s(:args, arg).line lexer.lineno
|
2420
|
-
when Sexp then
|
2421
|
-
result = arg
|
2422
|
-
else
|
2423
|
-
debug20 32
|
2424
|
-
raise "Unknown f_arg type: #{val.inspect}"
|
2425
|
-
end
|
2476
|
+
result = new_arg val
|
2426
2477
|
}
|
2427
2478
|
| f_arg tCOMMA f_arg_item
|
2428
2479
|
{
|
@@ -2434,7 +2485,7 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2434
2485
|
result = s(:args, list).line list.line
|
2435
2486
|
end
|
2436
2487
|
|
2437
|
-
result << item
|
2488
|
+
result << (Sexp === item ? item : item.first)
|
2438
2489
|
}
|
2439
2490
|
|
2440
2491
|
f_label: tLABEL
|
@@ -2495,27 +2546,33 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2495
2546
|
kwrest_mark: tPOW
|
2496
2547
|
| tDSTAR
|
2497
2548
|
|
2549
|
+
|
2498
2550
|
f_kwrest: kwrest_mark tIDENTIFIER
|
2499
2551
|
{
|
2500
|
-
|
2501
|
-
|
2502
|
-
|
2552
|
+
_, (id, line) = val
|
2553
|
+
|
2554
|
+
name = id.to_sym
|
2555
|
+
self.assignable [name, line]
|
2556
|
+
result = [:"**#{name}", line]
|
2503
2557
|
}
|
2504
2558
|
| kwrest_mark
|
2505
2559
|
{
|
2506
|
-
|
2507
|
-
self.env[
|
2560
|
+
id = :"**"
|
2561
|
+
self.env[id] = :lvar # TODO: needed?!?
|
2562
|
+
result = [id, lexer.lineno] # TODO: tPOW/tDSTAR include lineno
|
2508
2563
|
}
|
2509
2564
|
|
2510
2565
|
f_opt: f_arg_asgn tEQL arg_value
|
2511
2566
|
{
|
2512
|
-
|
2567
|
+
lhs, _, rhs = val
|
2568
|
+
result = self.assignable lhs, rhs
|
2513
2569
|
# TODO: detect duplicate names
|
2514
2570
|
}
|
2515
2571
|
|
2516
2572
|
f_block_opt: f_arg_asgn tEQL primary_value
|
2517
2573
|
{
|
2518
|
-
|
2574
|
+
lhs, _, rhs = val
|
2575
|
+
result = self.assignable lhs, rhs
|
2519
2576
|
}
|
2520
2577
|
|
2521
2578
|
f_block_optarg: f_block_opt
|
@@ -2545,30 +2602,33 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2545
2602
|
f_rest_arg: restarg_mark tIDENTIFIER
|
2546
2603
|
{
|
2547
2604
|
# TODO: differs from parse.y - needs tests
|
2548
|
-
|
2549
|
-
|
2550
|
-
|
2605
|
+
_, (id, line) = val
|
2606
|
+
name = id.to_sym
|
2607
|
+
self.assignable [name, line]
|
2608
|
+
result = [:"*#{name}", line]
|
2551
2609
|
}
|
2552
2610
|
| restarg_mark
|
2553
2611
|
{
|
2554
2612
|
name = :"*"
|
2555
2613
|
self.env[name] = :lvar
|
2556
|
-
result = name
|
2614
|
+
result = [name, lexer.lineno] # FIX: tSTAR to include lineno
|
2557
2615
|
}
|
2558
2616
|
|
2559
2617
|
blkarg_mark: tAMPER2 | tAMPER
|
2560
2618
|
|
2561
2619
|
f_block_arg: blkarg_mark tIDENTIFIER
|
2562
2620
|
{
|
2563
|
-
|
2621
|
+
_, (id, line) = val
|
2622
|
+
identifier = id.to_sym
|
2564
2623
|
|
2565
2624
|
self.env[identifier] = :lvar
|
2566
|
-
result = "&#{identifier}".to_sym
|
2625
|
+
result = ["&#{identifier}".to_sym, line]
|
2567
2626
|
}
|
2568
2627
|
|
2569
2628
|
opt_f_block_arg: tCOMMA f_block_arg
|
2570
2629
|
{
|
2571
|
-
|
2630
|
+
_, arg = val
|
2631
|
+
result = arg
|
2572
2632
|
}
|
2573
2633
|
|
|
2574
2634
|
{
|
@@ -2617,9 +2677,11 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2617
2677
|
}
|
2618
2678
|
| tSTRING_BEG string_contents tLABEL_END arg_value
|
2619
2679
|
{
|
2620
|
-
_, sym, _, value = val
|
2680
|
+
(_, line), sym, _, value = val
|
2681
|
+
|
2621
2682
|
sym.sexp_type = :dsym
|
2622
|
-
|
2683
|
+
|
2684
|
+
result = s(:array, sym, value).line line
|
2623
2685
|
}
|
2624
2686
|
| tDSTAR arg_value
|
2625
2687
|
{
|