brakeman 5.1.1 → 5.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +22 -1
- data/README.md +1 -1
- data/bundle/load.rb +5 -5
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/CHANGELOG.md +8 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/FAQ.md +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/Gemfile +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/MIT-LICENSE +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/README.md +19 -13
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/REFERENCE.md +10 -3
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/TODO +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/haml.gemspec +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/attribute_builder.rb +55 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/attribute_compiler.rb +4 -2
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/attribute_parser.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/buffer.rb +0 -56
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/compiler.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/engine.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/error.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/escapable.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/exec.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/filters.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/generator.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers/action_view_extensions.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers/action_view_mods.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers/action_view_xss_mods.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers/safe_erubi_template.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers/safe_erubis_template.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers/xss_mods.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/options.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/parser.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/plugin.rb +18 -1
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/railtie.rb +5 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/sass_rails_filter.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/template/options.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/template.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/temple_engine.rb +2 -1
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/temple_line_counter.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/util.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/version.rb +1 -1
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/yard/default/fulldoc/html/css/common.sass +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/yard/default/layout/html/footer.erb +0 -0
- data/bundle/ruby/2.7.0/gems/{parallel-1.20.1 → parallel-1.21.0}/MIT-LICENSE.txt +0 -0
- data/bundle/ruby/2.7.0/gems/parallel-1.21.0/lib/parallel/processor_count.rb +45 -0
- data/bundle/ruby/2.7.0/gems/parallel-1.21.0/lib/parallel/version.rb +4 -0
- data/bundle/ruby/2.7.0/gems/{parallel-1.20.1 → parallel-1.21.0}/lib/parallel.rb +52 -43
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/History.rdoc +88 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/Manifest.txt +3 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/README.rdoc +1 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/compare/normalize.rb +6 -1
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/debugging.md +0 -0
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/gauntlet.md +106 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/rp_extensions.rb +15 -36
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/rp_stringscanner.rb +33 -0
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby20_parser.rb +7128 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby20_parser.y +335 -252
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby21_parser.rb +7182 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby21_parser.y +330 -249
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby22_parser.rb +7228 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby22_parser.y +334 -251
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby23_parser.rb +7237 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0/lib/ruby26_parser.y → ruby_parser-3.18.1/lib/ruby23_parser.y} +336 -276
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby24_parser.rb +7268 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby24_parser.y +334 -251
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby25_parser.rb +7268 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0/lib/ruby30_parser.y → ruby_parser-3.18.1/lib/ruby25_parser.y} +335 -304
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby26_parser.rb +7287 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0/lib/ruby27_parser.y → ruby_parser-3.18.1/lib/ruby26_parser.y} +334 -288
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby27_parser.rb +8517 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0/lib/ruby_parser.yy → ruby_parser-3.18.1/lib/ruby27_parser.y} +906 -380
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby30_parser.rb +8751 -0
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby30_parser.y +3472 -0
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby3_parser.yy +3476 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby_lexer.rb +261 -609
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby_lexer.rex +27 -20
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby_lexer.rex.rb +59 -23
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby_lexer_strings.rb +638 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby_parser.rb +0 -0
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby_parser.yy +3487 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby_parser_extras.rb +296 -115
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/tools/munge.rb +34 -6
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/tools/ripper.rb +44 -0
- data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/History.rdoc +15 -0
- data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/Manifest.txt +0 -0
- data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/README.rdoc +0 -0
- data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/composite_sexp_processor.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/pt_testcase.rb +7 -2
- data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/sexp.rb +19 -9
- data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/sexp_matcher.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/sexp_processor.rb +1 -1
- data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/strict_sexp.rb +25 -3
- data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/unique.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/CHANGELOG.md +4 -0
- data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/MIT-LICENSE.txt +0 -0
- data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/README.md +1 -1
- data/bundle/ruby/2.7.0/gems/unicode-display_width-1.8.0/data/display_width.marshal.gz +0 -0
- data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/lib/unicode/display_width/constants.rb +2 -2
- data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/lib/unicode/display_width/index.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/lib/unicode/display_width/no_string_ext.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/lib/unicode/display_width/string_ext.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/lib/unicode/display_width.rb +0 -0
- data/lib/brakeman/app_tree.rb +1 -1
- data/lib/brakeman/checks/base_check.rb +10 -0
- data/lib/brakeman/checks/check_eol_rails.rb +23 -0
- data/lib/brakeman/checks/check_eol_ruby.rb +26 -0
- data/lib/brakeman/checks/check_json_parsing.rb +1 -1
- data/lib/brakeman/checks/check_sql.rb +3 -2
- data/lib/brakeman/checks/check_symbol_dos.rb +1 -1
- data/lib/brakeman/checks/eol_check.rb +47 -0
- data/lib/brakeman/options.rb +8 -0
- data/lib/brakeman/processors/alias_processor.rb +7 -1
- data/lib/brakeman/processors/gem_processor.rb +3 -0
- data/lib/brakeman/processors/haml_template_processor.rb +9 -0
- data/lib/brakeman/processors/lib/call_conversion_helper.rb +2 -0
- data/lib/brakeman/processors/lib/rails3_route_processor.rb +2 -0
- data/lib/brakeman/processors/model_processor.rb +1 -0
- data/lib/brakeman/report/ignore/config.rb +1 -1
- data/lib/brakeman/report/report_csv.rb +1 -1
- data/lib/brakeman/report/report_sarif.rb +1 -1
- data/lib/brakeman/report/report_text.rb +1 -1
- data/lib/brakeman/scanner.rb +15 -13
- data/lib/brakeman/tracker/config.rb +8 -1
- data/lib/brakeman/version.rb +1 -1
- data/lib/brakeman/warning_codes.rb +4 -0
- data/lib/brakeman.rb +2 -2
- data/lib/ruby_parser/bm_sexp.rb +11 -1
- metadata +105 -99
- data/bundle/ruby/2.7.0/gems/parallel-1.20.1/lib/parallel/processor_count.rb +0 -42
- data/bundle/ruby/2.7.0/gems/parallel-1.20.1/lib/parallel/version.rb +0 -3
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/rp_stringscanner.rb +0 -64
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby20_parser.rb +0 -7075
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby21_parser.rb +0 -7148
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby22_parser.rb +0 -7185
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby23_parser.rb +0 -7199
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby23_parser.y +0 -2643
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby24_parser.rb +0 -7219
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby25_parser.rb +0 -7218
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby25_parser.y +0 -2651
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby26_parser.rb +0 -7240
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby27_parser.rb +0 -7358
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby30_parser.rb +0 -7358
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/tools/ripper.rb +0 -39
- data/bundle/ruby/2.7.0/gems/unicode-display_width-1.7.0/data/display_width.marshal.gz +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- racc -*-
|
2
2
|
|
3
|
-
class
|
3
|
+
class Ruby26Parser
|
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,7 +18,7 @@ token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
|
|
18
18
|
tBACK_REF2 tSYMBEG tSTRING_BEG tXSTRING_BEG tREGEXP_BEG
|
19
19
|
tWORDS_BEG tQWORDS_BEG tSTRING_DBEG tSTRING_DVAR tSTRING_END
|
20
20
|
tSTRING tSYMBOL tNL tEH tCOLON tCOMMA tSPACE tSEMI tLAMBDA
|
21
|
-
tLAMBEG tDSTAR tCHAR tSYMBOLS_BEG tQSYMBOLS_BEG tSTRING_DEND
|
21
|
+
tLAMBEG tDSTAR tCHAR tSYMBOLS_BEG tQSYMBOLS_BEG tSTRING_DEND
|
22
22
|
tRATIONAL tIMAGINARY
|
23
23
|
tLABEL_END
|
24
24
|
tLONELY
|
@@ -80,7 +80,7 @@ rule
|
|
80
80
|
| klBEGIN
|
81
81
|
{
|
82
82
|
if (self.in_def || self.in_single > 0) then
|
83
|
-
|
83
|
+
debug 11
|
84
84
|
yyerror "BEGIN in method"
|
85
85
|
end
|
86
86
|
self.env.extend
|
@@ -105,6 +105,8 @@ rule
|
|
105
105
|
bodystmt: compstmt opt_rescue k_else
|
106
106
|
{
|
107
107
|
res = _values[-2]
|
108
|
+
# TODO: move down to main match so I can just use val
|
109
|
+
|
108
110
|
yyerror "else without rescue is useless" unless res
|
109
111
|
}
|
110
112
|
compstmt
|
@@ -135,7 +137,7 @@ rule
|
|
135
137
|
| error stmt
|
136
138
|
{
|
137
139
|
result = val[1]
|
138
|
-
|
140
|
+
debug 12
|
139
141
|
}
|
140
142
|
|
141
143
|
stmt_or_begin: stmt
|
@@ -143,6 +145,10 @@ rule
|
|
143
145
|
{
|
144
146
|
yyerror "BEGIN is permitted only at toplevel"
|
145
147
|
}
|
148
|
+
begin_block
|
149
|
+
{
|
150
|
+
result = val[2] # wtf?
|
151
|
+
}
|
146
152
|
|
147
153
|
stmt: kALIAS fitem
|
148
154
|
{
|
@@ -155,12 +161,12 @@ rule
|
|
155
161
|
}
|
156
162
|
| kALIAS tGVAR tGVAR
|
157
163
|
{
|
158
|
-
(_, line), lhs, rhs = val
|
164
|
+
(_, line), (lhs, _), (rhs, _) = val
|
159
165
|
result = s(:valias, lhs.to_sym, rhs.to_sym).line line
|
160
166
|
}
|
161
167
|
| kALIAS tGVAR tBACK_REF
|
162
168
|
{
|
163
|
-
(_, line), lhs, rhs = val
|
169
|
+
(_, line), (lhs, _), (rhs, _) = val
|
164
170
|
result = s(:valias, lhs.to_sym, :"$#{rhs}").line line
|
165
171
|
}
|
166
172
|
| kALIAS tGVAR tNTH_REF
|
@@ -203,7 +209,7 @@ rule
|
|
203
209
|
(_, line), _, stmt, _ = val
|
204
210
|
|
205
211
|
if (self.in_def || self.in_single > 0) then
|
206
|
-
|
212
|
+
debug 13
|
207
213
|
yyerror "END in method; use at_exit"
|
208
214
|
end
|
209
215
|
|
@@ -243,32 +249,31 @@ rule
|
|
243
249
|
}
|
244
250
|
| primary_value call_op tIDENTIFIER tOP_ASGN command_rhs
|
245
251
|
{
|
246
|
-
prim, _, id,
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
result.line = val[0].line
|
252
|
+
prim, (call_op, _), (id, _), (op_asgn, _), rhs = val
|
253
|
+
|
254
|
+
result = s(:op_asgn, prim, rhs, id.to_sym, op_asgn.to_sym)
|
255
|
+
result.sexp_type = :safe_op_asgn if call_op == '&.'
|
256
|
+
result.line prim.line
|
252
257
|
}
|
253
258
|
| primary_value call_op tCONSTANT tOP_ASGN command_rhs
|
254
259
|
{
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
result.line
|
260
|
+
prim, (call_op, _), (id, _), (op_asgn, _), rhs = val
|
261
|
+
|
262
|
+
result = s(:op_asgn, prim, rhs, id.to_sym, op_asgn.to_sym)
|
263
|
+
result.sexp_type = :safe_op_asgn if call_op == '&.'
|
264
|
+
result.line prim.line
|
260
265
|
}
|
261
266
|
| primary_value tCOLON2 tCONSTANT tOP_ASGN command_rhs
|
262
267
|
{
|
263
|
-
lhs1, _, lhs2,
|
268
|
+
lhs1, _, (lhs2, line), (id, _), rhs = val
|
264
269
|
|
265
|
-
result = s(:op_asgn, lhs1, rhs, lhs2.to_sym,
|
270
|
+
result = s(:op_asgn, lhs1, rhs, lhs2.to_sym, id.to_sym).line line
|
266
271
|
}
|
267
272
|
| primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_rhs
|
268
273
|
{
|
269
|
-
lhs1, _, lhs2,
|
274
|
+
lhs1, _, (lhs2, line), (id, _), rhs = val
|
270
275
|
|
271
|
-
result = s(:op_asgn, lhs1, rhs, lhs2.to_sym,
|
276
|
+
result = s(:op_asgn, lhs1, rhs, lhs2.to_sym, id.to_sym).line line
|
272
277
|
}
|
273
278
|
| backref tOP_ASGN command_rhs
|
274
279
|
{
|
@@ -314,7 +319,7 @@ rule
|
|
314
319
|
# TODO: fix line number to tBANG... but causes BAD shift/reduce conflict
|
315
320
|
# REFACTOR: call_uni_op -- see parse26.y
|
316
321
|
}
|
317
|
-
| arg
|
322
|
+
| arg =tLBRACE_ARG
|
318
323
|
|
319
324
|
expr_value: expr
|
320
325
|
{
|
@@ -339,7 +344,7 @@ rule
|
|
339
344
|
block_command: block_call
|
340
345
|
| block_call call_op2 operation2 command_args
|
341
346
|
{
|
342
|
-
blk, _, msg, args = val
|
347
|
+
blk, _, (msg, _line), args = val
|
343
348
|
result = new_call(blk, msg.to_sym, args).line blk.line
|
344
349
|
}
|
345
350
|
|
@@ -353,15 +358,15 @@ rule
|
|
353
358
|
_, line, body, _ = val
|
354
359
|
|
355
360
|
result = body
|
356
|
-
result.line
|
361
|
+
result.line line
|
357
362
|
|
358
363
|
# self.env.unextend
|
359
364
|
}
|
360
365
|
|
361
366
|
fcall: operation
|
362
367
|
{
|
363
|
-
msg, = val
|
364
|
-
result = new_call(nil, msg.to_sym).line
|
368
|
+
(msg, line), = val
|
369
|
+
result = new_call(nil, msg.to_sym).line line
|
365
370
|
}
|
366
371
|
|
367
372
|
command: fcall command_args =tLOWEST
|
@@ -384,12 +389,14 @@ rule
|
|
384
389
|
}
|
385
390
|
| primary_value call_op operation2 command_args =tLOWEST
|
386
391
|
{
|
387
|
-
lhs, callop, op, args = val
|
392
|
+
lhs, callop, (op, _), args = val
|
393
|
+
|
388
394
|
result = new_call lhs, op.to_sym, args, callop
|
395
|
+
result.line lhs.line
|
389
396
|
}
|
390
397
|
| primary_value call_op operation2 command_args cmd_brace_block
|
391
398
|
{
|
392
|
-
recv, _, msg, args, block = val
|
399
|
+
recv, _, (msg, _line), args, block = val
|
393
400
|
call = new_call recv, msg.to_sym, args, val[1]
|
394
401
|
|
395
402
|
block_dup_check call, block
|
@@ -399,11 +406,14 @@ rule
|
|
399
406
|
}
|
400
407
|
| primary_value tCOLON2 operation2 command_args =tLOWEST
|
401
408
|
{
|
402
|
-
|
409
|
+
lhs, _, (id, line), args = val
|
410
|
+
|
411
|
+
result = new_call lhs, id.to_sym, args
|
412
|
+
result.line line
|
403
413
|
}
|
404
414
|
| primary_value tCOLON2 operation2 command_args cmd_brace_block
|
405
415
|
{
|
406
|
-
recv, _, msg, args, block = val
|
416
|
+
recv, _, (msg, _line), args, block = val
|
407
417
|
call = new_call recv, msg.to_sym, args
|
408
418
|
|
409
419
|
block_dup_check call, block
|
@@ -561,25 +571,29 @@ rule
|
|
561
571
|
}
|
562
572
|
| primary_value call_op tIDENTIFIER
|
563
573
|
{
|
564
|
-
|
574
|
+
lhs, call_op, (id, _line) = val
|
575
|
+
|
576
|
+
result = new_attrasgn lhs, id, call_op
|
565
577
|
}
|
566
578
|
| primary_value tCOLON2 tIDENTIFIER
|
567
579
|
{
|
568
|
-
recv, _, id = val
|
580
|
+
recv, _, (id, _line) = val
|
569
581
|
result = new_attrasgn recv, id
|
570
582
|
}
|
571
583
|
| primary_value call_op tCONSTANT
|
572
584
|
{
|
573
|
-
|
585
|
+
lhs, call_op, (id, _line) = val
|
586
|
+
|
587
|
+
result = new_attrasgn lhs, id, call_op
|
574
588
|
}
|
575
589
|
| primary_value tCOLON2 tCONSTANT
|
576
590
|
{
|
577
591
|
if (self.in_def || self.in_single > 0) then
|
578
|
-
|
592
|
+
debug 14
|
579
593
|
yyerror "dynamic constant assignment"
|
580
594
|
end
|
581
595
|
|
582
|
-
expr, _, id = val
|
596
|
+
expr, _, (id, _line) = val
|
583
597
|
l = expr.line
|
584
598
|
|
585
599
|
result = s(:const, s(:colon2, expr, id.to_sym).line(l), nil).line l
|
@@ -587,58 +601,65 @@ rule
|
|
587
601
|
| tCOLON3 tCONSTANT
|
588
602
|
{
|
589
603
|
if (self.in_def || self.in_single > 0) then
|
590
|
-
|
604
|
+
debug 15
|
591
605
|
yyerror "dynamic constant assignment"
|
592
606
|
end
|
593
607
|
|
594
|
-
_, id = val
|
595
|
-
l = lexer.lineno
|
608
|
+
_, (id, l) = val
|
596
609
|
|
597
610
|
result = s(:const, nil, s(:colon3, id.to_sym).line(l)).line l
|
598
611
|
}
|
599
612
|
| backref
|
600
613
|
{
|
601
|
-
|
614
|
+
ref, = val
|
615
|
+
|
616
|
+
self.backref_assign_error ref
|
602
617
|
}
|
603
618
|
|
604
619
|
lhs: user_variable
|
605
620
|
{
|
606
|
-
|
607
|
-
|
608
|
-
result
|
621
|
+
var, = val
|
622
|
+
|
623
|
+
result = self.assignable var
|
609
624
|
}
|
610
625
|
| keyword_variable
|
611
626
|
{
|
612
|
-
|
613
|
-
|
614
|
-
result
|
615
|
-
|
627
|
+
var, = val
|
628
|
+
|
629
|
+
result = self.assignable var
|
630
|
+
|
631
|
+
debug 16
|
616
632
|
}
|
617
633
|
| primary_value tLBRACK2 opt_call_args rbracket
|
618
634
|
{
|
619
635
|
lhs, _, args, _ = val
|
636
|
+
|
620
637
|
result = self.aryset lhs, args
|
621
638
|
}
|
622
639
|
| primary_value call_op tIDENTIFIER # REFACTOR
|
623
640
|
{
|
624
|
-
lhs, op, id = val
|
641
|
+
lhs, op, (id, _line) = val
|
642
|
+
|
625
643
|
result = new_attrasgn lhs, id, op
|
626
644
|
}
|
627
645
|
| primary_value tCOLON2 tIDENTIFIER
|
628
646
|
{
|
629
|
-
lhs, _, id = val
|
647
|
+
lhs, _, (id, _line) = val
|
648
|
+
|
630
649
|
result = new_attrasgn lhs, id
|
631
650
|
}
|
632
651
|
| primary_value call_op tCONSTANT # REFACTOR?
|
633
652
|
{
|
634
|
-
|
653
|
+
lhs, call_op, (id, _line) = val
|
654
|
+
|
655
|
+
result = new_attrasgn lhs, id, call_op
|
635
656
|
}
|
636
657
|
| primary_value tCOLON2 tCONSTANT
|
637
658
|
{
|
638
|
-
expr, _, id = val
|
659
|
+
expr, _, (id, _line) = val
|
639
660
|
|
640
661
|
if (self.in_def || self.in_single > 0) then
|
641
|
-
|
662
|
+
debug 17
|
642
663
|
yyerror "dynamic constant assignment"
|
643
664
|
end
|
644
665
|
|
@@ -647,14 +668,13 @@ rule
|
|
647
668
|
}
|
648
669
|
| tCOLON3 tCONSTANT
|
649
670
|
{
|
650
|
-
_, id = val
|
671
|
+
_, (id, l) = val
|
651
672
|
|
652
673
|
if (self.in_def || self.in_single > 0) then
|
653
|
-
|
674
|
+
debug 18
|
654
675
|
yyerror "dynamic constant assignment"
|
655
676
|
end
|
656
677
|
|
657
|
-
l = lexer.lineno
|
658
678
|
result = s(:const, s(:colon3, id.to_sym).line(l)).line l
|
659
679
|
}
|
660
680
|
| backref
|
@@ -670,16 +690,17 @@ rule
|
|
670
690
|
|
671
691
|
cpath: tCOLON3 cname
|
672
692
|
{
|
673
|
-
_, name = val
|
674
|
-
result = s(:colon3, name.to_sym).line
|
693
|
+
_, (name, line) = val
|
694
|
+
result = s(:colon3, name.to_sym).line line
|
675
695
|
}
|
676
696
|
| cname
|
677
697
|
{
|
678
|
-
|
698
|
+
(id, line), = val
|
699
|
+
result = [id.to_sym, line] # TODO: sexp?
|
679
700
|
}
|
680
701
|
| primary_value tCOLON2 cname
|
681
702
|
{
|
682
|
-
pval, _, name = val
|
703
|
+
pval, _, (name, _line) = val
|
683
704
|
|
684
705
|
result = s(:colon2, pval, name.to_sym)
|
685
706
|
result.line pval.line
|
@@ -689,24 +710,17 @@ rule
|
|
689
710
|
| op
|
690
711
|
{
|
691
712
|
lexer.lex_state = EXPR_END
|
692
|
-
result = val[0]
|
693
713
|
}
|
694
714
|
|
695
715
|
| reswords
|
696
|
-
{
|
697
|
-
(sym, _line), = val
|
698
|
-
lexer.lex_state = EXPR_END
|
699
|
-
result = sym
|
700
|
-
}
|
701
|
-
|
702
|
-
fsym: fname | symbol
|
703
716
|
|
704
|
-
fitem:
|
717
|
+
fitem: fname
|
705
718
|
{
|
706
|
-
id, = val
|
707
|
-
|
719
|
+
(id, line), = val
|
720
|
+
|
721
|
+
result = s(:lit, id.to_sym).line line
|
708
722
|
}
|
709
|
-
|
|
723
|
+
| symbol
|
710
724
|
|
711
725
|
undef_list: fitem
|
712
726
|
{
|
@@ -727,8 +741,6 @@ rule
|
|
727
741
|
| tNEQ | tLSHFT | tRSHFT | tPLUS | tMINUS | tSTAR2
|
728
742
|
| tSTAR | tDIVIDE | tPERCENT | tPOW | tDSTAR | tBANG | tTILDE
|
729
743
|
| tUPLUS | tUMINUS | tAREF | tASET | tBACK_REF2
|
730
|
-
# TODO: tUBANG dead?
|
731
|
-
| tUBANG
|
732
744
|
|
733
745
|
reswords: k__LINE__ | k__FILE__ | k__ENCODING__ | klBEGIN | klEND
|
734
746
|
| kALIAS | kAND | kBEGIN | kBREAK | kCASE
|
@@ -762,24 +774,20 @@ rule
|
|
762
774
|
}
|
763
775
|
| primary_value tCOLON2 tIDENTIFIER tOP_ASGN arg_rhs
|
764
776
|
{
|
765
|
-
lhs, _, id, op, rhs = val
|
777
|
+
lhs, _, (id, _line), (op, _), rhs = val
|
766
778
|
|
767
779
|
result = s(:op_asgn, lhs, rhs, id.to_sym, op.to_sym).line lhs.line
|
768
780
|
}
|
769
781
|
| primary_value tCOLON2 tCONSTANT tOP_ASGN arg_rhs
|
770
782
|
{
|
771
|
-
lhs1, _, lhs2, op, rhs = val
|
783
|
+
lhs1, _, (lhs2, _line), op, rhs = val
|
772
784
|
|
773
785
|
lhs = s(:colon2, lhs1, lhs2.to_sym).line lhs1.line
|
774
786
|
result = new_const_op_asgn [lhs, op, rhs]
|
775
787
|
}
|
776
|
-
| tCOLON3 tCONSTANT
|
777
|
-
{
|
778
|
-
result = self.lexer.lineno
|
779
|
-
}
|
780
|
-
tOP_ASGN arg_rhs
|
788
|
+
| tCOLON3 tCONSTANT tOP_ASGN arg_rhs
|
781
789
|
{
|
782
|
-
_, lhs, line, op, rhs = val
|
790
|
+
_, (lhs, line), op, rhs = val
|
783
791
|
|
784
792
|
lhs = s(:colon3, lhs.to_sym).line line
|
785
793
|
result = new_const_op_asgn [lhs, op, rhs]
|
@@ -793,7 +801,7 @@ rule
|
|
793
801
|
| arg tDOT2 arg
|
794
802
|
{
|
795
803
|
v1, v2 = val[0], val[2]
|
796
|
-
if v1.
|
804
|
+
if v1.sexp_type == :lit and v2.sexp_type == :lit and Integer === v1.last and Integer === v2.last then
|
797
805
|
result = s(:lit, (v1.last)..(v2.last)).line v1.line
|
798
806
|
else
|
799
807
|
result = s(:dot2, v1, v2).line v1.line
|
@@ -802,7 +810,7 @@ rule
|
|
802
810
|
| arg tDOT3 arg
|
803
811
|
{
|
804
812
|
v1, v2 = val[0], val[2]
|
805
|
-
if v1.
|
813
|
+
if v1.sexp_type == :lit and v2.sexp_type == :lit and Integer === v1.last and Integer === v2.last then
|
806
814
|
result = s(:lit, (v1.last)...(v2.last)).line v1.line
|
807
815
|
else
|
808
816
|
result = s(:dot3, v1, v2).line v1.line
|
@@ -823,20 +831,6 @@ rule
|
|
823
831
|
result = s(:dot3, v1, v2).line v1.line
|
824
832
|
}
|
825
833
|
|
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
834
|
|
841
835
|
| arg tPLUS arg
|
842
836
|
{
|
@@ -864,8 +858,9 @@ rule
|
|
864
858
|
}
|
865
859
|
| tUMINUS_NUM simple_numeric tPOW arg
|
866
860
|
{
|
867
|
-
|
868
|
-
|
861
|
+
_, (num, line), _, arg = val
|
862
|
+
lit = s(:lit, num).line line
|
863
|
+
result = new_call(new_call(lit, :"**", argl(arg)), :"-@")
|
869
864
|
|
870
865
|
}
|
871
866
|
| tUPLUS arg
|
@@ -964,12 +959,12 @@ rule
|
|
964
959
|
|
965
960
|
rel_expr: arg relop arg =tGT
|
966
961
|
{
|
967
|
-
lhs, op, rhs = val
|
962
|
+
lhs, (op, _), rhs = val
|
968
963
|
result = new_call lhs, op.to_sym, argl(rhs)
|
969
964
|
}
|
970
965
|
| rel_expr relop arg =tGT
|
971
966
|
{
|
972
|
-
lhs, op, rhs = val
|
967
|
+
lhs, (op, _), rhs = val
|
973
968
|
warn "comparison '%s' after comparison", op
|
974
969
|
result = new_call lhs, op.to_sym, argl(rhs)
|
975
970
|
}
|
@@ -1009,16 +1004,6 @@ rule
|
|
1009
1004
|
_, args, _ = val
|
1010
1005
|
result = args
|
1011
1006
|
}
|
1012
|
-
| tLPAREN2 args_forward rparen
|
1013
|
-
{
|
1014
|
-
if (!self.lexer.is_local_id(:"*") ||
|
1015
|
-
!self.lexer.is_local_id(:"**") ||
|
1016
|
-
!self.lexer.is_local_id(:"&")) then
|
1017
|
-
|
1018
|
-
yyerror("Invalid argument forwarding")
|
1019
|
-
end
|
1020
|
-
result = call_args [s(:forward_args).line(lexer.lineno)]
|
1021
|
-
}
|
1022
1007
|
|
1023
1008
|
opt_paren_args: none
|
1024
1009
|
| paren_args
|
@@ -1170,8 +1155,9 @@ rule
|
|
1170
1155
|
| backref
|
1171
1156
|
| tFID
|
1172
1157
|
{
|
1173
|
-
msg, = val
|
1158
|
+
(msg, line), = val
|
1174
1159
|
result = new_call nil, msg.to_sym
|
1160
|
+
result.line line
|
1175
1161
|
}
|
1176
1162
|
| k_begin
|
1177
1163
|
{
|
@@ -1213,15 +1199,15 @@ rule
|
|
1213
1199
|
}
|
1214
1200
|
| primary_value tCOLON2 tCONSTANT
|
1215
1201
|
{
|
1216
|
-
expr, _, id = val
|
1202
|
+
expr, _, (id, _line) = val
|
1217
1203
|
|
1218
1204
|
result = s(:colon2, expr, id.to_sym).line expr.line
|
1219
1205
|
}
|
1220
1206
|
| tCOLON3 tCONSTANT
|
1221
1207
|
{
|
1222
|
-
_, id = val
|
1208
|
+
_, (id, line) = val
|
1223
1209
|
|
1224
|
-
result = s(:colon3, id.to_sym).line
|
1210
|
+
result = s(:colon3, id.to_sym).line line
|
1225
1211
|
}
|
1226
1212
|
| tLBRACK { result = lexer.lineno } aref_args tRBRACK
|
1227
1213
|
{
|
@@ -1245,15 +1231,21 @@ rule
|
|
1245
1231
|
}
|
1246
1232
|
| kYIELD tLPAREN2 call_args rparen
|
1247
1233
|
{
|
1248
|
-
|
1234
|
+
(_, line), _, args, _ = val
|
1235
|
+
|
1236
|
+
result = new_yield(args).line line
|
1249
1237
|
}
|
1250
1238
|
| kYIELD tLPAREN2 rparen
|
1251
1239
|
{
|
1252
|
-
|
1240
|
+
(_, line), _, _ = val
|
1241
|
+
|
1242
|
+
result = new_yield.line line
|
1253
1243
|
}
|
1254
1244
|
| kYIELD
|
1255
1245
|
{
|
1256
|
-
|
1246
|
+
(_, line), = val
|
1247
|
+
|
1248
|
+
result = new_yield.line line
|
1257
1249
|
}
|
1258
1250
|
| kDEFINED opt_nl tLPAREN2 expr rparen
|
1259
1251
|
{
|
@@ -1268,7 +1260,7 @@ rule
|
|
1268
1260
|
}
|
1269
1261
|
| kNOT tLPAREN2 rparen
|
1270
1262
|
{
|
1271
|
-
|
1263
|
+
debug 20
|
1272
1264
|
}
|
1273
1265
|
| fcall brace_block
|
1274
1266
|
{
|
@@ -1286,9 +1278,10 @@ rule
|
|
1286
1278
|
iter.insert 1, call # FIX
|
1287
1279
|
result = iter
|
1288
1280
|
}
|
1289
|
-
|
|
1281
|
+
| lambda
|
1290
1282
|
{
|
1291
|
-
|
1283
|
+
expr, = val
|
1284
|
+
result = expr
|
1292
1285
|
}
|
1293
1286
|
| k_if expr_value then compstmt if_tail k_end
|
1294
1287
|
{
|
@@ -1331,7 +1324,6 @@ rule
|
|
1331
1324
|
}
|
1332
1325
|
cpath superclass
|
1333
1326
|
{
|
1334
|
-
self.comments.push self.lexer.comments
|
1335
1327
|
if (self.in_def || self.in_single > 0) then
|
1336
1328
|
yyerror "class definition in method body"
|
1337
1329
|
end
|
@@ -1341,7 +1333,7 @@ rule
|
|
1341
1333
|
{
|
1342
1334
|
result = new_class val
|
1343
1335
|
self.env.unextend
|
1344
|
-
self.lexer.
|
1336
|
+
self.lexer.ignore_body_comments
|
1345
1337
|
}
|
1346
1338
|
| k_class tLSHFT
|
1347
1339
|
{
|
@@ -1362,7 +1354,7 @@ rule
|
|
1362
1354
|
{
|
1363
1355
|
result = new_sclass val
|
1364
1356
|
self.env.unextend
|
1365
|
-
self.lexer.
|
1357
|
+
self.lexer.ignore_body_comments
|
1366
1358
|
}
|
1367
1359
|
| k_module
|
1368
1360
|
{
|
@@ -1370,7 +1362,6 @@ rule
|
|
1370
1362
|
}
|
1371
1363
|
cpath
|
1372
1364
|
{
|
1373
|
-
self.comments.push self.lexer.comments
|
1374
1365
|
yyerror "module definition in method body" if
|
1375
1366
|
self.in_def or self.in_single > 0
|
1376
1367
|
|
@@ -1380,7 +1371,7 @@ rule
|
|
1380
1371
|
{
|
1381
1372
|
result = new_module val
|
1382
1373
|
self.env.unextend
|
1383
|
-
self.lexer.
|
1374
|
+
self.lexer.ignore_body_comments
|
1384
1375
|
}
|
1385
1376
|
| k_def fname
|
1386
1377
|
{
|
@@ -1390,21 +1381,17 @@ rule
|
|
1390
1381
|
self.env.extend
|
1391
1382
|
lexer.cmdarg.push false
|
1392
1383
|
lexer.cond.push false
|
1393
|
-
|
1394
|
-
self.comments.push self.lexer.comments
|
1395
1384
|
}
|
1396
|
-
f_arglist bodystmt
|
1385
|
+
f_arglist bodystmt k_end
|
1397
1386
|
{
|
1398
|
-
in_def = val
|
1399
|
-
|
1400
|
-
result = new_defn val
|
1387
|
+
result, in_def = new_defn val
|
1401
1388
|
|
1402
1389
|
lexer.cond.pop # group = local_pop
|
1403
1390
|
lexer.cmdarg.pop
|
1404
1391
|
self.env.unextend
|
1405
1392
|
self.in_def = in_def
|
1406
1393
|
|
1407
|
-
self.lexer.
|
1394
|
+
self.lexer.ignore_body_comments
|
1408
1395
|
}
|
1409
1396
|
| k_def singleton dot_or_colon
|
1410
1397
|
{
|
@@ -1412,7 +1399,7 @@ rule
|
|
1412
1399
|
}
|
1413
1400
|
fname
|
1414
1401
|
{
|
1415
|
-
result =
|
1402
|
+
result = self.in_def
|
1416
1403
|
|
1417
1404
|
self.in_single += 1 # TODO: remove?
|
1418
1405
|
|
@@ -1422,13 +1409,18 @@ rule
|
|
1422
1409
|
lexer.cond.push false
|
1423
1410
|
|
1424
1411
|
lexer.lex_state = EXPR_ENDFN|EXPR_LABEL
|
1425
|
-
self.comments.push self.lexer.comments
|
1426
1412
|
}
|
1427
1413
|
f_arglist bodystmt k_end
|
1428
1414
|
{
|
1429
|
-
_, _recv, _, _, _name, (in_def, _lineno), _args, _body, _ = val
|
1430
1415
|
|
1431
|
-
|
1416
|
+
# [kdef, recv, _, _, (name, line), in_def, args, body, kend]
|
1417
|
+
# =>
|
1418
|
+
# [kdef, recv, (name, line), in_def, args, body, kend]
|
1419
|
+
|
1420
|
+
val.delete_at 3
|
1421
|
+
val.delete_at 2
|
1422
|
+
|
1423
|
+
result, in_def = new_defs val
|
1432
1424
|
|
1433
1425
|
lexer.cond.pop # group = local_pop
|
1434
1426
|
lexer.cmdarg.pop
|
@@ -1439,7 +1431,7 @@ rule
|
|
1439
1431
|
|
1440
1432
|
# TODO: restore cur_arg ? what's cur_arg?
|
1441
1433
|
|
1442
|
-
self.lexer.
|
1434
|
+
self.lexer.ignore_body_comments
|
1443
1435
|
}
|
1444
1436
|
| kBREAK
|
1445
1437
|
{
|
@@ -1476,8 +1468,17 @@ rule
|
|
1476
1468
|
k_case: kCASE
|
1477
1469
|
k_for: kFOR
|
1478
1470
|
k_class: kCLASS
|
1471
|
+
{
|
1472
|
+
self.comments.push self.lexer.comments
|
1473
|
+
}
|
1479
1474
|
k_module: kMODULE
|
1475
|
+
{
|
1476
|
+
self.comments.push self.lexer.comments
|
1477
|
+
}
|
1480
1478
|
k_def: kDEF
|
1479
|
+
{
|
1480
|
+
self.comments.push self.lexer.comments
|
1481
|
+
}
|
1481
1482
|
k_do: kDO
|
1482
1483
|
k_do_block: kDO_BLOCK
|
1483
1484
|
k_rescue: kRESCUE
|
@@ -1538,51 +1539,42 @@ rule
|
|
1538
1539
|
|
1539
1540
|
result = block_var args
|
1540
1541
|
}
|
1541
|
-
| f_marg_list tCOMMA
|
1542
|
+
| f_marg_list tCOMMA f_rest_marg
|
1542
1543
|
{
|
1543
|
-
args, _,
|
1544
|
+
args, _, rest = val
|
1544
1545
|
|
1545
|
-
result = block_var args,
|
1546
|
+
result = block_var args, rest
|
1546
1547
|
}
|
1547
|
-
| f_marg_list tCOMMA
|
1548
|
+
| f_marg_list tCOMMA f_rest_marg tCOMMA f_marg_list
|
1548
1549
|
{
|
1549
|
-
|
1550
|
+
lhs, _, splat, _, rhs = val
|
1550
1551
|
|
1551
|
-
result = block_var
|
1552
|
+
result = block_var lhs, splat, rhs
|
1552
1553
|
}
|
1553
|
-
|
|
1554
|
+
| f_rest_marg
|
1554
1555
|
{
|
1555
|
-
|
1556
|
+
rest, = val
|
1556
1557
|
|
1557
|
-
result = block_var
|
1558
|
+
result = block_var rest
|
1558
1559
|
}
|
1559
|
-
|
|
1560
|
+
| f_rest_marg tCOMMA f_marg_list
|
1560
1561
|
{
|
1561
|
-
|
1562
|
+
splat, _, rest = val
|
1562
1563
|
|
1563
|
-
result = block_var
|
1564
|
+
result = block_var splat, rest
|
1564
1565
|
}
|
1565
|
-
| tSTAR f_norm_arg
|
1566
|
-
{
|
1567
|
-
_, splat = val
|
1568
1566
|
|
1569
|
-
|
1570
|
-
}
|
1571
|
-
| tSTAR f_norm_arg tCOMMA f_marg_list
|
1567
|
+
f_rest_marg: tSTAR f_norm_arg
|
1572
1568
|
{
|
1573
|
-
_,
|
1569
|
+
_, (id, line) = val
|
1574
1570
|
|
1575
|
-
result =
|
1571
|
+
result = args ["*#{id}".to_sym]
|
1572
|
+
result.line line
|
1576
1573
|
}
|
1577
1574
|
| tSTAR
|
1578
1575
|
{
|
1579
|
-
result =
|
1580
|
-
|
1581
|
-
| tSTAR tCOMMA f_marg_list
|
1582
|
-
{
|
1583
|
-
_, _, args = val
|
1584
|
-
|
1585
|
-
result = block_var :*, args
|
1576
|
+
result = args [:*]
|
1577
|
+
result.line lexer.lineno # FIX: tSTAR -> line
|
1586
1578
|
}
|
1587
1579
|
|
1588
1580
|
block_args_tail: f_block_kwarg tCOMMA f_kwrest opt_f_block_arg
|
@@ -1599,8 +1591,8 @@ rule
|
|
1599
1591
|
}
|
1600
1592
|
| f_block_arg
|
1601
1593
|
{
|
1602
|
-
line =
|
1603
|
-
result = call_args
|
1594
|
+
(id, line), = val
|
1595
|
+
result = call_args [id]
|
1604
1596
|
result.line line
|
1605
1597
|
}
|
1606
1598
|
|
@@ -1709,13 +1701,13 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1709
1701
|
|
1710
1702
|
bvar: tIDENTIFIER
|
1711
1703
|
{
|
1712
|
-
id, = val
|
1713
|
-
line = lexer.lineno
|
1704
|
+
(id, line), = val
|
1714
1705
|
result = s(:shadow, id.to_sym).line line
|
1715
1706
|
}
|
1716
1707
|
| f_bad_arg
|
1717
1708
|
|
1718
|
-
lambda:
|
1709
|
+
lambda: tLAMBDA
|
1710
|
+
{
|
1719
1711
|
self.env.extend :dynamic
|
1720
1712
|
result = [lexer.lineno, lexer.lpar_beg]
|
1721
1713
|
lexer.paren_nest += 1
|
@@ -1727,14 +1719,14 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1727
1719
|
}
|
1728
1720
|
lambda_body
|
1729
1721
|
{
|
1730
|
-
(line, lpar), args, _cmdarg, body = val
|
1722
|
+
_, (line, lpar), args, _cmdarg, body = val
|
1731
1723
|
lexer.lpar_beg = lpar
|
1732
1724
|
|
1733
1725
|
lexer.cmdarg.pop
|
1734
1726
|
|
1735
1727
|
call = s(:lambda).line line
|
1736
1728
|
result = new_iter call, args, body
|
1737
|
-
result.line
|
1729
|
+
result.line line
|
1738
1730
|
self.env.unextend # TODO: dynapush & dynapop
|
1739
1731
|
}
|
1740
1732
|
|
@@ -1769,23 +1761,28 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1769
1761
|
## if (nd_type($1) == NODE_YIELD) {
|
1770
1762
|
## compile_error(PARSER_ARG "block given to yield");
|
1771
1763
|
|
1772
|
-
|
1773
|
-
val[0].block_pass?
|
1764
|
+
cmd, blk = val
|
1774
1765
|
|
1775
|
-
|
1766
|
+
syntax_error "Both block arg and actual block given." if
|
1767
|
+
cmd.block_pass?
|
1776
1768
|
|
1777
|
-
|
1769
|
+
if inverted? val then
|
1770
|
+
val = invert_block_call val
|
1771
|
+
cmd, blk = val
|
1772
|
+
end
|
1778
1773
|
|
1779
1774
|
result = blk
|
1780
1775
|
result.insert 1, cmd
|
1781
1776
|
}
|
1782
1777
|
| block_call call_op2 operation2 opt_paren_args
|
1783
1778
|
{
|
1784
|
-
|
1779
|
+
lhs, _, (id, _line), args = val
|
1780
|
+
|
1781
|
+
result = new_call lhs, id.to_sym, args
|
1785
1782
|
}
|
1786
1783
|
| block_call call_op2 operation2 opt_paren_args brace_block
|
1787
1784
|
{
|
1788
|
-
iter1, _, name, args, iter2 = val
|
1785
|
+
iter1, _, (name, _line), args, iter2 = val
|
1789
1786
|
|
1790
1787
|
call = new_call iter1, name.to_sym, args
|
1791
1788
|
iter2.insert 1, call
|
@@ -1794,7 +1791,7 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1794
1791
|
}
|
1795
1792
|
| block_call call_op2 operation2 command_args do_block
|
1796
1793
|
{
|
1797
|
-
iter1, _, name, args, iter2 = val
|
1794
|
+
iter1, _, (name, _line), args, iter2 = val
|
1798
1795
|
|
1799
1796
|
call = new_call iter1, name.to_sym, args
|
1800
1797
|
iter2.insert 1, call
|
@@ -1802,28 +1799,29 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1802
1799
|
result = iter2
|
1803
1800
|
}
|
1804
1801
|
|
1805
|
-
method_call: fcall
|
1806
|
-
{
|
1807
|
-
result = self.lexer.lineno
|
1808
|
-
}
|
1809
|
-
paren_args
|
1802
|
+
method_call: fcall paren_args
|
1810
1803
|
{
|
1811
|
-
call,
|
1804
|
+
call, args = val
|
1812
1805
|
|
1813
1806
|
result = call.concat args.sexp_body if args
|
1814
|
-
result.line lineno
|
1815
1807
|
}
|
1816
1808
|
| primary_value call_op operation2 opt_paren_args
|
1817
1809
|
{
|
1818
|
-
|
1810
|
+
recv, call_op, (op, _line), args = val
|
1811
|
+
|
1812
|
+
result = new_call recv, op.to_sym, args, call_op
|
1819
1813
|
}
|
1820
1814
|
| primary_value tCOLON2 operation2 paren_args
|
1821
1815
|
{
|
1822
|
-
|
1816
|
+
recv, _, (op, _line), args = val
|
1817
|
+
|
1818
|
+
result = new_call recv, op.to_sym, args
|
1823
1819
|
}
|
1824
1820
|
| primary_value tCOLON2 operation3
|
1825
1821
|
{
|
1826
|
-
|
1822
|
+
lhs, _, (id, _line) = val
|
1823
|
+
|
1824
|
+
result = new_call lhs, id.to_sym
|
1827
1825
|
}
|
1828
1826
|
| primary_value call_op paren_args
|
1829
1827
|
{
|
@@ -1856,7 +1854,7 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1856
1854
|
_, line, body, _ = val
|
1857
1855
|
|
1858
1856
|
result = body
|
1859
|
-
result.line
|
1857
|
+
result.line line
|
1860
1858
|
|
1861
1859
|
self.env.unextend
|
1862
1860
|
}
|
@@ -1870,7 +1868,7 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1870
1868
|
_, line, body, _ = val
|
1871
1869
|
|
1872
1870
|
result = body
|
1873
|
-
result.line
|
1871
|
+
result.line line
|
1874
1872
|
|
1875
1873
|
self.env.unextend
|
1876
1874
|
}
|
@@ -1899,14 +1897,39 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1899
1897
|
self.env.unextend
|
1900
1898
|
}
|
1901
1899
|
|
1900
|
+
case_args: arg_value
|
1901
|
+
{
|
1902
|
+
arg, = val
|
1903
|
+
|
1904
|
+
result = s(:array, arg).line arg.line
|
1905
|
+
}
|
1906
|
+
| tSTAR arg_value
|
1907
|
+
{
|
1908
|
+
_, arg = val
|
1909
|
+
|
1910
|
+
result = s(:array, s(:splat, arg).line(arg.line)).line arg.line
|
1911
|
+
}
|
1912
|
+
| case_args tCOMMA arg_value
|
1913
|
+
{
|
1914
|
+
args, _, id = val
|
1915
|
+
|
1916
|
+
result = self.list_append args, id
|
1917
|
+
}
|
1918
|
+
| case_args tCOMMA tSTAR arg_value
|
1919
|
+
{
|
1920
|
+
args, _, _, id = val
|
1921
|
+
|
1922
|
+
result = self.list_append args, s(:splat, id).line(id.line)
|
1923
|
+
}
|
1924
|
+
|
1902
1925
|
case_body: k_when
|
1903
1926
|
{
|
1904
1927
|
result = self.lexer.lineno
|
1905
1928
|
}
|
1906
|
-
|
1929
|
+
case_args then compstmt cases
|
1907
1930
|
{
|
1908
1931
|
result = new_when(val[2], val[4])
|
1909
|
-
result.line
|
1932
|
+
result.line val[1]
|
1910
1933
|
result << val[5] if val[5]
|
1911
1934
|
}
|
1912
1935
|
|
@@ -1952,17 +1975,10 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1952
1975
|
|
1953
1976
|
literal: numeric
|
1954
1977
|
{
|
1955
|
-
line =
|
1956
|
-
result = s(:lit,
|
1957
|
-
result.line = line
|
1978
|
+
(lit, line), = val
|
1979
|
+
result = s(:lit, lit).line line
|
1958
1980
|
}
|
1959
1981
|
| symbol
|
1960
|
-
{
|
1961
|
-
line = lexer.lineno
|
1962
|
-
result = s(:lit, val[0])
|
1963
|
-
result.line = line
|
1964
|
-
}
|
1965
|
-
| dsym
|
1966
1982
|
|
1967
1983
|
strings: string
|
1968
1984
|
{
|
@@ -1973,7 +1989,7 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1973
1989
|
|
1974
1990
|
string: tCHAR
|
1975
1991
|
{
|
1976
|
-
|
1992
|
+
debug 37
|
1977
1993
|
}
|
1978
1994
|
| string1
|
1979
1995
|
| string string1
|
@@ -1983,11 +1999,11 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1983
1999
|
|
1984
2000
|
string1: tSTRING_BEG string_contents tSTRING_END
|
1985
2001
|
{
|
1986
|
-
_, str, (_, func) = val
|
2002
|
+
(_, line), str, (_, func) = val
|
1987
2003
|
|
1988
|
-
str = dedent str if func =~ RubyLexer::
|
2004
|
+
str = dedent str if func =~ RubyLexer::STR_FUNC_DEDENT
|
1989
2005
|
|
1990
|
-
result = str
|
2006
|
+
result = str.line line
|
1991
2007
|
}
|
1992
2008
|
| tSTRING
|
1993
2009
|
{
|
@@ -2007,11 +2023,15 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
2007
2023
|
|
2008
2024
|
words: tWORDS_BEG tSPACE tSTRING_END
|
2009
2025
|
{
|
2010
|
-
|
2026
|
+
(_, line), _, _ = val
|
2027
|
+
|
2028
|
+
result = s(:array).line line
|
2011
2029
|
}
|
2012
2030
|
| tWORDS_BEG word_list tSTRING_END
|
2013
2031
|
{
|
2014
|
-
|
2032
|
+
(_, line), list, _ = val
|
2033
|
+
|
2034
|
+
result = list.line line
|
2015
2035
|
}
|
2016
2036
|
|
2017
2037
|
word_list: none
|
@@ -2031,18 +2051,20 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
2031
2051
|
|
2032
2052
|
symbols: tSYMBOLS_BEG tSPACE tSTRING_END
|
2033
2053
|
{
|
2034
|
-
|
2054
|
+
(_, line), _, _ = val
|
2055
|
+
|
2056
|
+
result = s(:array).line line
|
2035
2057
|
}
|
2036
|
-
| tSYMBOLS_BEG
|
2058
|
+
| tSYMBOLS_BEG symbol_list tSTRING_END
|
2037
2059
|
{
|
2038
|
-
_, line, list, _, = val
|
2039
|
-
list.line
|
2060
|
+
(_, line), list, _, = val
|
2061
|
+
list.line line
|
2040
2062
|
result = list
|
2041
2063
|
}
|
2042
2064
|
|
2043
2065
|
symbol_list: none
|
2044
2066
|
{
|
2045
|
-
result = new_symbol_list
|
2067
|
+
result = new_symbol_list
|
2046
2068
|
}
|
2047
2069
|
| symbol_list word tSPACE
|
2048
2070
|
{
|
@@ -2052,20 +2074,28 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
2052
2074
|
|
2053
2075
|
qwords: tQWORDS_BEG tSPACE tSTRING_END
|
2054
2076
|
{
|
2055
|
-
|
2077
|
+
(_, line), _, _ = val
|
2078
|
+
|
2079
|
+
result = s(:array).line line
|
2056
2080
|
}
|
2057
2081
|
| tQWORDS_BEG qword_list tSTRING_END
|
2058
2082
|
{
|
2059
|
-
|
2083
|
+
(_, line), list, _ = val
|
2084
|
+
|
2085
|
+
result = list.line line
|
2060
2086
|
}
|
2061
2087
|
|
2062
2088
|
qsymbols: tQSYMBOLS_BEG tSPACE tSTRING_END
|
2063
2089
|
{
|
2064
|
-
|
2090
|
+
(_, line), _, _ = val
|
2091
|
+
|
2092
|
+
result = s(:array).line line
|
2065
2093
|
}
|
2066
2094
|
| tQSYMBOLS_BEG qsym_list tSTRING_END
|
2067
2095
|
{
|
2068
|
-
|
2096
|
+
(_, line), list, _ = val
|
2097
|
+
|
2098
|
+
result = list.line line
|
2069
2099
|
}
|
2070
2100
|
|
2071
2101
|
qword_list: none
|
@@ -2088,7 +2118,8 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
2088
2118
|
|
2089
2119
|
string_contents: none
|
2090
2120
|
{
|
2091
|
-
|
2121
|
+
line = prev_value_to_lineno _values.last
|
2122
|
+
result = s(:str, +"").line line
|
2092
2123
|
}
|
2093
2124
|
| string_contents string_content
|
2094
2125
|
{
|
@@ -2163,8 +2194,8 @@ regexp_contents: none
|
|
2163
2194
|
lexer.brace_nest = brace_nest
|
2164
2195
|
lexer.string_nest = string_nest
|
2165
2196
|
|
2166
|
-
lexer.cmdarg.pop
|
2167
2197
|
lexer.cond.pop
|
2198
|
+
lexer.cmdarg.pop
|
2168
2199
|
|
2169
2200
|
lexer.lex_state = oldlex_state
|
2170
2201
|
|
@@ -2179,29 +2210,49 @@ regexp_contents: none
|
|
2179
2210
|
when nil then
|
2180
2211
|
result = s(:evstr).line line
|
2181
2212
|
else
|
2182
|
-
|
2213
|
+
debug 38
|
2183
2214
|
raise "unknown string body: #{stmt.inspect}"
|
2184
2215
|
end
|
2185
2216
|
}
|
2186
2217
|
|
2187
|
-
string_dvar: tGVAR
|
2188
|
-
|
2189
|
-
|
2218
|
+
string_dvar: tGVAR
|
2219
|
+
{
|
2220
|
+
(id, line), = val
|
2221
|
+
result = s(:gvar, id.to_sym).line line
|
2222
|
+
}
|
2223
|
+
| tIVAR
|
2224
|
+
{
|
2225
|
+
(id, line), = val
|
2226
|
+
result = s(:ivar, id.to_sym).line line
|
2227
|
+
}
|
2228
|
+
| tCVAR
|
2229
|
+
{
|
2230
|
+
(id, line), = val
|
2231
|
+
result = s(:cvar, id.to_sym).line line
|
2232
|
+
}
|
2190
2233
|
| backref
|
2191
2234
|
|
2192
|
-
symbol:
|
2235
|
+
symbol: ssym
|
2236
|
+
| dsym
|
2237
|
+
|
2238
|
+
ssym: tSYMBEG sym
|
2193
2239
|
{
|
2240
|
+
_, (id, line) = val
|
2241
|
+
|
2194
2242
|
lexer.lex_state = EXPR_END
|
2195
|
-
result =
|
2243
|
+
result = s(:lit, id.to_sym).line line
|
2196
2244
|
}
|
2197
2245
|
| tSYMBOL
|
2198
2246
|
{
|
2199
|
-
|
2247
|
+
(id, line), = val
|
2248
|
+
|
2249
|
+
lexer.lex_state = EXPR_END
|
2250
|
+
result = s(:lit, id.to_sym).line line
|
2200
2251
|
}
|
2201
2252
|
|
2202
2253
|
sym: fname | tIVAR | tGVAR | tCVAR
|
2203
2254
|
|
2204
|
-
dsym: tSYMBEG
|
2255
|
+
dsym: tSYMBEG string_contents tSTRING_END
|
2205
2256
|
{
|
2206
2257
|
_, result, _ = val
|
2207
2258
|
|
@@ -2217,14 +2268,15 @@ regexp_contents: none
|
|
2217
2268
|
when :evstr then
|
2218
2269
|
result = s(:dsym, "", result).line result.line
|
2219
2270
|
else
|
2220
|
-
|
2271
|
+
debug 39
|
2221
2272
|
end
|
2222
2273
|
}
|
2223
2274
|
|
2224
2275
|
numeric: simple_numeric
|
2225
|
-
| tUMINUS_NUM simple_numeric
|
2276
|
+
| tUMINUS_NUM simple_numeric =tLOWEST
|
2226
2277
|
{
|
2227
|
-
|
2278
|
+
_, (num, line) = val
|
2279
|
+
result = [-num, line]
|
2228
2280
|
}
|
2229
2281
|
|
2230
2282
|
simple_numeric: tINTEGER
|
@@ -2257,8 +2309,10 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2257
2309
|
|
2258
2310
|
var_ref: user_variable
|
2259
2311
|
{
|
2260
|
-
|
2312
|
+
raise "NO: #{val.inspect}" if Sexp === val.first
|
2313
|
+
(var, line), = val
|
2261
2314
|
result = Sexp === var ? var : self.gettable(var)
|
2315
|
+
result.line line
|
2262
2316
|
}
|
2263
2317
|
| keyword_variable
|
2264
2318
|
{
|
@@ -2273,11 +2327,19 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2273
2327
|
| keyword_variable
|
2274
2328
|
{
|
2275
2329
|
result = self.assignable val[0]
|
2276
|
-
|
2330
|
+
debug 40
|
2277
2331
|
}
|
2278
2332
|
|
2279
|
-
backref: tNTH_REF
|
2280
|
-
|
2333
|
+
backref: tNTH_REF
|
2334
|
+
{
|
2335
|
+
(ref, line), = val
|
2336
|
+
result = s(:nth_ref, ref).line line
|
2337
|
+
}
|
2338
|
+
| tBACK_REF
|
2339
|
+
{
|
2340
|
+
(ref, line), = val
|
2341
|
+
result = s(:back_ref, ref).line line
|
2342
|
+
}
|
2281
2343
|
|
2282
2344
|
superclass: tLT
|
2283
2345
|
{
|
@@ -2295,22 +2357,7 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2295
2357
|
|
2296
2358
|
f_arglist: tLPAREN2 f_args rparen
|
2297
2359
|
{
|
2298
|
-
result = val
|
2299
|
-
self.lexer.lex_state = EXPR_BEG
|
2300
|
-
self.lexer.command_start = true
|
2301
|
-
}
|
2302
|
-
| tLPAREN2 args_forward rparen
|
2303
|
-
{
|
2304
|
-
args_rest = :"*"
|
2305
|
-
kwargs_rest = :"**"
|
2306
|
-
block_fwd = :"&"
|
2307
|
-
self.env[args_rest] = :lvar
|
2308
|
-
self.env[kwargs_rest] = :lvar
|
2309
|
-
self.env[block_fwd] = :lvar
|
2310
|
-
|
2311
|
-
result = s(:args, s(:forward_args)).line lexer.lineno
|
2312
|
-
self.lexer.lex_state = EXPR_BEG
|
2313
|
-
self.lexer.command_start = true
|
2360
|
+
result = end_args val
|
2314
2361
|
}
|
2315
2362
|
| {
|
2316
2363
|
result = self.in_kwarg
|
@@ -2319,12 +2366,7 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2319
2366
|
}
|
2320
2367
|
f_args term
|
2321
2368
|
{
|
2322
|
-
|
2323
|
-
|
2324
|
-
self.in_kwarg = kwarg
|
2325
|
-
result = args
|
2326
|
-
lexer.lex_state = EXPR_BEG
|
2327
|
-
lexer.command_start = true
|
2369
|
+
result = end_args val
|
2328
2370
|
}
|
2329
2371
|
|
2330
2372
|
args_tail: f_kwarg tCOMMA f_kwrest opt_f_block_arg
|
@@ -2409,9 +2451,9 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2409
2451
|
|
|
2410
2452
|
{
|
2411
2453
|
result = args val
|
2454
|
+
# result.line lexer.lineno
|
2412
2455
|
}
|
2413
2456
|
|
2414
|
-
args_forward: tBDOT3
|
2415
2457
|
|
2416
2458
|
f_bad_arg: tCONSTANT
|
2417
2459
|
{
|
@@ -2433,10 +2475,11 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2433
2475
|
f_norm_arg: f_bad_arg
|
2434
2476
|
| tIDENTIFIER
|
2435
2477
|
{
|
2436
|
-
|
2478
|
+
(id, line), = val
|
2479
|
+
identifier = id.to_sym
|
2437
2480
|
self.env[identifier] = :lvar
|
2438
2481
|
|
2439
|
-
result = identifier
|
2482
|
+
result = [identifier, line]
|
2440
2483
|
}
|
2441
2484
|
|
2442
2485
|
f_arg_asgn: f_norm_arg
|
@@ -2444,22 +2487,14 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2444
2487
|
f_arg_item: f_arg_asgn
|
2445
2488
|
| tLPAREN f_margs rparen
|
2446
2489
|
{
|
2447
|
-
|
2490
|
+
_, margs, _ = val
|
2491
|
+
|
2492
|
+
result = margs
|
2448
2493
|
}
|
2449
2494
|
|
2450
2495
|
f_arg: f_arg_item
|
2451
2496
|
{
|
2452
|
-
|
2453
|
-
|
2454
|
-
case arg
|
2455
|
-
when Symbol then
|
2456
|
-
result = s(:args, arg).line lexer.lineno
|
2457
|
-
when Sexp then
|
2458
|
-
result = arg
|
2459
|
-
else
|
2460
|
-
debug20 32
|
2461
|
-
raise "Unknown f_arg type: #{val.inspect}"
|
2462
|
-
end
|
2497
|
+
result = new_arg val
|
2463
2498
|
}
|
2464
2499
|
| f_arg tCOMMA f_arg_item
|
2465
2500
|
{
|
@@ -2471,7 +2506,7 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2471
2506
|
result = s(:args, list).line list.line
|
2472
2507
|
end
|
2473
2508
|
|
2474
|
-
result << item
|
2509
|
+
result << (Sexp === item ? item : item.first)
|
2475
2510
|
}
|
2476
2511
|
|
2477
2512
|
f_label: tLABEL
|
@@ -2532,27 +2567,33 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2532
2567
|
kwrest_mark: tPOW
|
2533
2568
|
| tDSTAR
|
2534
2569
|
|
2570
|
+
|
2535
2571
|
f_kwrest: kwrest_mark tIDENTIFIER
|
2536
2572
|
{
|
2537
|
-
|
2538
|
-
|
2539
|
-
|
2573
|
+
_, (id, line) = val
|
2574
|
+
|
2575
|
+
name = id.to_sym
|
2576
|
+
self.assignable [name, line]
|
2577
|
+
result = [:"**#{name}", line]
|
2540
2578
|
}
|
2541
2579
|
| kwrest_mark
|
2542
2580
|
{
|
2543
|
-
|
2544
|
-
self.env[
|
2581
|
+
id = :"**"
|
2582
|
+
self.env[id] = :lvar # TODO: needed?!?
|
2583
|
+
result = [id, lexer.lineno] # TODO: tPOW/tDSTAR include lineno
|
2545
2584
|
}
|
2546
2585
|
|
2547
2586
|
f_opt: f_arg_asgn tEQL arg_value
|
2548
2587
|
{
|
2549
|
-
|
2588
|
+
lhs, _, rhs = val
|
2589
|
+
result = self.assignable lhs, rhs
|
2550
2590
|
# TODO: detect duplicate names
|
2551
2591
|
}
|
2552
2592
|
|
2553
2593
|
f_block_opt: f_arg_asgn tEQL primary_value
|
2554
2594
|
{
|
2555
|
-
|
2595
|
+
lhs, _, rhs = val
|
2596
|
+
result = self.assignable lhs, rhs
|
2556
2597
|
}
|
2557
2598
|
|
2558
2599
|
f_block_optarg: f_block_opt
|
@@ -2582,30 +2623,33 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2582
2623
|
f_rest_arg: restarg_mark tIDENTIFIER
|
2583
2624
|
{
|
2584
2625
|
# TODO: differs from parse.y - needs tests
|
2585
|
-
|
2586
|
-
|
2587
|
-
|
2626
|
+
_, (id, line) = val
|
2627
|
+
name = id.to_sym
|
2628
|
+
self.assignable [name, line]
|
2629
|
+
result = [:"*#{name}", line]
|
2588
2630
|
}
|
2589
2631
|
| restarg_mark
|
2590
2632
|
{
|
2591
2633
|
name = :"*"
|
2592
2634
|
self.env[name] = :lvar
|
2593
|
-
result = name
|
2635
|
+
result = [name, lexer.lineno] # FIX: tSTAR to include lineno
|
2594
2636
|
}
|
2595
2637
|
|
2596
2638
|
blkarg_mark: tAMPER2 | tAMPER
|
2597
2639
|
|
2598
2640
|
f_block_arg: blkarg_mark tIDENTIFIER
|
2599
2641
|
{
|
2600
|
-
|
2642
|
+
_, (id, line) = val
|
2643
|
+
identifier = id.to_sym
|
2601
2644
|
|
2602
2645
|
self.env[identifier] = :lvar
|
2603
|
-
result = "&#{identifier}".to_sym
|
2646
|
+
result = ["&#{identifier}".to_sym, line]
|
2604
2647
|
}
|
2605
2648
|
|
2606
2649
|
opt_f_block_arg: tCOMMA f_block_arg
|
2607
2650
|
{
|
2608
|
-
|
2651
|
+
_, arg = val
|
2652
|
+
result = arg
|
2609
2653
|
}
|
2610
2654
|
|
|
2611
2655
|
{
|
@@ -2654,9 +2698,11 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2654
2698
|
}
|
2655
2699
|
| tSTRING_BEG string_contents tLABEL_END arg_value
|
2656
2700
|
{
|
2657
|
-
_, sym, _, value = val
|
2701
|
+
(_, line), sym, _, value = val
|
2702
|
+
|
2658
2703
|
sym.sexp_type = :dsym
|
2659
|
-
|
2704
|
+
|
2705
|
+
result = s(:array, sym, value).line line
|
2660
2706
|
}
|
2661
2707
|
| tDSTAR arg_value
|
2662
2708
|
{
|