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 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
|
777
|
-
{
|
778
|
-
result = self.lexer.lineno
|
779
|
-
}
|
780
|
-
tOP_ASGN arg_rhs
|
787
|
+
| tCOLON3 tCONSTANT tOP_ASGN arg_rhs
|
781
788
|
{
|
782
|
-
_, lhs, line, op, rhs = val
|
789
|
+
_, (lhs, line), op, rhs = val
|
783
790
|
|
784
791
|
lhs = s(:colon3, lhs.to_sym).line line
|
785
792
|
result = new_const_op_asgn [lhs, op, rhs]
|
@@ -793,7 +800,7 @@ rule
|
|
793
800
|
| arg tDOT2 arg
|
794
801
|
{
|
795
802
|
v1, v2 = val[0], val[2]
|
796
|
-
if v1.
|
803
|
+
if v1.sexp_type == :lit and v2.sexp_type == :lit and Integer === v1.last and Integer === v2.last then
|
797
804
|
result = s(:lit, (v1.last)..(v2.last)).line v1.line
|
798
805
|
else
|
799
806
|
result = s(:dot2, v1, v2).line v1.line
|
@@ -802,41 +809,13 @@ rule
|
|
802
809
|
| arg tDOT3 arg
|
803
810
|
{
|
804
811
|
v1, v2 = val[0], val[2]
|
805
|
-
if v1.
|
812
|
+
if v1.sexp_type == :lit and v2.sexp_type == :lit and Integer === v1.last and Integer === v2.last then
|
806
813
|
result = s(:lit, (v1.last)...(v2.last)).line v1.line
|
807
814
|
else
|
808
815
|
result = s(:dot3, v1, v2).line v1.line
|
809
816
|
end
|
810
817
|
}
|
811
|
-
| arg tDOT2
|
812
|
-
{
|
813
|
-
v1, _ = val
|
814
|
-
v2 = nil
|
815
|
-
|
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
|
-
| tBDOT2 arg
|
827
|
-
{
|
828
|
-
_, v2, = val
|
829
|
-
v1 = nil
|
830
|
-
|
831
|
-
result = s(:dot2, v1, v2).line v2.line
|
832
|
-
}
|
833
|
-
| tBDOT3 arg
|
834
|
-
{
|
835
|
-
_, v2 = val
|
836
|
-
v1 = nil
|
837
|
-
|
838
|
-
result = s(:dot3, v1, v2).line v2.line
|
839
|
-
}
|
840
819
|
|
841
820
|
| arg tPLUS arg
|
842
821
|
{
|
@@ -864,8 +843,9 @@ rule
|
|
864
843
|
}
|
865
844
|
| tUMINUS_NUM simple_numeric tPOW arg
|
866
845
|
{
|
867
|
-
|
868
|
-
|
846
|
+
_, (num, line), _, arg = val
|
847
|
+
lit = s(:lit, num).line line
|
848
|
+
result = new_call(new_call(lit, :"**", argl(arg)), :"-@")
|
869
849
|
|
870
850
|
}
|
871
851
|
| tUPLUS arg
|
@@ -964,12 +944,12 @@ rule
|
|
964
944
|
|
965
945
|
rel_expr: arg relop arg =tGT
|
966
946
|
{
|
967
|
-
lhs, op, rhs = val
|
947
|
+
lhs, (op, _), rhs = val
|
968
948
|
result = new_call lhs, op.to_sym, argl(rhs)
|
969
949
|
}
|
970
950
|
| rel_expr relop arg =tGT
|
971
951
|
{
|
972
|
-
lhs, op, rhs = val
|
952
|
+
lhs, (op, _), rhs = val
|
973
953
|
warn "comparison '%s' after comparison", op
|
974
954
|
result = new_call lhs, op.to_sym, argl(rhs)
|
975
955
|
}
|
@@ -1009,16 +989,6 @@ rule
|
|
1009
989
|
_, args, _ = val
|
1010
990
|
result = args
|
1011
991
|
}
|
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
992
|
|
1023
993
|
opt_paren_args: none
|
1024
994
|
| paren_args
|
@@ -1170,8 +1140,9 @@ rule
|
|
1170
1140
|
| backref
|
1171
1141
|
| tFID
|
1172
1142
|
{
|
1173
|
-
msg, = val
|
1143
|
+
(msg, line), = val
|
1174
1144
|
result = new_call nil, msg.to_sym
|
1145
|
+
result.line line
|
1175
1146
|
}
|
1176
1147
|
| k_begin
|
1177
1148
|
{
|
@@ -1213,15 +1184,15 @@ rule
|
|
1213
1184
|
}
|
1214
1185
|
| primary_value tCOLON2 tCONSTANT
|
1215
1186
|
{
|
1216
|
-
expr, _, id = val
|
1187
|
+
expr, _, (id, _line) = val
|
1217
1188
|
|
1218
1189
|
result = s(:colon2, expr, id.to_sym).line expr.line
|
1219
1190
|
}
|
1220
1191
|
| tCOLON3 tCONSTANT
|
1221
1192
|
{
|
1222
|
-
_, id = val
|
1193
|
+
_, (id, line) = val
|
1223
1194
|
|
1224
|
-
result = s(:colon3, id.to_sym).line
|
1195
|
+
result = s(:colon3, id.to_sym).line line
|
1225
1196
|
}
|
1226
1197
|
| tLBRACK { result = lexer.lineno } aref_args tRBRACK
|
1227
1198
|
{
|
@@ -1245,15 +1216,21 @@ rule
|
|
1245
1216
|
}
|
1246
1217
|
| kYIELD tLPAREN2 call_args rparen
|
1247
1218
|
{
|
1248
|
-
|
1219
|
+
(_, line), _, args, _ = val
|
1220
|
+
|
1221
|
+
result = new_yield(args).line line
|
1249
1222
|
}
|
1250
1223
|
| kYIELD tLPAREN2 rparen
|
1251
1224
|
{
|
1252
|
-
|
1225
|
+
(_, line), _, _ = val
|
1226
|
+
|
1227
|
+
result = new_yield.line line
|
1253
1228
|
}
|
1254
1229
|
| kYIELD
|
1255
1230
|
{
|
1256
|
-
|
1231
|
+
(_, line), = val
|
1232
|
+
|
1233
|
+
result = new_yield.line line
|
1257
1234
|
}
|
1258
1235
|
| kDEFINED opt_nl tLPAREN2 expr rparen
|
1259
1236
|
{
|
@@ -1268,7 +1245,7 @@ rule
|
|
1268
1245
|
}
|
1269
1246
|
| kNOT tLPAREN2 rparen
|
1270
1247
|
{
|
1271
|
-
|
1248
|
+
debug 20
|
1272
1249
|
}
|
1273
1250
|
| fcall brace_block
|
1274
1251
|
{
|
@@ -1286,9 +1263,10 @@ rule
|
|
1286
1263
|
iter.insert 1, call # FIX
|
1287
1264
|
result = iter
|
1288
1265
|
}
|
1289
|
-
|
|
1266
|
+
| lambda
|
1290
1267
|
{
|
1291
|
-
|
1268
|
+
expr, = val
|
1269
|
+
result = expr
|
1292
1270
|
}
|
1293
1271
|
| k_if expr_value then compstmt if_tail k_end
|
1294
1272
|
{
|
@@ -1331,7 +1309,6 @@ rule
|
|
1331
1309
|
}
|
1332
1310
|
cpath superclass
|
1333
1311
|
{
|
1334
|
-
self.comments.push self.lexer.comments
|
1335
1312
|
if (self.in_def || self.in_single > 0) then
|
1336
1313
|
yyerror "class definition in method body"
|
1337
1314
|
end
|
@@ -1341,7 +1318,7 @@ rule
|
|
1341
1318
|
{
|
1342
1319
|
result = new_class val
|
1343
1320
|
self.env.unextend
|
1344
|
-
self.lexer.
|
1321
|
+
self.lexer.ignore_body_comments
|
1345
1322
|
}
|
1346
1323
|
| k_class tLSHFT
|
1347
1324
|
{
|
@@ -1362,7 +1339,7 @@ rule
|
|
1362
1339
|
{
|
1363
1340
|
result = new_sclass val
|
1364
1341
|
self.env.unextend
|
1365
|
-
self.lexer.
|
1342
|
+
self.lexer.ignore_body_comments
|
1366
1343
|
}
|
1367
1344
|
| k_module
|
1368
1345
|
{
|
@@ -1370,7 +1347,6 @@ rule
|
|
1370
1347
|
}
|
1371
1348
|
cpath
|
1372
1349
|
{
|
1373
|
-
self.comments.push self.lexer.comments
|
1374
1350
|
yyerror "module definition in method body" if
|
1375
1351
|
self.in_def or self.in_single > 0
|
1376
1352
|
|
@@ -1380,7 +1356,7 @@ rule
|
|
1380
1356
|
{
|
1381
1357
|
result = new_module val
|
1382
1358
|
self.env.unextend
|
1383
|
-
self.lexer.
|
1359
|
+
self.lexer.ignore_body_comments
|
1384
1360
|
}
|
1385
1361
|
| k_def fname
|
1386
1362
|
{
|
@@ -1390,21 +1366,17 @@ rule
|
|
1390
1366
|
self.env.extend
|
1391
1367
|
lexer.cmdarg.push false
|
1392
1368
|
lexer.cond.push false
|
1393
|
-
|
1394
|
-
self.comments.push self.lexer.comments
|
1395
1369
|
}
|
1396
|
-
f_arglist bodystmt
|
1370
|
+
f_arglist bodystmt k_end
|
1397
1371
|
{
|
1398
|
-
in_def = val
|
1399
|
-
|
1400
|
-
result = new_defn val
|
1372
|
+
result, in_def = new_defn val
|
1401
1373
|
|
1402
1374
|
lexer.cond.pop # group = local_pop
|
1403
1375
|
lexer.cmdarg.pop
|
1404
1376
|
self.env.unextend
|
1405
1377
|
self.in_def = in_def
|
1406
1378
|
|
1407
|
-
self.lexer.
|
1379
|
+
self.lexer.ignore_body_comments
|
1408
1380
|
}
|
1409
1381
|
| k_def singleton dot_or_colon
|
1410
1382
|
{
|
@@ -1412,7 +1384,7 @@ rule
|
|
1412
1384
|
}
|
1413
1385
|
fname
|
1414
1386
|
{
|
1415
|
-
result =
|
1387
|
+
result = self.in_def
|
1416
1388
|
|
1417
1389
|
self.in_single += 1 # TODO: remove?
|
1418
1390
|
|
@@ -1422,13 +1394,18 @@ rule
|
|
1422
1394
|
lexer.cond.push false
|
1423
1395
|
|
1424
1396
|
lexer.lex_state = EXPR_ENDFN|EXPR_LABEL
|
1425
|
-
self.comments.push self.lexer.comments
|
1426
1397
|
}
|
1427
1398
|
f_arglist bodystmt k_end
|
1428
1399
|
{
|
1429
|
-
_, _recv, _, _, _name, (in_def, _lineno), _args, _body, _ = val
|
1430
1400
|
|
1431
|
-
|
1401
|
+
# [kdef, recv, _, _, (name, line), in_def, args, body, kend]
|
1402
|
+
# =>
|
1403
|
+
# [kdef, recv, (name, line), in_def, args, body, kend]
|
1404
|
+
|
1405
|
+
val.delete_at 3
|
1406
|
+
val.delete_at 2
|
1407
|
+
|
1408
|
+
result, in_def = new_defs val
|
1432
1409
|
|
1433
1410
|
lexer.cond.pop # group = local_pop
|
1434
1411
|
lexer.cmdarg.pop
|
@@ -1439,7 +1416,7 @@ rule
|
|
1439
1416
|
|
1440
1417
|
# TODO: restore cur_arg ? what's cur_arg?
|
1441
1418
|
|
1442
|
-
self.lexer.
|
1419
|
+
self.lexer.ignore_body_comments
|
1443
1420
|
}
|
1444
1421
|
| kBREAK
|
1445
1422
|
{
|
@@ -1476,8 +1453,17 @@ rule
|
|
1476
1453
|
k_case: kCASE
|
1477
1454
|
k_for: kFOR
|
1478
1455
|
k_class: kCLASS
|
1456
|
+
{
|
1457
|
+
self.comments.push self.lexer.comments
|
1458
|
+
}
|
1479
1459
|
k_module: kMODULE
|
1460
|
+
{
|
1461
|
+
self.comments.push self.lexer.comments
|
1462
|
+
}
|
1480
1463
|
k_def: kDEF
|
1464
|
+
{
|
1465
|
+
self.comments.push self.lexer.comments
|
1466
|
+
}
|
1481
1467
|
k_do: kDO
|
1482
1468
|
k_do_block: kDO_BLOCK
|
1483
1469
|
k_rescue: kRESCUE
|
@@ -1538,51 +1524,42 @@ rule
|
|
1538
1524
|
|
1539
1525
|
result = block_var args
|
1540
1526
|
}
|
1541
|
-
| f_marg_list tCOMMA
|
1527
|
+
| f_marg_list tCOMMA f_rest_marg
|
1542
1528
|
{
|
1543
|
-
args, _,
|
1529
|
+
args, _, rest = val
|
1544
1530
|
|
1545
|
-
result = block_var args,
|
1531
|
+
result = block_var args, rest
|
1546
1532
|
}
|
1547
|
-
| f_marg_list tCOMMA
|
1533
|
+
| f_marg_list tCOMMA f_rest_marg tCOMMA f_marg_list
|
1548
1534
|
{
|
1549
|
-
|
1535
|
+
lhs, _, splat, _, rhs = val
|
1550
1536
|
|
1551
|
-
result = block_var
|
1537
|
+
result = block_var lhs, splat, rhs
|
1552
1538
|
}
|
1553
|
-
|
|
1539
|
+
| f_rest_marg
|
1554
1540
|
{
|
1555
|
-
|
1541
|
+
rest, = val
|
1556
1542
|
|
1557
|
-
result = block_var
|
1543
|
+
result = block_var rest
|
1558
1544
|
}
|
1559
|
-
|
|
1545
|
+
| f_rest_marg tCOMMA f_marg_list
|
1560
1546
|
{
|
1561
|
-
|
1547
|
+
splat, _, rest = val
|
1562
1548
|
|
1563
|
-
result = block_var
|
1549
|
+
result = block_var splat, rest
|
1564
1550
|
}
|
1565
|
-
| tSTAR f_norm_arg
|
1566
|
-
{
|
1567
|
-
_, splat = val
|
1568
1551
|
|
1569
|
-
|
1570
|
-
}
|
1571
|
-
| tSTAR f_norm_arg tCOMMA f_marg_list
|
1552
|
+
f_rest_marg: tSTAR f_norm_arg
|
1572
1553
|
{
|
1573
|
-
_,
|
1554
|
+
_, (id, line) = val
|
1574
1555
|
|
1575
|
-
result =
|
1556
|
+
result = args ["*#{id}".to_sym]
|
1557
|
+
result.line line
|
1576
1558
|
}
|
1577
1559
|
| tSTAR
|
1578
1560
|
{
|
1579
|
-
result =
|
1580
|
-
|
1581
|
-
| tSTAR tCOMMA f_marg_list
|
1582
|
-
{
|
1583
|
-
_, _, args = val
|
1584
|
-
|
1585
|
-
result = block_var :*, args
|
1561
|
+
result = args [:*]
|
1562
|
+
result.line lexer.lineno # FIX: tSTAR -> line
|
1586
1563
|
}
|
1587
1564
|
|
1588
1565
|
block_args_tail: f_block_kwarg tCOMMA f_kwrest opt_f_block_arg
|
@@ -1599,8 +1576,8 @@ rule
|
|
1599
1576
|
}
|
1600
1577
|
| f_block_arg
|
1601
1578
|
{
|
1602
|
-
line =
|
1603
|
-
result = call_args
|
1579
|
+
(id, line), = val
|
1580
|
+
result = call_args [id]
|
1604
1581
|
result.line line
|
1605
1582
|
}
|
1606
1583
|
|
@@ -1709,13 +1686,13 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1709
1686
|
|
1710
1687
|
bvar: tIDENTIFIER
|
1711
1688
|
{
|
1712
|
-
id, = val
|
1713
|
-
line = lexer.lineno
|
1689
|
+
(id, line), = val
|
1714
1690
|
result = s(:shadow, id.to_sym).line line
|
1715
1691
|
}
|
1716
1692
|
| f_bad_arg
|
1717
1693
|
|
1718
|
-
lambda:
|
1694
|
+
lambda: tLAMBDA
|
1695
|
+
{
|
1719
1696
|
self.env.extend :dynamic
|
1720
1697
|
result = [lexer.lineno, lexer.lpar_beg]
|
1721
1698
|
lexer.paren_nest += 1
|
@@ -1727,14 +1704,14 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1727
1704
|
}
|
1728
1705
|
lambda_body
|
1729
1706
|
{
|
1730
|
-
(line, lpar), args, _cmdarg, body = val
|
1707
|
+
_, (line, lpar), args, _cmdarg, body = val
|
1731
1708
|
lexer.lpar_beg = lpar
|
1732
1709
|
|
1733
1710
|
lexer.cmdarg.pop
|
1734
1711
|
|
1735
1712
|
call = s(:lambda).line line
|
1736
1713
|
result = new_iter call, args, body
|
1737
|
-
result.line
|
1714
|
+
result.line line
|
1738
1715
|
self.env.unextend # TODO: dynapush & dynapop
|
1739
1716
|
}
|
1740
1717
|
|
@@ -1769,23 +1746,28 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1769
1746
|
## if (nd_type($1) == NODE_YIELD) {
|
1770
1747
|
## compile_error(PARSER_ARG "block given to yield");
|
1771
1748
|
|
1772
|
-
|
1773
|
-
val[0].block_pass?
|
1749
|
+
cmd, blk = val
|
1774
1750
|
|
1775
|
-
|
1751
|
+
syntax_error "Both block arg and actual block given." if
|
1752
|
+
cmd.block_pass?
|
1776
1753
|
|
1777
|
-
|
1754
|
+
if inverted? val then
|
1755
|
+
val = invert_block_call val
|
1756
|
+
cmd, blk = val
|
1757
|
+
end
|
1778
1758
|
|
1779
1759
|
result = blk
|
1780
1760
|
result.insert 1, cmd
|
1781
1761
|
}
|
1782
1762
|
| block_call call_op2 operation2 opt_paren_args
|
1783
1763
|
{
|
1784
|
-
|
1764
|
+
lhs, _, (id, _line), args = val
|
1765
|
+
|
1766
|
+
result = new_call lhs, id.to_sym, args
|
1785
1767
|
}
|
1786
1768
|
| block_call call_op2 operation2 opt_paren_args brace_block
|
1787
1769
|
{
|
1788
|
-
iter1, _, name, args, iter2 = val
|
1770
|
+
iter1, _, (name, _line), args, iter2 = val
|
1789
1771
|
|
1790
1772
|
call = new_call iter1, name.to_sym, args
|
1791
1773
|
iter2.insert 1, call
|
@@ -1794,7 +1776,7 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1794
1776
|
}
|
1795
1777
|
| block_call call_op2 operation2 command_args do_block
|
1796
1778
|
{
|
1797
|
-
iter1, _, name, args, iter2 = val
|
1779
|
+
iter1, _, (name, _line), args, iter2 = val
|
1798
1780
|
|
1799
1781
|
call = new_call iter1, name.to_sym, args
|
1800
1782
|
iter2.insert 1, call
|
@@ -1802,28 +1784,29 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1802
1784
|
result = iter2
|
1803
1785
|
}
|
1804
1786
|
|
1805
|
-
method_call: fcall
|
1806
|
-
{
|
1807
|
-
result = self.lexer.lineno
|
1808
|
-
}
|
1809
|
-
paren_args
|
1787
|
+
method_call: fcall paren_args
|
1810
1788
|
{
|
1811
|
-
call,
|
1789
|
+
call, args = val
|
1812
1790
|
|
1813
1791
|
result = call.concat args.sexp_body if args
|
1814
|
-
result.line lineno
|
1815
1792
|
}
|
1816
1793
|
| primary_value call_op operation2 opt_paren_args
|
1817
1794
|
{
|
1818
|
-
|
1795
|
+
recv, call_op, (op, _line), args = val
|
1796
|
+
|
1797
|
+
result = new_call recv, op.to_sym, args, call_op
|
1819
1798
|
}
|
1820
1799
|
| primary_value tCOLON2 operation2 paren_args
|
1821
1800
|
{
|
1822
|
-
|
1801
|
+
recv, _, (op, _line), args = val
|
1802
|
+
|
1803
|
+
result = new_call recv, op.to_sym, args
|
1823
1804
|
}
|
1824
1805
|
| primary_value tCOLON2 operation3
|
1825
1806
|
{
|
1826
|
-
|
1807
|
+
lhs, _, (id, _line) = val
|
1808
|
+
|
1809
|
+
result = new_call lhs, id.to_sym
|
1827
1810
|
}
|
1828
1811
|
| primary_value call_op paren_args
|
1829
1812
|
{
|
@@ -1856,7 +1839,7 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1856
1839
|
_, line, body, _ = val
|
1857
1840
|
|
1858
1841
|
result = body
|
1859
|
-
result.line
|
1842
|
+
result.line line
|
1860
1843
|
|
1861
1844
|
self.env.unextend
|
1862
1845
|
}
|
@@ -1870,7 +1853,7 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1870
1853
|
_, line, body, _ = val
|
1871
1854
|
|
1872
1855
|
result = body
|
1873
|
-
result.line
|
1856
|
+
result.line line
|
1874
1857
|
|
1875
1858
|
self.env.unextend
|
1876
1859
|
}
|
@@ -1899,14 +1882,39 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1899
1882
|
self.env.unextend
|
1900
1883
|
}
|
1901
1884
|
|
1885
|
+
case_args: arg_value
|
1886
|
+
{
|
1887
|
+
arg, = val
|
1888
|
+
|
1889
|
+
result = s(:array, arg).line arg.line
|
1890
|
+
}
|
1891
|
+
| tSTAR arg_value
|
1892
|
+
{
|
1893
|
+
_, arg = val
|
1894
|
+
|
1895
|
+
result = s(:array, s(:splat, arg).line(arg.line)).line arg.line
|
1896
|
+
}
|
1897
|
+
| case_args tCOMMA arg_value
|
1898
|
+
{
|
1899
|
+
args, _, id = val
|
1900
|
+
|
1901
|
+
result = self.list_append args, id
|
1902
|
+
}
|
1903
|
+
| case_args tCOMMA tSTAR arg_value
|
1904
|
+
{
|
1905
|
+
args, _, _, id = val
|
1906
|
+
|
1907
|
+
result = self.list_append args, s(:splat, id).line(id.line)
|
1908
|
+
}
|
1909
|
+
|
1902
1910
|
case_body: k_when
|
1903
1911
|
{
|
1904
1912
|
result = self.lexer.lineno
|
1905
1913
|
}
|
1906
|
-
|
1914
|
+
case_args then compstmt cases
|
1907
1915
|
{
|
1908
1916
|
result = new_when(val[2], val[4])
|
1909
|
-
result.line
|
1917
|
+
result.line val[1]
|
1910
1918
|
result << val[5] if val[5]
|
1911
1919
|
}
|
1912
1920
|
|
@@ -1952,17 +1960,10 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1952
1960
|
|
1953
1961
|
literal: numeric
|
1954
1962
|
{
|
1955
|
-
line =
|
1956
|
-
result = s(:lit,
|
1957
|
-
result.line = line
|
1963
|
+
(lit, line), = val
|
1964
|
+
result = s(:lit, lit).line line
|
1958
1965
|
}
|
1959
1966
|
| symbol
|
1960
|
-
{
|
1961
|
-
line = lexer.lineno
|
1962
|
-
result = s(:lit, val[0])
|
1963
|
-
result.line = line
|
1964
|
-
}
|
1965
|
-
| dsym
|
1966
1967
|
|
1967
1968
|
strings: string
|
1968
1969
|
{
|
@@ -1973,7 +1974,7 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1973
1974
|
|
1974
1975
|
string: tCHAR
|
1975
1976
|
{
|
1976
|
-
|
1977
|
+
debug 37
|
1977
1978
|
}
|
1978
1979
|
| string1
|
1979
1980
|
| string string1
|
@@ -1983,11 +1984,11 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1983
1984
|
|
1984
1985
|
string1: tSTRING_BEG string_contents tSTRING_END
|
1985
1986
|
{
|
1986
|
-
_, str, (_, func) = val
|
1987
|
+
(_, line), str, (_, func) = val
|
1987
1988
|
|
1988
|
-
str = dedent str if func =~ RubyLexer::
|
1989
|
+
str = dedent str if func =~ RubyLexer::STR_FUNC_DEDENT
|
1989
1990
|
|
1990
|
-
result = str
|
1991
|
+
result = str.line line
|
1991
1992
|
}
|
1992
1993
|
| tSTRING
|
1993
1994
|
{
|
@@ -2007,11 +2008,15 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
2007
2008
|
|
2008
2009
|
words: tWORDS_BEG tSPACE tSTRING_END
|
2009
2010
|
{
|
2010
|
-
|
2011
|
+
(_, line), _, _ = val
|
2012
|
+
|
2013
|
+
result = s(:array).line line
|
2011
2014
|
}
|
2012
2015
|
| tWORDS_BEG word_list tSTRING_END
|
2013
2016
|
{
|
2014
|
-
|
2017
|
+
(_, line), list, _ = val
|
2018
|
+
|
2019
|
+
result = list.line line
|
2015
2020
|
}
|
2016
2021
|
|
2017
2022
|
word_list: none
|
@@ -2031,18 +2036,20 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
2031
2036
|
|
2032
2037
|
symbols: tSYMBOLS_BEG tSPACE tSTRING_END
|
2033
2038
|
{
|
2034
|
-
|
2039
|
+
(_, line), _, _ = val
|
2040
|
+
|
2041
|
+
result = s(:array).line line
|
2035
2042
|
}
|
2036
|
-
| tSYMBOLS_BEG
|
2043
|
+
| tSYMBOLS_BEG symbol_list tSTRING_END
|
2037
2044
|
{
|
2038
|
-
_, line, list, _, = val
|
2039
|
-
list.line
|
2045
|
+
(_, line), list, _, = val
|
2046
|
+
list.line line
|
2040
2047
|
result = list
|
2041
2048
|
}
|
2042
2049
|
|
2043
2050
|
symbol_list: none
|
2044
2051
|
{
|
2045
|
-
result = new_symbol_list
|
2052
|
+
result = new_symbol_list
|
2046
2053
|
}
|
2047
2054
|
| symbol_list word tSPACE
|
2048
2055
|
{
|
@@ -2052,20 +2059,28 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
2052
2059
|
|
2053
2060
|
qwords: tQWORDS_BEG tSPACE tSTRING_END
|
2054
2061
|
{
|
2055
|
-
|
2062
|
+
(_, line), _, _ = val
|
2063
|
+
|
2064
|
+
result = s(:array).line line
|
2056
2065
|
}
|
2057
2066
|
| tQWORDS_BEG qword_list tSTRING_END
|
2058
2067
|
{
|
2059
|
-
|
2068
|
+
(_, line), list, _ = val
|
2069
|
+
|
2070
|
+
result = list.line line
|
2060
2071
|
}
|
2061
2072
|
|
2062
2073
|
qsymbols: tQSYMBOLS_BEG tSPACE tSTRING_END
|
2063
2074
|
{
|
2064
|
-
|
2075
|
+
(_, line), _, _ = val
|
2076
|
+
|
2077
|
+
result = s(:array).line line
|
2065
2078
|
}
|
2066
2079
|
| tQSYMBOLS_BEG qsym_list tSTRING_END
|
2067
2080
|
{
|
2068
|
-
|
2081
|
+
(_, line), list, _ = val
|
2082
|
+
|
2083
|
+
result = list.line line
|
2069
2084
|
}
|
2070
2085
|
|
2071
2086
|
qword_list: none
|
@@ -2088,7 +2103,8 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
2088
2103
|
|
2089
2104
|
string_contents: none
|
2090
2105
|
{
|
2091
|
-
|
2106
|
+
line = prev_value_to_lineno _values.last
|
2107
|
+
result = s(:str, +"").line line
|
2092
2108
|
}
|
2093
2109
|
| string_contents string_content
|
2094
2110
|
{
|
@@ -2163,8 +2179,8 @@ regexp_contents: none
|
|
2163
2179
|
lexer.brace_nest = brace_nest
|
2164
2180
|
lexer.string_nest = string_nest
|
2165
2181
|
|
2166
|
-
lexer.cmdarg.pop
|
2167
2182
|
lexer.cond.pop
|
2183
|
+
lexer.cmdarg.pop
|
2168
2184
|
|
2169
2185
|
lexer.lex_state = oldlex_state
|
2170
2186
|
|
@@ -2179,29 +2195,49 @@ regexp_contents: none
|
|
2179
2195
|
when nil then
|
2180
2196
|
result = s(:evstr).line line
|
2181
2197
|
else
|
2182
|
-
|
2198
|
+
debug 38
|
2183
2199
|
raise "unknown string body: #{stmt.inspect}"
|
2184
2200
|
end
|
2185
2201
|
}
|
2186
2202
|
|
2187
|
-
string_dvar: tGVAR
|
2188
|
-
|
2189
|
-
|
2203
|
+
string_dvar: tGVAR
|
2204
|
+
{
|
2205
|
+
(id, line), = val
|
2206
|
+
result = s(:gvar, id.to_sym).line line
|
2207
|
+
}
|
2208
|
+
| tIVAR
|
2209
|
+
{
|
2210
|
+
(id, line), = val
|
2211
|
+
result = s(:ivar, id.to_sym).line line
|
2212
|
+
}
|
2213
|
+
| tCVAR
|
2214
|
+
{
|
2215
|
+
(id, line), = val
|
2216
|
+
result = s(:cvar, id.to_sym).line line
|
2217
|
+
}
|
2190
2218
|
| backref
|
2191
2219
|
|
2192
|
-
symbol:
|
2220
|
+
symbol: ssym
|
2221
|
+
| dsym
|
2222
|
+
|
2223
|
+
ssym: tSYMBEG sym
|
2193
2224
|
{
|
2225
|
+
_, (id, line) = val
|
2226
|
+
|
2194
2227
|
lexer.lex_state = EXPR_END
|
2195
|
-
result =
|
2228
|
+
result = s(:lit, id.to_sym).line line
|
2196
2229
|
}
|
2197
2230
|
| tSYMBOL
|
2198
2231
|
{
|
2199
|
-
|
2232
|
+
(id, line), = val
|
2233
|
+
|
2234
|
+
lexer.lex_state = EXPR_END
|
2235
|
+
result = s(:lit, id.to_sym).line line
|
2200
2236
|
}
|
2201
2237
|
|
2202
2238
|
sym: fname | tIVAR | tGVAR | tCVAR
|
2203
2239
|
|
2204
|
-
dsym: tSYMBEG
|
2240
|
+
dsym: tSYMBEG string_contents tSTRING_END
|
2205
2241
|
{
|
2206
2242
|
_, result, _ = val
|
2207
2243
|
|
@@ -2217,14 +2253,15 @@ regexp_contents: none
|
|
2217
2253
|
when :evstr then
|
2218
2254
|
result = s(:dsym, "", result).line result.line
|
2219
2255
|
else
|
2220
|
-
|
2256
|
+
debug 39
|
2221
2257
|
end
|
2222
2258
|
}
|
2223
2259
|
|
2224
2260
|
numeric: simple_numeric
|
2225
|
-
| tUMINUS_NUM simple_numeric
|
2261
|
+
| tUMINUS_NUM simple_numeric =tLOWEST
|
2226
2262
|
{
|
2227
|
-
|
2263
|
+
_, (num, line) = val
|
2264
|
+
result = [-num, line]
|
2228
2265
|
}
|
2229
2266
|
|
2230
2267
|
simple_numeric: tINTEGER
|
@@ -2257,8 +2294,10 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2257
2294
|
|
2258
2295
|
var_ref: user_variable
|
2259
2296
|
{
|
2260
|
-
|
2297
|
+
raise "NO: #{val.inspect}" if Sexp === val.first
|
2298
|
+
(var, line), = val
|
2261
2299
|
result = Sexp === var ? var : self.gettable(var)
|
2300
|
+
result.line line
|
2262
2301
|
}
|
2263
2302
|
| keyword_variable
|
2264
2303
|
{
|
@@ -2273,11 +2312,19 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2273
2312
|
| keyword_variable
|
2274
2313
|
{
|
2275
2314
|
result = self.assignable val[0]
|
2276
|
-
|
2315
|
+
debug 40
|
2277
2316
|
}
|
2278
2317
|
|
2279
|
-
backref: tNTH_REF
|
2280
|
-
|
2318
|
+
backref: tNTH_REF
|
2319
|
+
{
|
2320
|
+
(ref, line), = val
|
2321
|
+
result = s(:nth_ref, ref).line line
|
2322
|
+
}
|
2323
|
+
| tBACK_REF
|
2324
|
+
{
|
2325
|
+
(ref, line), = val
|
2326
|
+
result = s(:back_ref, ref).line line
|
2327
|
+
}
|
2281
2328
|
|
2282
2329
|
superclass: tLT
|
2283
2330
|
{
|
@@ -2295,22 +2342,7 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2295
2342
|
|
2296
2343
|
f_arglist: tLPAREN2 f_args rparen
|
2297
2344
|
{
|
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
|
2345
|
+
result = end_args val
|
2314
2346
|
}
|
2315
2347
|
| {
|
2316
2348
|
result = self.in_kwarg
|
@@ -2319,12 +2351,7 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2319
2351
|
}
|
2320
2352
|
f_args term
|
2321
2353
|
{
|
2322
|
-
|
2323
|
-
|
2324
|
-
self.in_kwarg = kwarg
|
2325
|
-
result = args
|
2326
|
-
lexer.lex_state = EXPR_BEG
|
2327
|
-
lexer.command_start = true
|
2354
|
+
result = end_args val
|
2328
2355
|
}
|
2329
2356
|
|
2330
2357
|
args_tail: f_kwarg tCOMMA f_kwrest opt_f_block_arg
|
@@ -2409,9 +2436,9 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2409
2436
|
|
|
2410
2437
|
{
|
2411
2438
|
result = args val
|
2439
|
+
# result.line lexer.lineno
|
2412
2440
|
}
|
2413
2441
|
|
2414
|
-
args_forward: tBDOT3
|
2415
2442
|
|
2416
2443
|
f_bad_arg: tCONSTANT
|
2417
2444
|
{
|
@@ -2433,10 +2460,11 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2433
2460
|
f_norm_arg: f_bad_arg
|
2434
2461
|
| tIDENTIFIER
|
2435
2462
|
{
|
2436
|
-
|
2463
|
+
(id, line), = val
|
2464
|
+
identifier = id.to_sym
|
2437
2465
|
self.env[identifier] = :lvar
|
2438
2466
|
|
2439
|
-
result = identifier
|
2467
|
+
result = [identifier, line]
|
2440
2468
|
}
|
2441
2469
|
|
2442
2470
|
f_arg_asgn: f_norm_arg
|
@@ -2444,22 +2472,14 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2444
2472
|
f_arg_item: f_arg_asgn
|
2445
2473
|
| tLPAREN f_margs rparen
|
2446
2474
|
{
|
2447
|
-
|
2475
|
+
_, margs, _ = val
|
2476
|
+
|
2477
|
+
result = margs
|
2448
2478
|
}
|
2449
2479
|
|
2450
2480
|
f_arg: f_arg_item
|
2451
2481
|
{
|
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
|
2482
|
+
result = new_arg val
|
2463
2483
|
}
|
2464
2484
|
| f_arg tCOMMA f_arg_item
|
2465
2485
|
{
|
@@ -2471,7 +2491,7 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2471
2491
|
result = s(:args, list).line list.line
|
2472
2492
|
end
|
2473
2493
|
|
2474
|
-
result << item
|
2494
|
+
result << (Sexp === item ? item : item.first)
|
2475
2495
|
}
|
2476
2496
|
|
2477
2497
|
f_label: tLABEL
|
@@ -2532,27 +2552,33 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2532
2552
|
kwrest_mark: tPOW
|
2533
2553
|
| tDSTAR
|
2534
2554
|
|
2555
|
+
|
2535
2556
|
f_kwrest: kwrest_mark tIDENTIFIER
|
2536
2557
|
{
|
2537
|
-
|
2538
|
-
|
2539
|
-
|
2558
|
+
_, (id, line) = val
|
2559
|
+
|
2560
|
+
name = id.to_sym
|
2561
|
+
self.assignable [name, line]
|
2562
|
+
result = [:"**#{name}", line]
|
2540
2563
|
}
|
2541
2564
|
| kwrest_mark
|
2542
2565
|
{
|
2543
|
-
|
2544
|
-
self.env[
|
2566
|
+
id = :"**"
|
2567
|
+
self.env[id] = :lvar # TODO: needed?!?
|
2568
|
+
result = [id, lexer.lineno] # TODO: tPOW/tDSTAR include lineno
|
2545
2569
|
}
|
2546
2570
|
|
2547
2571
|
f_opt: f_arg_asgn tEQL arg_value
|
2548
2572
|
{
|
2549
|
-
|
2573
|
+
lhs, _, rhs = val
|
2574
|
+
result = self.assignable lhs, rhs
|
2550
2575
|
# TODO: detect duplicate names
|
2551
2576
|
}
|
2552
2577
|
|
2553
2578
|
f_block_opt: f_arg_asgn tEQL primary_value
|
2554
2579
|
{
|
2555
|
-
|
2580
|
+
lhs, _, rhs = val
|
2581
|
+
result = self.assignable lhs, rhs
|
2556
2582
|
}
|
2557
2583
|
|
2558
2584
|
f_block_optarg: f_block_opt
|
@@ -2582,30 +2608,33 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2582
2608
|
f_rest_arg: restarg_mark tIDENTIFIER
|
2583
2609
|
{
|
2584
2610
|
# TODO: differs from parse.y - needs tests
|
2585
|
-
|
2586
|
-
|
2587
|
-
|
2611
|
+
_, (id, line) = val
|
2612
|
+
name = id.to_sym
|
2613
|
+
self.assignable [name, line]
|
2614
|
+
result = [:"*#{name}", line]
|
2588
2615
|
}
|
2589
2616
|
| restarg_mark
|
2590
2617
|
{
|
2591
2618
|
name = :"*"
|
2592
2619
|
self.env[name] = :lvar
|
2593
|
-
result = name
|
2620
|
+
result = [name, lexer.lineno] # FIX: tSTAR to include lineno
|
2594
2621
|
}
|
2595
2622
|
|
2596
2623
|
blkarg_mark: tAMPER2 | tAMPER
|
2597
2624
|
|
2598
2625
|
f_block_arg: blkarg_mark tIDENTIFIER
|
2599
2626
|
{
|
2600
|
-
|
2627
|
+
_, (id, line) = val
|
2628
|
+
identifier = id.to_sym
|
2601
2629
|
|
2602
2630
|
self.env[identifier] = :lvar
|
2603
|
-
result = "&#{identifier}".to_sym
|
2631
|
+
result = ["&#{identifier}".to_sym, line]
|
2604
2632
|
}
|
2605
2633
|
|
2606
2634
|
opt_f_block_arg: tCOMMA f_block_arg
|
2607
2635
|
{
|
2608
|
-
|
2636
|
+
_, arg = val
|
2637
|
+
result = arg
|
2609
2638
|
}
|
2610
2639
|
|
|
2611
2640
|
{
|
@@ -2654,9 +2683,11 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
|
|
2654
2683
|
}
|
2655
2684
|
| tSTRING_BEG string_contents tLABEL_END arg_value
|
2656
2685
|
{
|
2657
|
-
_, sym, _, value = val
|
2686
|
+
(_, line), sym, _, value = val
|
2687
|
+
|
2658
2688
|
sym.sexp_type = :dsym
|
2659
|
-
|
2689
|
+
|
2690
|
+
result = s(:array, sym, value).line line
|
2660
2691
|
}
|
2661
2692
|
| tDSTAR arg_value
|
2662
2693
|
{
|