brakeman 3.5.0 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGES +15 -4
- data/bin/brakeman +6 -1
- data/bundle/load.rb +2 -2
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/Manifest.txt +5 -0
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/README.rdoc +12 -0
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/Rakefile +127 -70
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/compare/normalize.rb +146 -0
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/rp_extensions.rb +77 -0
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/rp_stringscanner.rb +64 -0
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/ruby18_parser.rb +1637 -1646
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/ruby18_parser.y +11 -11
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/ruby19_parser.rb +1602 -1603
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/ruby19_parser.y +12 -12
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/ruby20_parser.rb +2507 -2524
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/ruby20_parser.y +12 -26
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/ruby21_parser.rb +1872 -1868
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/ruby21_parser.y +12 -21
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/ruby22_parser.rb +1758 -1754
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/ruby22_parser.y +12 -21
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/ruby23_parser.rb +1844 -1847
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/ruby23_parser.y +12 -21
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/ruby24_parser.rb +6790 -0
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/ruby24_parser.y +2364 -0
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/ruby_lexer.rb +12 -16
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/ruby_lexer.rex.rb +6 -12
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/ruby_parser.rb +86 -7
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/ruby_parser.yy +51 -50
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/lib/ruby_parser_extras.rb +30 -237
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/test/test_ruby_lexer.rb +54 -41
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/test/test_ruby_parser.rb +775 -700
- data/bundle/ruby/2.3.0/gems/ruby_parser-3.8.4/test/test_ruby_parser_extras.rb +4 -6
- data/bundle/ruby/2.3.0/gems/{sexp_processor-4.7.0 → sexp_processor-4.8.0}/History.txt +7 -0
- data/bundle/ruby/2.3.0/gems/{sexp_processor-4.7.0 → sexp_processor-4.8.0}/Manifest.txt +0 -0
- data/bundle/ruby/2.3.0/gems/{sexp_processor-4.7.0 → sexp_processor-4.8.0}/README.txt +0 -0
- data/bundle/ruby/2.3.0/gems/{sexp_processor-4.7.0 → sexp_processor-4.8.0}/Rakefile +0 -0
- data/bundle/ruby/2.3.0/gems/{sexp_processor-4.7.0 → sexp_processor-4.8.0}/lib/composite_sexp_processor.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{sexp_processor-4.7.0 → sexp_processor-4.8.0}/lib/pt_testcase.rb +3 -1
- data/bundle/ruby/2.3.0/gems/{sexp_processor-4.7.0 → sexp_processor-4.8.0}/lib/sexp.rb +7 -0
- data/bundle/ruby/2.3.0/gems/{sexp_processor-4.7.0 → sexp_processor-4.8.0}/lib/sexp_processor.rb +7 -5
- data/bundle/ruby/2.3.0/gems/{sexp_processor-4.7.0 → sexp_processor-4.8.0}/lib/unique.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{sexp_processor-4.7.0 → sexp_processor-4.8.0}/test/test_composite_sexp_processor.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{sexp_processor-4.7.0 → sexp_processor-4.8.0}/test/test_environment.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{sexp_processor-4.7.0 → sexp_processor-4.8.0}/test/test_sexp.rb +21 -2
- data/bundle/ruby/2.3.0/gems/{sexp_processor-4.7.0 → sexp_processor-4.8.0}/test/test_sexp_processor.rb +13 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/CHANGELOG.md +4 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/COPYING +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/Gemfile +1 -1
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/HACKING +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/README.md +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/Rakefile +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/bin/tilt +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/docs/TEMPLATES.md +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/docs/common.css +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt.rb +1 -1
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/asciidoc.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/babel.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/bluecloth.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/builder.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/coffee.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/commonmarker.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/creole.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/csv.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/dummy.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/erb.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/erubi.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/erubis.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/etanni.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/haml.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/kramdown.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/less.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/liquid.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/livescript.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/mapping.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/markaby.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/maruku.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/nokogiri.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/pandoc.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/plain.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/prawn.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/radius.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/rdiscount.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/rdoc.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/redcarpet.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/redcloth.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/rst-pandoc.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/sass.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/sigil.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/string.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/template.rb +10 -1
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/typescript.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/wikicloth.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/lib/tilt/yajl.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/man/index.txt +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/man/tilt.1.ronn +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/markaby/locals.mab +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/markaby/markaby.mab +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/markaby/markaby_other_static.mab +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/markaby/render_twice.mab +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/markaby/scope.mab +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/markaby/yielding.mab +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/mytemplate.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/test_helper.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_asciidoctor_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_babeltemplate.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_blueclothtemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_buildertemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_cache_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_coffeescripttemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_commonmarkertemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_compilesite_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_creoletemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_csv_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_erbtemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_erubistemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_erubitemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_etannitemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_hamltemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_kramdown_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_lesstemplate_test.less +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_lesstemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_liquidtemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_livescripttemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_mapping_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_markaby_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_markdown_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_marukutemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_metadata_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_nokogiritemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_pandoctemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_prawntemplate.prawn +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_prawntemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_radiustemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_rdiscounttemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_rdoctemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_redcarpettemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_redclothtemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_rstpandoctemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_sasstemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_sigil_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_stringtemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_template_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_typescript_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_wikiclothtemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/test/tilt_yajltemplate_test.rb +0 -0
- data/bundle/ruby/2.3.0/gems/{tilt-2.0.6 → tilt-2.0.7}/tilt.gemspec +2 -2
- data/lib/brakeman.rb +4 -0
- data/lib/brakeman/checks/check_sql.rb +2 -2
- data/lib/brakeman/checks/check_xml_dos.rb +0 -6
- data/lib/brakeman/options.rb +4 -0
- data/lib/brakeman/parsers/rails3_erubis.rb +7 -0
- data/lib/brakeman/processors/alias_processor.rb +101 -0
- data/lib/brakeman/processors/controller_processor.rb +3 -1
- data/lib/brakeman/version.rb +1 -1
- metadata +125 -118
@@ -0,0 +1,2364 @@
|
|
1
|
+
# -*- racc -*-
|
2
|
+
|
3
|
+
class Ruby24Parser
|
4
|
+
|
5
|
+
token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
|
6
|
+
kTHEN kELSIF kELSE kCASE kWHEN kWHILE kUNTIL kFOR kBREAK kNEXT
|
7
|
+
kREDO kRETRY kIN kDO kDO_COND kDO_BLOCK kDO_LAMBDA kRETURN kYIELD kSUPER
|
8
|
+
kSELF kNIL kTRUE kFALSE kAND kOR kNOT kIF_MOD kUNLESS_MOD kWHILE_MOD
|
9
|
+
kUNTIL_MOD kRESCUE_MOD kALIAS kDEFINED klBEGIN klEND k__LINE__
|
10
|
+
k__FILE__ k__ENCODING__ tIDENTIFIER tFID tGVAR tIVAR tCONSTANT
|
11
|
+
tLABEL tCVAR tNTH_REF tBACK_REF tSTRING_CONTENT tINTEGER tFLOAT
|
12
|
+
tREGEXP_END tUPLUS tUMINUS tUMINUS_NUM tPOW tCMP tEQ tEQQ tNEQ
|
13
|
+
tGEQ tLEQ tANDOP tOROP tMATCH tNMATCH tDOT tDOT2 tDOT3 tAREF
|
14
|
+
tASET tLSHFT tRSHFT tCOLON2 tCOLON3 tOP_ASGN tASSOC tLPAREN
|
15
|
+
tLPAREN2 tRPAREN tLPAREN_ARG tLBRACK tLBRACK2 tRBRACK tLBRACE
|
16
|
+
tLBRACE_ARG tSTAR tSTAR2 tAMPER tAMPER2 tTILDE tPERCENT tDIVIDE
|
17
|
+
tPLUS tMINUS tLT tGT tPIPE tBANG tCARET tLCURLY tRCURLY
|
18
|
+
tBACK_REF2 tSYMBEG tSTRING_BEG tXSTRING_BEG tREGEXP_BEG
|
19
|
+
tWORDS_BEG tQWORDS_BEG tSTRING_DBEG tSTRING_DVAR tSTRING_END
|
20
|
+
tSTRING tSYMBOL tNL tEH tCOLON tCOMMA tSPACE tSEMI tLAMBDA
|
21
|
+
tLAMBEG tDSTAR tCHAR tSYMBOLS_BEG tQSYMBOLS_BEG tSTRING_DEND tUBANG
|
22
|
+
tRATIONAL tIMAGINARY
|
23
|
+
tLABEL_END
|
24
|
+
tLONELY
|
25
|
+
|
26
|
+
prechigh
|
27
|
+
right tBANG tTILDE tUPLUS
|
28
|
+
right tPOW
|
29
|
+
right tUMINUS_NUM tUMINUS
|
30
|
+
left tSTAR2 tDIVIDE tPERCENT
|
31
|
+
left tPLUS tMINUS
|
32
|
+
left tLSHFT tRSHFT
|
33
|
+
left tAMPER2
|
34
|
+
left tPIPE tCARET
|
35
|
+
left tGT tGEQ tLT tLEQ
|
36
|
+
nonassoc tCMP tEQ tEQQ tNEQ tMATCH tNMATCH
|
37
|
+
left tANDOP
|
38
|
+
left tOROP
|
39
|
+
nonassoc tDOT2 tDOT3
|
40
|
+
right tEH tCOLON
|
41
|
+
left kRESCUE_MOD
|
42
|
+
right tEQL tOP_ASGN
|
43
|
+
nonassoc kDEFINED
|
44
|
+
right kNOT
|
45
|
+
left kOR kAND
|
46
|
+
nonassoc kIF_MOD kUNLESS_MOD kWHILE_MOD kUNTIL_MOD
|
47
|
+
nonassoc tLBRACE_ARG
|
48
|
+
nonassoc tLOWEST
|
49
|
+
preclow
|
50
|
+
|
51
|
+
rule
|
52
|
+
|
53
|
+
program: {
|
54
|
+
self.lexer.lex_state = :expr_beg
|
55
|
+
}
|
56
|
+
top_compstmt
|
57
|
+
{
|
58
|
+
result = new_compstmt val
|
59
|
+
}
|
60
|
+
|
61
|
+
top_compstmt: top_stmts opt_terms
|
62
|
+
{
|
63
|
+
result = val[0]
|
64
|
+
}
|
65
|
+
|
66
|
+
top_stmts: none
|
67
|
+
| top_stmt
|
68
|
+
| top_stmts terms top_stmt
|
69
|
+
{
|
70
|
+
result = self.block_append val[0], val[2]
|
71
|
+
}
|
72
|
+
| error top_stmt
|
73
|
+
|
74
|
+
top_stmt: stmt
|
75
|
+
{
|
76
|
+
result = val[0]
|
77
|
+
|
78
|
+
# TODO: remove once I have more confidence this is fixed
|
79
|
+
# result.each_of_type :call_args do |s|
|
80
|
+
# debug20 666, s, result
|
81
|
+
# end
|
82
|
+
}
|
83
|
+
| klBEGIN
|
84
|
+
{
|
85
|
+
if (self.in_def || self.in_single > 0) then
|
86
|
+
debug20 1
|
87
|
+
yyerror "BEGIN in method"
|
88
|
+
end
|
89
|
+
self.env.extend
|
90
|
+
}
|
91
|
+
tLCURLY top_compstmt tRCURLY
|
92
|
+
{
|
93
|
+
result = new_iter s(:preexe), nil, val[3]
|
94
|
+
}
|
95
|
+
|
96
|
+
bodystmt: compstmt opt_rescue opt_else opt_ensure
|
97
|
+
{
|
98
|
+
result = new_body val
|
99
|
+
}
|
100
|
+
|
101
|
+
compstmt: stmts opt_terms
|
102
|
+
{
|
103
|
+
result = new_compstmt val
|
104
|
+
}
|
105
|
+
|
106
|
+
stmts: none
|
107
|
+
| stmt
|
108
|
+
| stmts terms stmt
|
109
|
+
{
|
110
|
+
result = self.block_append val[0], val[2]
|
111
|
+
}
|
112
|
+
| error stmt
|
113
|
+
{
|
114
|
+
result = val[1]
|
115
|
+
debug20 2, val, result
|
116
|
+
}
|
117
|
+
|
118
|
+
stmt: kALIAS fitem
|
119
|
+
{
|
120
|
+
lexer.lex_state = :expr_fname
|
121
|
+
result = self.lexer.lineno
|
122
|
+
}
|
123
|
+
fitem
|
124
|
+
{
|
125
|
+
result = s(:alias, val[1], val[3]).line(val[2])
|
126
|
+
}
|
127
|
+
| kALIAS tGVAR tGVAR
|
128
|
+
{
|
129
|
+
result = s(:valias, val[1].to_sym, val[2].to_sym)
|
130
|
+
}
|
131
|
+
| kALIAS tGVAR tBACK_REF
|
132
|
+
{
|
133
|
+
result = s(:valias, val[1].to_sym, :"$#{val[2]}")
|
134
|
+
}
|
135
|
+
| kALIAS tGVAR tNTH_REF
|
136
|
+
{
|
137
|
+
yyerror "can't make alias for the number variables"
|
138
|
+
}
|
139
|
+
| kUNDEF undef_list
|
140
|
+
{
|
141
|
+
result = val[1]
|
142
|
+
}
|
143
|
+
| stmt kIF_MOD expr_value
|
144
|
+
{
|
145
|
+
result = new_if val[2], val[0], nil
|
146
|
+
}
|
147
|
+
| stmt kUNLESS_MOD expr_value
|
148
|
+
{
|
149
|
+
result = new_if val[2], nil, val[0]
|
150
|
+
}
|
151
|
+
| stmt kWHILE_MOD expr_value
|
152
|
+
{
|
153
|
+
result = new_while val[0], val[2], true
|
154
|
+
}
|
155
|
+
| stmt kUNTIL_MOD expr_value
|
156
|
+
{
|
157
|
+
result = new_until val[0], val[2], true
|
158
|
+
}
|
159
|
+
| stmt kRESCUE_MOD stmt
|
160
|
+
{
|
161
|
+
result = s(:rescue, val[0], new_resbody(s(:array), val[2]))
|
162
|
+
}
|
163
|
+
| klEND tLCURLY compstmt tRCURLY
|
164
|
+
{
|
165
|
+
if (self.in_def || self.in_single > 0) then
|
166
|
+
debug20 3
|
167
|
+
yyerror "END in method; use at_exit"
|
168
|
+
end
|
169
|
+
result = new_iter s(:postexe), 0, val[2]
|
170
|
+
}
|
171
|
+
| command_asgn
|
172
|
+
| mlhs tEQL command_call
|
173
|
+
{
|
174
|
+
result = new_masgn val[0], val[2], :wrap
|
175
|
+
}
|
176
|
+
| var_lhs tOP_ASGN command_call
|
177
|
+
{
|
178
|
+
result = new_op_asgn val
|
179
|
+
}
|
180
|
+
| primary_value tLBRACK2 opt_call_args rbracket tOP_ASGN command_call
|
181
|
+
{
|
182
|
+
result = s(:op_asgn1, val[0], val[2], val[4].to_sym, val[5])
|
183
|
+
}
|
184
|
+
| primary_value call_op tIDENTIFIER tOP_ASGN command_call
|
185
|
+
{
|
186
|
+
result = s(:op_asgn, val[0], val[4], val[2].to_sym, val[3].to_sym)
|
187
|
+
if val[1] == '&.'
|
188
|
+
result[0] = :safe_op_asgn
|
189
|
+
end
|
190
|
+
result.line = val[0].line
|
191
|
+
}
|
192
|
+
| primary_value call_op tCONSTANT tOP_ASGN command_call
|
193
|
+
{
|
194
|
+
result = s(:op_asgn, val[0], val[4], val[2].to_sym, val[3].to_sym)
|
195
|
+
if val[1] == '&.'
|
196
|
+
result[0] = :safe_op_asgn
|
197
|
+
end
|
198
|
+
result.line = val[0].line
|
199
|
+
}
|
200
|
+
| primary_value tCOLON2 tCONSTANT tOP_ASGN command_call
|
201
|
+
{
|
202
|
+
result = s(:op_asgn, val[0], val[4], val[2], val[3])
|
203
|
+
debug20 4, val, result
|
204
|
+
}
|
205
|
+
| primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_call
|
206
|
+
{
|
207
|
+
result = s(:op_asgn, val[0], val[4], val[2], val[3])
|
208
|
+
debug20 5, val, result
|
209
|
+
}
|
210
|
+
| backref tOP_ASGN command_call
|
211
|
+
{
|
212
|
+
self.backref_assign_error val[0]
|
213
|
+
}
|
214
|
+
| lhs tEQL mrhs
|
215
|
+
{
|
216
|
+
result = new_assign val[0], s(:svalue, val[2])
|
217
|
+
}
|
218
|
+
| mlhs tEQL mrhs_arg
|
219
|
+
{
|
220
|
+
result = new_masgn val[0], val[2]
|
221
|
+
}
|
222
|
+
| expr
|
223
|
+
|
224
|
+
command_asgn: lhs tEQL command_call
|
225
|
+
{
|
226
|
+
result = new_assign val[0], val[2]
|
227
|
+
}
|
228
|
+
| lhs tEQL command_asgn
|
229
|
+
{
|
230
|
+
result = new_assign val[0], val[2]
|
231
|
+
}
|
232
|
+
|
233
|
+
expr: command_call
|
234
|
+
| expr kAND expr
|
235
|
+
{
|
236
|
+
result = logical_op :and, val[0], val[2]
|
237
|
+
}
|
238
|
+
| expr kOR expr
|
239
|
+
{
|
240
|
+
result = logical_op :or, val[0], val[2]
|
241
|
+
}
|
242
|
+
| kNOT opt_nl expr
|
243
|
+
{
|
244
|
+
result = s(:call, val[2], :"!")
|
245
|
+
}
|
246
|
+
| tBANG command_call
|
247
|
+
{
|
248
|
+
result = s(:call, val[1], :"!")
|
249
|
+
}
|
250
|
+
| arg
|
251
|
+
|
252
|
+
expr_value: expr
|
253
|
+
{
|
254
|
+
result = value_expr(val[0])
|
255
|
+
}
|
256
|
+
|
257
|
+
command_call: command
|
258
|
+
| block_command
|
259
|
+
|
260
|
+
block_command: block_call
|
261
|
+
| block_call dot_or_colon operation2 command_args
|
262
|
+
{
|
263
|
+
result = new_call val[0], val[2].to_sym, val[3]
|
264
|
+
}
|
265
|
+
|
266
|
+
cmd_brace_block: tLBRACE_ARG
|
267
|
+
{
|
268
|
+
self.env.extend(:dynamic)
|
269
|
+
result = self.lexer.lineno
|
270
|
+
}
|
271
|
+
opt_block_param
|
272
|
+
{
|
273
|
+
result = nil # self.env.dynamic.keys
|
274
|
+
}
|
275
|
+
compstmt tRCURLY
|
276
|
+
{
|
277
|
+
result = new_iter nil, val[2], val[4]
|
278
|
+
result.line = val[1]
|
279
|
+
|
280
|
+
self.env.unextend
|
281
|
+
}
|
282
|
+
|
283
|
+
fcall: operation
|
284
|
+
{
|
285
|
+
result = new_call nil, val[0].to_sym
|
286
|
+
}
|
287
|
+
|
288
|
+
command: fcall command_args =tLOWEST
|
289
|
+
{
|
290
|
+
result = val[0].concat val[1][1..-1] # REFACTOR pattern
|
291
|
+
}
|
292
|
+
| fcall command_args cmd_brace_block
|
293
|
+
{
|
294
|
+
result = val[0].concat val[1][1..-1]
|
295
|
+
if val[2] then
|
296
|
+
block_dup_check result, val[2]
|
297
|
+
|
298
|
+
result, operation = val[2], result
|
299
|
+
result.insert 1, operation
|
300
|
+
end
|
301
|
+
}
|
302
|
+
| primary_value call_op operation2 command_args =tLOWEST
|
303
|
+
{
|
304
|
+
result = new_call val[0], val[2].to_sym, val[3], val[1]
|
305
|
+
}
|
306
|
+
| primary_value call_op operation2 command_args cmd_brace_block
|
307
|
+
{
|
308
|
+
recv, _, msg, args, block = val
|
309
|
+
call = new_call recv, msg.to_sym, args, val[1]
|
310
|
+
|
311
|
+
block_dup_check call, block
|
312
|
+
|
313
|
+
block.insert 1, call
|
314
|
+
result = block
|
315
|
+
}
|
316
|
+
| primary_value tCOLON2 operation2 command_args =tLOWEST
|
317
|
+
{
|
318
|
+
result = new_call val[0], val[2].to_sym, val[3]
|
319
|
+
}
|
320
|
+
| primary_value tCOLON2 operation2 command_args cmd_brace_block
|
321
|
+
{
|
322
|
+
recv, _, msg, args, block = val
|
323
|
+
call = new_call recv, msg.to_sym, args
|
324
|
+
|
325
|
+
block_dup_check call, block
|
326
|
+
|
327
|
+
block.insert 1, call
|
328
|
+
result = block
|
329
|
+
}
|
330
|
+
| kSUPER command_args
|
331
|
+
{
|
332
|
+
result = new_super val[1]
|
333
|
+
}
|
334
|
+
| kYIELD command_args
|
335
|
+
{
|
336
|
+
result = new_yield val[1]
|
337
|
+
}
|
338
|
+
| kRETURN call_args
|
339
|
+
{
|
340
|
+
line = val[0].last
|
341
|
+
result = s(:return, ret_args(val[1])).line(line)
|
342
|
+
}
|
343
|
+
| kBREAK call_args
|
344
|
+
{
|
345
|
+
line = val[0].last
|
346
|
+
result = s(:break, ret_args(val[1])).line(line)
|
347
|
+
}
|
348
|
+
| kNEXT call_args
|
349
|
+
{
|
350
|
+
line = val[0].last
|
351
|
+
result = s(:next, ret_args(val[1])).line(line)
|
352
|
+
}
|
353
|
+
|
354
|
+
mlhs: mlhs_basic
|
355
|
+
| tLPAREN mlhs_inner rparen
|
356
|
+
{
|
357
|
+
result = val[1]
|
358
|
+
}
|
359
|
+
|
360
|
+
mlhs_inner: mlhs_basic
|
361
|
+
| tLPAREN mlhs_inner rparen
|
362
|
+
{
|
363
|
+
result = s(:masgn, s(:array, val[1]))
|
364
|
+
}
|
365
|
+
|
366
|
+
mlhs_basic: mlhs_head
|
367
|
+
{
|
368
|
+
result = s(:masgn, val[0])
|
369
|
+
}
|
370
|
+
| mlhs_head mlhs_item
|
371
|
+
{
|
372
|
+
result = s(:masgn, val[0] << val[1].compact)
|
373
|
+
}
|
374
|
+
| mlhs_head tSTAR mlhs_node
|
375
|
+
{
|
376
|
+
result = s(:masgn, val[0] << s(:splat, val[2]))
|
377
|
+
}
|
378
|
+
| mlhs_head tSTAR mlhs_node tCOMMA mlhs_post
|
379
|
+
{
|
380
|
+
ary1, _, splat, _, ary2 = val
|
381
|
+
|
382
|
+
result = list_append ary1, s(:splat, splat)
|
383
|
+
result.concat ary2[1..-1]
|
384
|
+
result = s(:masgn, result)
|
385
|
+
}
|
386
|
+
| mlhs_head tSTAR
|
387
|
+
{
|
388
|
+
result = s(:masgn, val[0] << s(:splat))
|
389
|
+
}
|
390
|
+
| mlhs_head tSTAR tCOMMA mlhs_post
|
391
|
+
{
|
392
|
+
ary = list_append val[0], s(:splat)
|
393
|
+
ary.concat val[3][1..-1]
|
394
|
+
result = s(:masgn, ary)
|
395
|
+
}
|
396
|
+
| tSTAR mlhs_node
|
397
|
+
{
|
398
|
+
result = s(:masgn, s(:array, s(:splat, val[1])))
|
399
|
+
}
|
400
|
+
| tSTAR mlhs_node tCOMMA mlhs_post
|
401
|
+
{
|
402
|
+
ary = s(:array, s(:splat, val[1]))
|
403
|
+
ary.concat val[3][1..-1]
|
404
|
+
result = s(:masgn, ary)
|
405
|
+
}
|
406
|
+
| tSTAR
|
407
|
+
{
|
408
|
+
result = s(:masgn, s(:array, s(:splat)))
|
409
|
+
}
|
410
|
+
| tSTAR tCOMMA mlhs_post
|
411
|
+
{
|
412
|
+
result = s(:masgn, s(:array, s(:splat), *val[2][1..-1]))
|
413
|
+
}
|
414
|
+
|
415
|
+
mlhs_item: mlhs_node
|
416
|
+
| tLPAREN mlhs_inner rparen
|
417
|
+
{
|
418
|
+
result = val[1]
|
419
|
+
}
|
420
|
+
|
421
|
+
mlhs_head: mlhs_item tCOMMA
|
422
|
+
{
|
423
|
+
result = s(:array, val[0])
|
424
|
+
}
|
425
|
+
| mlhs_head mlhs_item tCOMMA
|
426
|
+
{
|
427
|
+
result = val[0] << val[1].compact
|
428
|
+
}
|
429
|
+
|
430
|
+
mlhs_post: mlhs_item
|
431
|
+
{
|
432
|
+
result = s(:array, val[0])
|
433
|
+
}
|
434
|
+
| mlhs_post tCOMMA mlhs_item
|
435
|
+
{
|
436
|
+
result = list_append val[0], val[2]
|
437
|
+
}
|
438
|
+
|
439
|
+
mlhs_node: user_variable
|
440
|
+
{
|
441
|
+
result = self.assignable val[0]
|
442
|
+
}
|
443
|
+
| keyword_variable
|
444
|
+
{
|
445
|
+
result = self.assignable val[0]
|
446
|
+
}
|
447
|
+
| primary_value tLBRACK2 opt_call_args rbracket
|
448
|
+
{
|
449
|
+
result = self.aryset val[0], val[2]
|
450
|
+
}
|
451
|
+
| primary_value call_op tIDENTIFIER
|
452
|
+
{
|
453
|
+
result = new_attrasgn val[0], val[2], val[1]
|
454
|
+
}
|
455
|
+
| primary_value tCOLON2 tIDENTIFIER
|
456
|
+
{
|
457
|
+
result = s(:attrasgn, val[0], :"#{val[2]}=")
|
458
|
+
}
|
459
|
+
| primary_value call_op tCONSTANT
|
460
|
+
{
|
461
|
+
result = new_attrasgn val[0], val[2], val[1]
|
462
|
+
}
|
463
|
+
| primary_value tCOLON2 tCONSTANT
|
464
|
+
{
|
465
|
+
if (self.in_def || self.in_single > 0) then
|
466
|
+
debug20 7
|
467
|
+
yyerror "dynamic constant assignment"
|
468
|
+
end
|
469
|
+
|
470
|
+
result = s(:const, s(:colon2, val[0], val[2].to_sym), nil)
|
471
|
+
}
|
472
|
+
| tCOLON3 tCONSTANT
|
473
|
+
{
|
474
|
+
if (self.in_def || self.in_single > 0) then
|
475
|
+
debug20 8
|
476
|
+
yyerror "dynamic constant assignment"
|
477
|
+
end
|
478
|
+
|
479
|
+
result = s(:const, nil, s(:colon3, val[1].to_sym))
|
480
|
+
}
|
481
|
+
| backref
|
482
|
+
{
|
483
|
+
self.backref_assign_error val[0]
|
484
|
+
}
|
485
|
+
|
486
|
+
lhs: user_variable
|
487
|
+
{
|
488
|
+
result = self.assignable val[0]
|
489
|
+
}
|
490
|
+
| keyword_variable
|
491
|
+
{
|
492
|
+
result = self.assignable val[0]
|
493
|
+
debug20 9, val, result
|
494
|
+
}
|
495
|
+
| primary_value tLBRACK2 opt_call_args rbracket
|
496
|
+
{
|
497
|
+
result = self.aryset val[0], val[2]
|
498
|
+
}
|
499
|
+
| primary_value call_op tIDENTIFIER # REFACTOR
|
500
|
+
{
|
501
|
+
result = new_attrasgn val[0], val[2], val[1]
|
502
|
+
}
|
503
|
+
| primary_value tCOLON2 tIDENTIFIER
|
504
|
+
{
|
505
|
+
result = s(:attrasgn, val[0], :"#{val[2]}=")
|
506
|
+
}
|
507
|
+
| primary_value call_op tCONSTANT # REFACTOR?
|
508
|
+
{
|
509
|
+
result = new_attrasgn val[0], val[2], val[1]
|
510
|
+
}
|
511
|
+
| primary_value tCOLON2 tCONSTANT
|
512
|
+
{
|
513
|
+
if (self.in_def || self.in_single > 0) then
|
514
|
+
debug20 10
|
515
|
+
yyerror "dynamic constant assignment"
|
516
|
+
end
|
517
|
+
|
518
|
+
result = s(:const, s(:colon2, val[0], val[2].to_sym))
|
519
|
+
}
|
520
|
+
| tCOLON3 tCONSTANT
|
521
|
+
{
|
522
|
+
if (self.in_def || self.in_single > 0) then
|
523
|
+
debug20 11
|
524
|
+
yyerror "dynamic constant assignment"
|
525
|
+
end
|
526
|
+
|
527
|
+
result = s(:const, s(:colon3, val[1].to_sym))
|
528
|
+
}
|
529
|
+
| backref
|
530
|
+
{
|
531
|
+
self.backref_assign_error val[0]
|
532
|
+
}
|
533
|
+
|
534
|
+
cname: tIDENTIFIER
|
535
|
+
{
|
536
|
+
yyerror "class/module name must be CONSTANT"
|
537
|
+
}
|
538
|
+
| tCONSTANT
|
539
|
+
|
540
|
+
cpath: tCOLON3 cname
|
541
|
+
{
|
542
|
+
result = s(:colon3, val[1].to_sym)
|
543
|
+
}
|
544
|
+
| cname
|
545
|
+
{
|
546
|
+
result = val[0].to_sym
|
547
|
+
}
|
548
|
+
| primary_value tCOLON2 cname
|
549
|
+
{
|
550
|
+
result = s(:colon2, val[0], val[2].to_sym)
|
551
|
+
}
|
552
|
+
|
553
|
+
fname: tIDENTIFIER | tCONSTANT | tFID
|
554
|
+
| op
|
555
|
+
{
|
556
|
+
lexer.lex_state = :expr_end
|
557
|
+
result = val[0]
|
558
|
+
}
|
559
|
+
|
560
|
+
| reswords
|
561
|
+
{
|
562
|
+
lexer.lex_state = :expr_end
|
563
|
+
result = val[0]
|
564
|
+
}
|
565
|
+
|
566
|
+
fsym: fname | symbol
|
567
|
+
|
568
|
+
fitem: fsym
|
569
|
+
{
|
570
|
+
result = s(:lit, val[0].to_sym)
|
571
|
+
}
|
572
|
+
| dsym
|
573
|
+
|
574
|
+
undef_list: fitem
|
575
|
+
{
|
576
|
+
result = new_undef val[0]
|
577
|
+
}
|
578
|
+
|
|
579
|
+
undef_list tCOMMA
|
580
|
+
{
|
581
|
+
lexer.lex_state = :expr_fname
|
582
|
+
}
|
583
|
+
fitem
|
584
|
+
{
|
585
|
+
result = new_undef val[0], val[3]
|
586
|
+
}
|
587
|
+
|
588
|
+
op: tPIPE | tCARET | tAMPER2 | tCMP | tEQ | tEQQ
|
589
|
+
| tMATCH | tNMATCH | tGT | tGEQ | tLT | tLEQ
|
590
|
+
| tNEQ | tLSHFT | tRSHFT | tPLUS | tMINUS | tSTAR2
|
591
|
+
| tSTAR | tDIVIDE | tPERCENT | tPOW | tDSTAR | tBANG | tTILDE
|
592
|
+
| tUPLUS | tUMINUS | tAREF | tASET | tBACK_REF2
|
593
|
+
|
594
|
+
reswords: k__LINE__ | k__FILE__ | k__ENCODING__ | klBEGIN | klEND
|
595
|
+
| kALIAS | kAND | kBEGIN | kBREAK | kCASE
|
596
|
+
| kCLASS | kDEF | kDEFINED | kDO | kELSE
|
597
|
+
| kELSIF | kEND | kENSURE | kFALSE | kFOR
|
598
|
+
| kIN | kMODULE | kNEXT | kNIL | kNOT
|
599
|
+
| kOR | kREDO | kRESCUE | kRETRY | kRETURN
|
600
|
+
| kSELF | kSUPER | kTHEN | kTRUE | kUNDEF
|
601
|
+
| kWHEN | kYIELD | kIF | kUNLESS | kWHILE
|
602
|
+
| kUNTIL
|
603
|
+
|
604
|
+
arg: lhs tEQL arg
|
605
|
+
{
|
606
|
+
result = new_assign val[0], val[2]
|
607
|
+
}
|
608
|
+
| lhs tEQL arg kRESCUE_MOD arg
|
609
|
+
{
|
610
|
+
result = new_assign val[0], s(:rescue, val[2], new_resbody(s(:array), val[4]))
|
611
|
+
}
|
612
|
+
| var_lhs tOP_ASGN arg
|
613
|
+
{
|
614
|
+
result = new_op_asgn val
|
615
|
+
}
|
616
|
+
| var_lhs tOP_ASGN arg kRESCUE_MOD arg
|
617
|
+
{
|
618
|
+
result = new_op_asgn val
|
619
|
+
result = s(:rescue, result, new_resbody(s(:array), val[4]))
|
620
|
+
}
|
621
|
+
| primary_value tLBRACK2 opt_call_args rbracket tOP_ASGN arg
|
622
|
+
{
|
623
|
+
val[2][0] = :arglist if val[2]
|
624
|
+
result = s(:op_asgn1, val[0], val[2], val[4].to_sym, val[5])
|
625
|
+
}
|
626
|
+
| primary_value call_op tIDENTIFIER tOP_ASGN arg
|
627
|
+
{
|
628
|
+
result = new_op_asgn2 val
|
629
|
+
}
|
630
|
+
| primary_value call_op tCONSTANT tOP_ASGN arg
|
631
|
+
{
|
632
|
+
result = new_op_asgn2 val
|
633
|
+
}
|
634
|
+
| primary_value tCOLON2 tIDENTIFIER tOP_ASGN arg
|
635
|
+
{
|
636
|
+
result = s(:op_asgn, val[0], val[4], val[2].to_sym, val[3].to_sym)
|
637
|
+
}
|
638
|
+
| primary_value tCOLON2 tCONSTANT tOP_ASGN arg
|
639
|
+
{
|
640
|
+
yyerror "constant re-assignment"
|
641
|
+
}
|
642
|
+
| tCOLON3 tCONSTANT tOP_ASGN arg
|
643
|
+
{
|
644
|
+
yyerror "constant re-assignment"
|
645
|
+
}
|
646
|
+
| backref tOP_ASGN arg
|
647
|
+
{
|
648
|
+
self.backref_assign_error val[0]
|
649
|
+
}
|
650
|
+
| arg tDOT2 arg
|
651
|
+
{
|
652
|
+
v1, v2 = val[0], val[2]
|
653
|
+
if v1.node_type == :lit and v2.node_type == :lit and Integer === v1.last and Integer === v2.last then
|
654
|
+
result = s(:lit, (v1.last)..(v2.last))
|
655
|
+
else
|
656
|
+
result = s(:dot2, v1, v2)
|
657
|
+
end
|
658
|
+
}
|
659
|
+
| arg tDOT3 arg
|
660
|
+
{
|
661
|
+
v1, v2 = val[0], val[2]
|
662
|
+
if v1.node_type == :lit and v2.node_type == :lit and Integer === v1.last and Integer === v2.last then
|
663
|
+
result = s(:lit, (v1.last)...(v2.last))
|
664
|
+
else
|
665
|
+
result = s(:dot3, v1, v2)
|
666
|
+
end
|
667
|
+
}
|
668
|
+
| arg tPLUS arg
|
669
|
+
{
|
670
|
+
result = new_call val[0], :+, argl(val[2])
|
671
|
+
}
|
672
|
+
| arg tMINUS arg
|
673
|
+
{
|
674
|
+
result = new_call val[0], :-, argl(val[2])
|
675
|
+
}
|
676
|
+
| arg tSTAR2 arg # TODO: rename
|
677
|
+
{
|
678
|
+
result = new_call val[0], :*, argl(val[2])
|
679
|
+
}
|
680
|
+
| arg tDIVIDE arg
|
681
|
+
{
|
682
|
+
result = new_call val[0], :"/", argl(val[2])
|
683
|
+
}
|
684
|
+
| arg tPERCENT arg
|
685
|
+
{
|
686
|
+
result = new_call val[0], :"%", argl(val[2])
|
687
|
+
}
|
688
|
+
| arg tPOW arg
|
689
|
+
{
|
690
|
+
result = new_call val[0], :**, argl(val[2])
|
691
|
+
}
|
692
|
+
| tUMINUS_NUM simple_numeric tPOW arg
|
693
|
+
{
|
694
|
+
result = new_call(new_call(s(:lit, val[1]), :"**", argl(val[3])), :"-@")
|
695
|
+
}
|
696
|
+
| tUPLUS arg
|
697
|
+
{
|
698
|
+
result = new_call val[1], :"+@"
|
699
|
+
}
|
700
|
+
| tUMINUS arg
|
701
|
+
{
|
702
|
+
result = new_call val[1], :"-@"
|
703
|
+
}
|
704
|
+
| arg tPIPE arg
|
705
|
+
{
|
706
|
+
result = new_call val[0], :"|", argl(val[2])
|
707
|
+
}
|
708
|
+
| arg tCARET arg
|
709
|
+
{
|
710
|
+
result = new_call val[0], :"^", argl(val[2])
|
711
|
+
}
|
712
|
+
| arg tAMPER2 arg
|
713
|
+
{
|
714
|
+
result = new_call val[0], :"&", argl(val[2])
|
715
|
+
}
|
716
|
+
| arg tCMP arg
|
717
|
+
{
|
718
|
+
result = new_call val[0], :"<=>", argl(val[2])
|
719
|
+
}
|
720
|
+
| arg tGT arg
|
721
|
+
{
|
722
|
+
result = new_call val[0], :">", argl(val[2])
|
723
|
+
}
|
724
|
+
| arg tGEQ arg
|
725
|
+
{
|
726
|
+
result = new_call val[0], :">=", argl(val[2])
|
727
|
+
}
|
728
|
+
| arg tLT arg
|
729
|
+
{
|
730
|
+
result = new_call val[0], :"<", argl(val[2])
|
731
|
+
}
|
732
|
+
| arg tLEQ arg
|
733
|
+
{
|
734
|
+
result = new_call val[0], :"<=", argl(val[2])
|
735
|
+
}
|
736
|
+
| arg tEQ arg
|
737
|
+
{
|
738
|
+
result = new_call val[0], :"==", argl(val[2])
|
739
|
+
}
|
740
|
+
| arg tEQQ arg
|
741
|
+
{
|
742
|
+
result = new_call val[0], :"===", argl(val[2])
|
743
|
+
}
|
744
|
+
| arg tNEQ arg
|
745
|
+
{
|
746
|
+
result = new_call val[0], :"!=", argl(val[2])
|
747
|
+
}
|
748
|
+
| arg tMATCH arg
|
749
|
+
{
|
750
|
+
result = new_match val[0], val[2]
|
751
|
+
}
|
752
|
+
| arg tNMATCH arg
|
753
|
+
{
|
754
|
+
result = s(:not, new_match(val[0], val[2]))
|
755
|
+
}
|
756
|
+
| tBANG arg
|
757
|
+
{
|
758
|
+
result = new_call val[1], :"!"
|
759
|
+
}
|
760
|
+
| tTILDE arg
|
761
|
+
{
|
762
|
+
result = new_call value_expr(val[1]), :"~"
|
763
|
+
}
|
764
|
+
| arg tLSHFT arg
|
765
|
+
{
|
766
|
+
val[0] = value_expr val[0]
|
767
|
+
val[2] = value_expr val[2]
|
768
|
+
result = new_call val[0], :"\<\<", argl(val[2])
|
769
|
+
}
|
770
|
+
| arg tRSHFT arg
|
771
|
+
{
|
772
|
+
val[0] = value_expr val[0]
|
773
|
+
val[2] = value_expr val[2]
|
774
|
+
result = new_call val[0], :">>", argl(val[2])
|
775
|
+
}
|
776
|
+
| arg tANDOP arg
|
777
|
+
{
|
778
|
+
result = logical_op :and, val[0], val[2]
|
779
|
+
}
|
780
|
+
| arg tOROP arg
|
781
|
+
{
|
782
|
+
result = logical_op :or, val[0], val[2]
|
783
|
+
}
|
784
|
+
| kDEFINED opt_nl arg
|
785
|
+
{
|
786
|
+
result = s(:defined, val[2])
|
787
|
+
}
|
788
|
+
| arg tEH arg opt_nl tCOLON arg
|
789
|
+
{
|
790
|
+
result = s(:if, val[0], val[2], val[5])
|
791
|
+
}
|
792
|
+
| primary
|
793
|
+
|
794
|
+
arg_value: arg
|
795
|
+
{
|
796
|
+
result = value_expr(val[0])
|
797
|
+
}
|
798
|
+
|
799
|
+
aref_args: none
|
800
|
+
| args trailer
|
801
|
+
{
|
802
|
+
result = args [val[0]]
|
803
|
+
}
|
804
|
+
| args tCOMMA assocs trailer
|
805
|
+
{
|
806
|
+
result = args [val[0], array_to_hash(val[2])]
|
807
|
+
}
|
808
|
+
| assocs trailer
|
809
|
+
{
|
810
|
+
result = args [array_to_hash(val[0])]
|
811
|
+
}
|
812
|
+
|
813
|
+
paren_args: tLPAREN2 opt_call_args rparen
|
814
|
+
{
|
815
|
+
result = val[1]
|
816
|
+
}
|
817
|
+
|
818
|
+
opt_paren_args: none
|
819
|
+
| paren_args
|
820
|
+
|
821
|
+
opt_call_args: none
|
822
|
+
{
|
823
|
+
result = val[0]
|
824
|
+
}
|
825
|
+
| call_args
|
826
|
+
{
|
827
|
+
result = val[0]
|
828
|
+
}
|
829
|
+
| args tCOMMA
|
830
|
+
{
|
831
|
+
result = args val
|
832
|
+
}
|
833
|
+
| args tCOMMA assocs tCOMMA
|
834
|
+
{
|
835
|
+
result = args [val[0], array_to_hash(val[2])]
|
836
|
+
}
|
837
|
+
| assocs tCOMMA
|
838
|
+
{
|
839
|
+
result = args [array_to_hash(val[0])]
|
840
|
+
}
|
841
|
+
|
842
|
+
call_args: command
|
843
|
+
{
|
844
|
+
warning "parenthesize argument(s) for future version"
|
845
|
+
result = call_args val
|
846
|
+
}
|
847
|
+
| args opt_block_arg
|
848
|
+
{
|
849
|
+
result = call_args val
|
850
|
+
result = self.arg_blk_pass val[0], val[1]
|
851
|
+
}
|
852
|
+
| assocs opt_block_arg
|
853
|
+
{
|
854
|
+
result = call_args [array_to_hash(val[0])]
|
855
|
+
result = self.arg_blk_pass result, val[1]
|
856
|
+
}
|
857
|
+
| args tCOMMA assocs opt_block_arg
|
858
|
+
{
|
859
|
+
result = call_args [val[0], array_to_hash(val[2])]
|
860
|
+
result = self.arg_blk_pass result, val[3]
|
861
|
+
}
|
862
|
+
| block_arg
|
863
|
+
{
|
864
|
+
result = call_args val
|
865
|
+
}
|
866
|
+
|
867
|
+
command_args: {
|
868
|
+
result = lexer.cmdarg.stack.dup # TODO: smell?
|
869
|
+
lexer.cmdarg.push true
|
870
|
+
}
|
871
|
+
call_args
|
872
|
+
{
|
873
|
+
lexer.cmdarg.stack.replace val[0]
|
874
|
+
result = val[1]
|
875
|
+
}
|
876
|
+
|
877
|
+
block_arg: tAMPER arg_value
|
878
|
+
{
|
879
|
+
result = s(:block_pass, val[1])
|
880
|
+
}
|
881
|
+
|
882
|
+
opt_block_arg: tCOMMA block_arg
|
883
|
+
{
|
884
|
+
result = val[1]
|
885
|
+
}
|
886
|
+
| none
|
887
|
+
|
888
|
+
args: arg_value
|
889
|
+
{
|
890
|
+
result = s(:array, val[0])
|
891
|
+
}
|
892
|
+
| tSTAR arg_value
|
893
|
+
{
|
894
|
+
result = s(:array, s(:splat, val[1]))
|
895
|
+
}
|
896
|
+
| args tCOMMA arg_value
|
897
|
+
{
|
898
|
+
result = self.list_append val[0], val[2]
|
899
|
+
}
|
900
|
+
| args tCOMMA tSTAR arg_value
|
901
|
+
{
|
902
|
+
result = self.list_append val[0], s(:splat, val[3])
|
903
|
+
}
|
904
|
+
|
905
|
+
mrhs_arg: mrhs
|
906
|
+
{
|
907
|
+
result = new_masgn_arg val[0]
|
908
|
+
}
|
909
|
+
| arg_value
|
910
|
+
{
|
911
|
+
result = new_masgn_arg val[0], :wrap
|
912
|
+
}
|
913
|
+
|
914
|
+
mrhs: args tCOMMA arg_value
|
915
|
+
{
|
916
|
+
result = val[0] << val[2]
|
917
|
+
}
|
918
|
+
| args tCOMMA tSTAR arg_value
|
919
|
+
{
|
920
|
+
result = self.arg_concat val[0], val[3]
|
921
|
+
}
|
922
|
+
| tSTAR arg_value
|
923
|
+
{
|
924
|
+
result = s(:splat, val[1])
|
925
|
+
}
|
926
|
+
|
927
|
+
primary: literal
|
928
|
+
| strings
|
929
|
+
| xstring
|
930
|
+
| regexp
|
931
|
+
| words
|
932
|
+
| qwords
|
933
|
+
| symbols
|
934
|
+
| qsymbols
|
935
|
+
| var_ref
|
936
|
+
| backref
|
937
|
+
| tFID
|
938
|
+
{
|
939
|
+
result = new_call nil, val[0].to_sym
|
940
|
+
}
|
941
|
+
| kBEGIN
|
942
|
+
{
|
943
|
+
result = self.lexer.lineno
|
944
|
+
}
|
945
|
+
bodystmt kEND
|
946
|
+
{
|
947
|
+
unless val[2] then
|
948
|
+
result = s(:nil)
|
949
|
+
else
|
950
|
+
result = s(:begin, val[2])
|
951
|
+
end
|
952
|
+
|
953
|
+
result.line = val[1]
|
954
|
+
}
|
955
|
+
| tLPAREN_ARG rparen
|
956
|
+
{
|
957
|
+
debug20 13, val, result
|
958
|
+
}
|
959
|
+
| tLPAREN_ARG expr
|
960
|
+
{
|
961
|
+
lexer.lex_state = :expr_endarg
|
962
|
+
}
|
963
|
+
rparen
|
964
|
+
{
|
965
|
+
warning "(...) interpreted as grouped expression"
|
966
|
+
result = val[1]
|
967
|
+
}
|
968
|
+
| tLPAREN compstmt tRPAREN
|
969
|
+
{
|
970
|
+
result = val[1] || s(:nil)
|
971
|
+
result.paren = true
|
972
|
+
}
|
973
|
+
| primary_value tCOLON2 tCONSTANT
|
974
|
+
{
|
975
|
+
result = s(:colon2, val[0], val[2].to_sym)
|
976
|
+
}
|
977
|
+
| tCOLON3 tCONSTANT
|
978
|
+
{
|
979
|
+
result = s(:colon3, val[1].to_sym)
|
980
|
+
}
|
981
|
+
| tLBRACK aref_args tRBRACK
|
982
|
+
{
|
983
|
+
result = val[1] || s(:array)
|
984
|
+
result[0] = :array # aref_args is :args
|
985
|
+
}
|
986
|
+
| tLBRACE assoc_list tRCURLY
|
987
|
+
{
|
988
|
+
result = s(:hash, *val[1].values) # TODO: array_to_hash?
|
989
|
+
}
|
990
|
+
| kRETURN
|
991
|
+
{
|
992
|
+
result = s(:return)
|
993
|
+
}
|
994
|
+
| kYIELD tLPAREN2 call_args rparen
|
995
|
+
{
|
996
|
+
result = new_yield val[2]
|
997
|
+
}
|
998
|
+
| kYIELD tLPAREN2 rparen
|
999
|
+
{
|
1000
|
+
result = new_yield
|
1001
|
+
}
|
1002
|
+
| kYIELD
|
1003
|
+
{
|
1004
|
+
result = new_yield
|
1005
|
+
}
|
1006
|
+
| kDEFINED opt_nl tLPAREN2 expr rparen
|
1007
|
+
{
|
1008
|
+
result = s(:defined, val[3])
|
1009
|
+
}
|
1010
|
+
| kNOT tLPAREN2 expr rparen
|
1011
|
+
{
|
1012
|
+
result = s(:call, val[2], :"!")
|
1013
|
+
}
|
1014
|
+
| kNOT tLPAREN2 rparen
|
1015
|
+
{
|
1016
|
+
debug20 14, val, result
|
1017
|
+
}
|
1018
|
+
| fcall brace_block
|
1019
|
+
{
|
1020
|
+
oper, iter = val[0], val[1]
|
1021
|
+
call = oper # FIX
|
1022
|
+
iter.insert 1, call
|
1023
|
+
result = iter
|
1024
|
+
call.line = iter.line
|
1025
|
+
}
|
1026
|
+
| method_call
|
1027
|
+
| method_call brace_block
|
1028
|
+
{
|
1029
|
+
call, iter = val[0], val[1]
|
1030
|
+
block_dup_check call, iter
|
1031
|
+
iter.insert 1, call # FIX
|
1032
|
+
result = iter
|
1033
|
+
}
|
1034
|
+
| tLAMBDA lambda
|
1035
|
+
{
|
1036
|
+
result = val[1] # TODO: fix lineno
|
1037
|
+
}
|
1038
|
+
| kIF expr_value then compstmt if_tail kEND
|
1039
|
+
{
|
1040
|
+
result = new_if val[1], val[3], val[4]
|
1041
|
+
}
|
1042
|
+
| kUNLESS expr_value then compstmt opt_else kEND
|
1043
|
+
{
|
1044
|
+
result = new_if val[1], val[4], val[3]
|
1045
|
+
}
|
1046
|
+
| kWHILE
|
1047
|
+
{
|
1048
|
+
lexer.cond.push true
|
1049
|
+
}
|
1050
|
+
expr_value do
|
1051
|
+
{
|
1052
|
+
lexer.cond.pop
|
1053
|
+
}
|
1054
|
+
compstmt kEND
|
1055
|
+
{
|
1056
|
+
result = new_while val[5], val[2], true
|
1057
|
+
}
|
1058
|
+
| kUNTIL
|
1059
|
+
{
|
1060
|
+
lexer.cond.push true
|
1061
|
+
}
|
1062
|
+
expr_value do
|
1063
|
+
{
|
1064
|
+
lexer.cond.pop
|
1065
|
+
}
|
1066
|
+
compstmt kEND
|
1067
|
+
{
|
1068
|
+
result = new_until val[5], val[2], true
|
1069
|
+
}
|
1070
|
+
| kCASE expr_value opt_terms case_body kEND
|
1071
|
+
{
|
1072
|
+
(_, line), expr, _, body, _ = val
|
1073
|
+
result = new_case expr, body, line
|
1074
|
+
}
|
1075
|
+
| kCASE opt_terms case_body kEND
|
1076
|
+
{
|
1077
|
+
(_, line), _, body, _ = val
|
1078
|
+
result = new_case nil, body, line
|
1079
|
+
}
|
1080
|
+
| kFOR for_var kIN
|
1081
|
+
{
|
1082
|
+
lexer.cond.push true
|
1083
|
+
}
|
1084
|
+
expr_value do
|
1085
|
+
{
|
1086
|
+
lexer.cond.pop
|
1087
|
+
}
|
1088
|
+
compstmt kEND
|
1089
|
+
{
|
1090
|
+
result = new_for val[4], val[1], val[7]
|
1091
|
+
}
|
1092
|
+
| kCLASS
|
1093
|
+
{
|
1094
|
+
result = self.lexer.lineno
|
1095
|
+
}
|
1096
|
+
cpath superclass
|
1097
|
+
{
|
1098
|
+
self.comments.push self.lexer.comments
|
1099
|
+
if (self.in_def || self.in_single > 0) then
|
1100
|
+
yyerror "class definition in method body"
|
1101
|
+
end
|
1102
|
+
self.env.extend
|
1103
|
+
}
|
1104
|
+
bodystmt kEND
|
1105
|
+
{
|
1106
|
+
result = new_class val
|
1107
|
+
self.env.unextend
|
1108
|
+
self.lexer.comments # we don't care about comments in the body
|
1109
|
+
}
|
1110
|
+
| kCLASS tLSHFT
|
1111
|
+
{
|
1112
|
+
result = self.lexer.lineno
|
1113
|
+
}
|
1114
|
+
expr
|
1115
|
+
{
|
1116
|
+
result = self.in_def
|
1117
|
+
self.in_def = false
|
1118
|
+
}
|
1119
|
+
term
|
1120
|
+
{
|
1121
|
+
result = self.in_single
|
1122
|
+
self.in_single = 0
|
1123
|
+
self.env.extend
|
1124
|
+
}
|
1125
|
+
bodystmt kEND
|
1126
|
+
{
|
1127
|
+
result = new_sclass val
|
1128
|
+
self.env.unextend
|
1129
|
+
self.lexer.comments # we don't care about comments in the body
|
1130
|
+
}
|
1131
|
+
| kMODULE
|
1132
|
+
{
|
1133
|
+
result = self.lexer.lineno
|
1134
|
+
}
|
1135
|
+
cpath
|
1136
|
+
{
|
1137
|
+
self.comments.push self.lexer.comments
|
1138
|
+
yyerror "module definition in method body" if
|
1139
|
+
self.in_def or self.in_single > 0
|
1140
|
+
|
1141
|
+
self.env.extend
|
1142
|
+
}
|
1143
|
+
bodystmt kEND
|
1144
|
+
{
|
1145
|
+
result = new_module val
|
1146
|
+
self.env.unextend
|
1147
|
+
self.lexer.comments # we don't care about comments in the body
|
1148
|
+
}
|
1149
|
+
| kDEF fname
|
1150
|
+
{
|
1151
|
+
result = [self.in_def, self.lexer.cmdarg.stack.dup]
|
1152
|
+
|
1153
|
+
self.comments.push self.lexer.comments
|
1154
|
+
self.in_def = true
|
1155
|
+
self.env.extend
|
1156
|
+
# TODO: local->cmdargs = cmdarg_stack;
|
1157
|
+
# TODO: port local_push_gen and local_pop_gen
|
1158
|
+
lexer.cmdarg.stack.replace [false]
|
1159
|
+
}
|
1160
|
+
f_arglist bodystmt kEND
|
1161
|
+
{
|
1162
|
+
in_def, cmdarg = val[2]
|
1163
|
+
|
1164
|
+
result = new_defn val
|
1165
|
+
|
1166
|
+
lexer.cmdarg.stack.replace cmdarg
|
1167
|
+
self.env.unextend
|
1168
|
+
self.in_def = in_def
|
1169
|
+
self.lexer.comments # we don't care about comments in the body
|
1170
|
+
}
|
1171
|
+
| kDEF singleton dot_or_colon
|
1172
|
+
{
|
1173
|
+
self.comments.push self.lexer.comments
|
1174
|
+
lexer.lex_state = :expr_fname
|
1175
|
+
}
|
1176
|
+
fname
|
1177
|
+
{
|
1178
|
+
self.in_single += 1
|
1179
|
+
self.env.extend
|
1180
|
+
lexer.lex_state = :expr_endfn # force for args
|
1181
|
+
result = lexer.lineno
|
1182
|
+
}
|
1183
|
+
f_arglist bodystmt kEND
|
1184
|
+
{
|
1185
|
+
result = new_defs val
|
1186
|
+
result[3].line val[5]
|
1187
|
+
|
1188
|
+
self.env.unextend
|
1189
|
+
self.in_single -= 1
|
1190
|
+
self.lexer.comments # we don't care about comments in the body
|
1191
|
+
}
|
1192
|
+
| kBREAK
|
1193
|
+
{
|
1194
|
+
result = s(:break)
|
1195
|
+
}
|
1196
|
+
| kNEXT
|
1197
|
+
{
|
1198
|
+
result = s(:next)
|
1199
|
+
}
|
1200
|
+
| kREDO
|
1201
|
+
{
|
1202
|
+
result = s(:redo)
|
1203
|
+
}
|
1204
|
+
| kRETRY
|
1205
|
+
{
|
1206
|
+
result = s(:retry)
|
1207
|
+
}
|
1208
|
+
|
1209
|
+
primary_value: primary
|
1210
|
+
{
|
1211
|
+
result = value_expr(val[0])
|
1212
|
+
}
|
1213
|
+
|
1214
|
+
# These are really stupid
|
1215
|
+
k_begin: kBEGIN
|
1216
|
+
k_if: kIF
|
1217
|
+
k_unless: kUNLESS
|
1218
|
+
k_while: kWHILE
|
1219
|
+
k_until: kUNTIL
|
1220
|
+
k_case: kCASE
|
1221
|
+
k_for: kFOR
|
1222
|
+
k_class: kCLASS
|
1223
|
+
k_module: kMODULE
|
1224
|
+
k_def: kDEF
|
1225
|
+
k_end: kEND
|
1226
|
+
|
1227
|
+
then: term
|
1228
|
+
| kTHEN
|
1229
|
+
| term kTHEN
|
1230
|
+
|
1231
|
+
do: term
|
1232
|
+
| kDO_COND
|
1233
|
+
|
1234
|
+
if_tail: opt_else
|
1235
|
+
| kELSIF expr_value then compstmt if_tail
|
1236
|
+
{
|
1237
|
+
result = s(:if, val[1], val[3], val[4])
|
1238
|
+
}
|
1239
|
+
|
1240
|
+
opt_else: none
|
1241
|
+
| kELSE compstmt
|
1242
|
+
{
|
1243
|
+
result = val[1]
|
1244
|
+
}
|
1245
|
+
|
1246
|
+
for_var: lhs
|
1247
|
+
| mlhs
|
1248
|
+
{
|
1249
|
+
val[0].delete_at 1 if val[0][1].nil? # HACK
|
1250
|
+
}
|
1251
|
+
|
1252
|
+
f_marg: f_norm_arg
|
1253
|
+
| tLPAREN f_margs rparen
|
1254
|
+
{
|
1255
|
+
result = val[1]
|
1256
|
+
}
|
1257
|
+
|
1258
|
+
f_marg_list: f_marg
|
1259
|
+
{
|
1260
|
+
result = s(:array, val[0])
|
1261
|
+
}
|
1262
|
+
| f_marg_list tCOMMA f_marg
|
1263
|
+
{
|
1264
|
+
result = list_append val[0], val[2]
|
1265
|
+
}
|
1266
|
+
|
1267
|
+
f_margs: f_marg_list
|
1268
|
+
{
|
1269
|
+
args, = val
|
1270
|
+
|
1271
|
+
result = block_var args
|
1272
|
+
}
|
1273
|
+
| f_marg_list tCOMMA tSTAR f_norm_arg
|
1274
|
+
{
|
1275
|
+
args, _, _, splat = val
|
1276
|
+
|
1277
|
+
result = block_var args, "*#{splat}".to_sym
|
1278
|
+
}
|
1279
|
+
| f_marg_list tCOMMA tSTAR f_norm_arg tCOMMA f_marg_list
|
1280
|
+
{
|
1281
|
+
args, _, _, splat, _, args2 = val
|
1282
|
+
|
1283
|
+
result = block_var args, "*#{splat}".to_sym, args2
|
1284
|
+
}
|
1285
|
+
| f_marg_list tCOMMA tSTAR
|
1286
|
+
{
|
1287
|
+
args, _, _ = val
|
1288
|
+
|
1289
|
+
result = block_var args, :*
|
1290
|
+
}
|
1291
|
+
| f_marg_list tCOMMA tSTAR tCOMMA f_marg_list
|
1292
|
+
{
|
1293
|
+
args, _, _, _, args2 = val
|
1294
|
+
|
1295
|
+
result = block_var args, :*, args2
|
1296
|
+
}
|
1297
|
+
| tSTAR f_norm_arg
|
1298
|
+
{
|
1299
|
+
_, splat = val
|
1300
|
+
|
1301
|
+
result = block_var :"*#{splat}"
|
1302
|
+
}
|
1303
|
+
| tSTAR f_norm_arg tCOMMA f_marg_list
|
1304
|
+
{
|
1305
|
+
_, splat, _, args = val
|
1306
|
+
|
1307
|
+
result = block_var :"*#{splat}", args
|
1308
|
+
}
|
1309
|
+
| tSTAR
|
1310
|
+
{
|
1311
|
+
result = block_var :*
|
1312
|
+
}
|
1313
|
+
| tSTAR tCOMMA f_marg_list
|
1314
|
+
{
|
1315
|
+
_, _, args = val
|
1316
|
+
|
1317
|
+
result = block_var :*, args
|
1318
|
+
}
|
1319
|
+
|
1320
|
+
block_args_tail: f_block_kwarg tCOMMA f_kwrest opt_f_block_arg
|
1321
|
+
{
|
1322
|
+
result = call_args val
|
1323
|
+
}
|
1324
|
+
| f_block_kwarg opt_f_block_arg
|
1325
|
+
{
|
1326
|
+
result = call_args val
|
1327
|
+
}
|
1328
|
+
| f_kwrest opt_f_block_arg
|
1329
|
+
{
|
1330
|
+
result = call_args val
|
1331
|
+
}
|
1332
|
+
| f_block_arg
|
1333
|
+
{
|
1334
|
+
result = call_args val
|
1335
|
+
}
|
1336
|
+
|
1337
|
+
opt_block_args_tail: tCOMMA block_args_tail
|
1338
|
+
{
|
1339
|
+
result = args val
|
1340
|
+
}
|
1341
|
+
| none
|
1342
|
+
|
1343
|
+
block_param: f_arg tCOMMA f_block_optarg tCOMMA f_rest_arg opt_block_args_tail
|
1344
|
+
{
|
1345
|
+
result = args val
|
1346
|
+
}
|
1347
|
+
| f_arg tCOMMA f_block_optarg tCOMMA f_rest_arg tCOMMA f_arg opt_block_args_tail
|
1348
|
+
{
|
1349
|
+
result = args val
|
1350
|
+
}
|
1351
|
+
| f_arg tCOMMA f_block_optarg opt_block_args_tail
|
1352
|
+
{
|
1353
|
+
result = args val
|
1354
|
+
}
|
1355
|
+
| f_arg tCOMMA f_block_optarg tCOMMA f_arg opt_block_args_tail
|
1356
|
+
{
|
1357
|
+
result = args val
|
1358
|
+
}
|
1359
|
+
| f_arg tCOMMA f_rest_arg opt_block_args_tail
|
1360
|
+
{
|
1361
|
+
result = args val
|
1362
|
+
}
|
1363
|
+
| f_arg tCOMMA
|
1364
|
+
{
|
1365
|
+
result = args val
|
1366
|
+
}
|
1367
|
+
| f_arg tCOMMA f_rest_arg tCOMMA f_arg opt_block_args_tail
|
1368
|
+
{
|
1369
|
+
result = args val
|
1370
|
+
}
|
1371
|
+
| f_arg opt_block_args_tail
|
1372
|
+
{
|
1373
|
+
result = args val
|
1374
|
+
}
|
1375
|
+
| f_block_optarg tCOMMA f_rest_arg opt_block_args_tail
|
1376
|
+
{
|
1377
|
+
result = args val
|
1378
|
+
}
|
1379
|
+
| f_block_optarg tCOMMA f_rest_arg tCOMMA f_arg opt_block_args_tail
|
1380
|
+
{
|
1381
|
+
result = args val
|
1382
|
+
}
|
1383
|
+
| f_block_optarg opt_block_args_tail
|
1384
|
+
{
|
1385
|
+
result = args val
|
1386
|
+
}
|
1387
|
+
| f_block_optarg tCOMMA f_arg opt_block_args_tail
|
1388
|
+
{
|
1389
|
+
result = args val
|
1390
|
+
}
|
1391
|
+
| f_rest_arg opt_block_args_tail
|
1392
|
+
{
|
1393
|
+
result = args val
|
1394
|
+
}
|
1395
|
+
| f_rest_arg tCOMMA f_arg opt_block_args_tail
|
1396
|
+
{
|
1397
|
+
result = args val
|
1398
|
+
}
|
1399
|
+
| block_args_tail
|
1400
|
+
{
|
1401
|
+
result = args val
|
1402
|
+
}
|
1403
|
+
|
1404
|
+
opt_block_param: none { result = 0 }
|
1405
|
+
| block_param_def
|
1406
|
+
|
1407
|
+
block_param_def: tPIPE opt_bv_decl tPIPE
|
1408
|
+
{
|
1409
|
+
result = args val
|
1410
|
+
}
|
1411
|
+
| tOROP
|
1412
|
+
{
|
1413
|
+
self.lexer.command_start = true
|
1414
|
+
result = s(:args)
|
1415
|
+
}
|
1416
|
+
| tPIPE block_param opt_bv_decl tPIPE
|
1417
|
+
{
|
1418
|
+
result = args val
|
1419
|
+
}
|
1420
|
+
|
1421
|
+
opt_bv_decl: opt_nl
|
1422
|
+
| opt_nl tSEMI bv_decls opt_nl
|
1423
|
+
{
|
1424
|
+
result = args val
|
1425
|
+
}
|
1426
|
+
|
1427
|
+
bv_decls: bvar
|
1428
|
+
{
|
1429
|
+
result = args val
|
1430
|
+
}
|
1431
|
+
| bv_decls tCOMMA bvar
|
1432
|
+
{
|
1433
|
+
result = args val
|
1434
|
+
}
|
1435
|
+
|
1436
|
+
bvar: tIDENTIFIER
|
1437
|
+
{
|
1438
|
+
result = s(:shadow, val[0].to_sym)
|
1439
|
+
}
|
1440
|
+
| f_bad_arg
|
1441
|
+
|
1442
|
+
lambda: {
|
1443
|
+
self.env.extend :dynamic
|
1444
|
+
result = self.lexer.lineno
|
1445
|
+
|
1446
|
+
result = lexer.lpar_beg
|
1447
|
+
lexer.paren_nest += 1
|
1448
|
+
lexer.lpar_beg = lexer.paren_nest
|
1449
|
+
}
|
1450
|
+
f_larglist lambda_body
|
1451
|
+
{
|
1452
|
+
lpar, args, body = val
|
1453
|
+
lexer.lpar_beg = lpar
|
1454
|
+
|
1455
|
+
call = new_call nil, :lambda
|
1456
|
+
result = new_iter call, args, body
|
1457
|
+
self.env.unextend
|
1458
|
+
}
|
1459
|
+
|
1460
|
+
f_larglist: tLPAREN2 f_args opt_bv_decl rparen
|
1461
|
+
{
|
1462
|
+
result = args val
|
1463
|
+
}
|
1464
|
+
| f_args
|
1465
|
+
{
|
1466
|
+
result = val[0]
|
1467
|
+
result = 0 if result == s(:args)
|
1468
|
+
}
|
1469
|
+
|
1470
|
+
lambda_body: tLAMBEG compstmt tRCURLY
|
1471
|
+
{
|
1472
|
+
result = val[1]
|
1473
|
+
}
|
1474
|
+
| kDO_LAMBDA compstmt kEND
|
1475
|
+
{
|
1476
|
+
result = val[1]
|
1477
|
+
}
|
1478
|
+
|
1479
|
+
do_block: kDO_BLOCK
|
1480
|
+
{
|
1481
|
+
self.env.extend :dynamic
|
1482
|
+
result = self.lexer.lineno
|
1483
|
+
}
|
1484
|
+
opt_block_param
|
1485
|
+
{
|
1486
|
+
result = nil # self.env.dynamic.keys
|
1487
|
+
}
|
1488
|
+
compstmt kEND
|
1489
|
+
{
|
1490
|
+
args = val[2]
|
1491
|
+
body = val[4]
|
1492
|
+
result = new_iter nil, args, body
|
1493
|
+
result.line = val[1]
|
1494
|
+
|
1495
|
+
self.env.unextend
|
1496
|
+
}
|
1497
|
+
|
1498
|
+
block_call: command do_block
|
1499
|
+
{
|
1500
|
+
# TODO:
|
1501
|
+
## if (nd_type($1) == NODE_YIELD) {
|
1502
|
+
## compile_error(PARSER_ARG "block given to yield");
|
1503
|
+
|
1504
|
+
syntax_error "Both block arg and actual block given." if
|
1505
|
+
val[0].block_pass?
|
1506
|
+
|
1507
|
+
val = invert_block_call val if inverted? val
|
1508
|
+
|
1509
|
+
result = val[1]
|
1510
|
+
result.insert 1, val[0]
|
1511
|
+
}
|
1512
|
+
| block_call dot_or_colon operation2 opt_paren_args
|
1513
|
+
{
|
1514
|
+
result = new_call val[0], val[2].to_sym, val[3]
|
1515
|
+
}
|
1516
|
+
| block_call dot_or_colon operation2 opt_paren_args brace_block
|
1517
|
+
{
|
1518
|
+
iter1, _, name, args, iter2 = val
|
1519
|
+
|
1520
|
+
call = new_call iter1, name.to_sym, args
|
1521
|
+
iter2.insert 1, call
|
1522
|
+
|
1523
|
+
result = iter2
|
1524
|
+
}
|
1525
|
+
| block_call dot_or_colon operation2 command_args do_block
|
1526
|
+
{
|
1527
|
+
iter1, _, name, args, iter2 = val
|
1528
|
+
|
1529
|
+
call = new_call iter1, name.to_sym, args
|
1530
|
+
iter2.insert 1, call
|
1531
|
+
|
1532
|
+
result = iter2
|
1533
|
+
}
|
1534
|
+
|
1535
|
+
method_call: fcall
|
1536
|
+
{
|
1537
|
+
result = self.lexer.lineno
|
1538
|
+
}
|
1539
|
+
paren_args
|
1540
|
+
{
|
1541
|
+
args = self.call_args val[2..-1]
|
1542
|
+
result = val[0].concat args[1..-1]
|
1543
|
+
}
|
1544
|
+
| primary_value call_op operation2 opt_paren_args
|
1545
|
+
{
|
1546
|
+
result = new_call val[0], val[2].to_sym, val[3], val[1]
|
1547
|
+
}
|
1548
|
+
| primary_value tCOLON2 operation2 paren_args
|
1549
|
+
{
|
1550
|
+
result = new_call val[0], val[2].to_sym, val[3]
|
1551
|
+
}
|
1552
|
+
| primary_value tCOLON2 operation3
|
1553
|
+
{
|
1554
|
+
result = new_call val[0], val[2].to_sym
|
1555
|
+
}
|
1556
|
+
| primary_value call_op paren_args
|
1557
|
+
{
|
1558
|
+
result = new_call val[0], :call, val[2], val[1]
|
1559
|
+
}
|
1560
|
+
| primary_value tCOLON2 paren_args
|
1561
|
+
{
|
1562
|
+
result = new_call val[0], :call, val[2]
|
1563
|
+
}
|
1564
|
+
| kSUPER paren_args
|
1565
|
+
{
|
1566
|
+
result = new_super val[1]
|
1567
|
+
}
|
1568
|
+
| kSUPER
|
1569
|
+
{
|
1570
|
+
result = s(:zsuper)
|
1571
|
+
}
|
1572
|
+
| primary_value tLBRACK2 opt_call_args rbracket
|
1573
|
+
{
|
1574
|
+
result = new_aref val
|
1575
|
+
}
|
1576
|
+
|
1577
|
+
brace_block: tLCURLY
|
1578
|
+
{
|
1579
|
+
self.env.extend :dynamic
|
1580
|
+
result = self.lexer.lineno
|
1581
|
+
}
|
1582
|
+
opt_block_param
|
1583
|
+
{
|
1584
|
+
result = nil # self.env.dynamic.keys
|
1585
|
+
}
|
1586
|
+
compstmt tRCURLY
|
1587
|
+
{
|
1588
|
+
_, line, args, _, body, _ = val
|
1589
|
+
|
1590
|
+
result = new_iter nil, args, body
|
1591
|
+
result.line = line
|
1592
|
+
|
1593
|
+
self.env.unextend
|
1594
|
+
}
|
1595
|
+
| kDO
|
1596
|
+
{
|
1597
|
+
self.env.extend :dynamic
|
1598
|
+
result = self.lexer.lineno
|
1599
|
+
}
|
1600
|
+
opt_block_param
|
1601
|
+
{
|
1602
|
+
result = nil # self.env.dynamic.keys
|
1603
|
+
}
|
1604
|
+
compstmt kEND
|
1605
|
+
{
|
1606
|
+
_, line, args, _, body, _ = val
|
1607
|
+
|
1608
|
+
result = new_iter nil, args, body
|
1609
|
+
result.line = line
|
1610
|
+
|
1611
|
+
self.env.unextend
|
1612
|
+
}
|
1613
|
+
|
1614
|
+
case_body: kWHEN
|
1615
|
+
{
|
1616
|
+
result = self.lexer.lineno
|
1617
|
+
}
|
1618
|
+
args then compstmt cases
|
1619
|
+
{
|
1620
|
+
result = new_when(val[2], val[4])
|
1621
|
+
result.line = val[1]
|
1622
|
+
result << val[5] if val[5]
|
1623
|
+
}
|
1624
|
+
|
1625
|
+
cases: opt_else | case_body
|
1626
|
+
|
1627
|
+
opt_rescue: kRESCUE exc_list exc_var then compstmt opt_rescue
|
1628
|
+
{
|
1629
|
+
_, klasses, var, _, body, rest = val
|
1630
|
+
|
1631
|
+
klasses ||= s(:array)
|
1632
|
+
klasses << new_assign(var, s(:gvar, :"$!")) if var
|
1633
|
+
|
1634
|
+
result = new_resbody(klasses, body)
|
1635
|
+
result << rest if rest # UGH, rewritten above
|
1636
|
+
}
|
1637
|
+
|
|
1638
|
+
{
|
1639
|
+
result = nil
|
1640
|
+
}
|
1641
|
+
|
1642
|
+
exc_list: arg_value
|
1643
|
+
{
|
1644
|
+
result = s(:array, val[0])
|
1645
|
+
}
|
1646
|
+
| mrhs
|
1647
|
+
| none
|
1648
|
+
|
1649
|
+
exc_var: tASSOC lhs
|
1650
|
+
{
|
1651
|
+
result = val[1]
|
1652
|
+
}
|
1653
|
+
| none
|
1654
|
+
|
1655
|
+
opt_ensure: kENSURE compstmt
|
1656
|
+
{
|
1657
|
+
_, body = val
|
1658
|
+
|
1659
|
+
result = body || s(:nil)
|
1660
|
+
}
|
1661
|
+
| none
|
1662
|
+
|
1663
|
+
literal: numeric
|
1664
|
+
{
|
1665
|
+
result = s(:lit, val[0])
|
1666
|
+
}
|
1667
|
+
| symbol
|
1668
|
+
{
|
1669
|
+
result = s(:lit, val[0])
|
1670
|
+
}
|
1671
|
+
| dsym
|
1672
|
+
|
1673
|
+
strings: string
|
1674
|
+
{
|
1675
|
+
val[0] = s(:dstr, val[0].value) if val[0][0] == :evstr
|
1676
|
+
result = val[0]
|
1677
|
+
}
|
1678
|
+
|
1679
|
+
string: tCHAR
|
1680
|
+
{
|
1681
|
+
debug20 23, val, result
|
1682
|
+
}
|
1683
|
+
| string1
|
1684
|
+
| string string1
|
1685
|
+
{
|
1686
|
+
result = self.literal_concat val[0], val[1]
|
1687
|
+
}
|
1688
|
+
|
1689
|
+
string1: tSTRING_BEG string_contents tSTRING_END
|
1690
|
+
{
|
1691
|
+
result = val[1]
|
1692
|
+
}
|
1693
|
+
| tSTRING
|
1694
|
+
{
|
1695
|
+
result = new_string val
|
1696
|
+
}
|
1697
|
+
|
1698
|
+
xstring: tXSTRING_BEG xstring_contents tSTRING_END
|
1699
|
+
{
|
1700
|
+
result = new_xstring val[1]
|
1701
|
+
}
|
1702
|
+
|
1703
|
+
regexp: tREGEXP_BEG regexp_contents tREGEXP_END
|
1704
|
+
{
|
1705
|
+
result = new_regexp val
|
1706
|
+
}
|
1707
|
+
|
1708
|
+
words: tWORDS_BEG tSPACE tSTRING_END
|
1709
|
+
{
|
1710
|
+
result = s(:array)
|
1711
|
+
}
|
1712
|
+
| tWORDS_BEG word_list tSTRING_END
|
1713
|
+
{
|
1714
|
+
result = val[1]
|
1715
|
+
}
|
1716
|
+
|
1717
|
+
word_list: none
|
1718
|
+
{
|
1719
|
+
result = new_word_list
|
1720
|
+
}
|
1721
|
+
| word_list word tSPACE
|
1722
|
+
{
|
1723
|
+
result = val[0].dup << new_word_list_entry(val)
|
1724
|
+
}
|
1725
|
+
|
1726
|
+
word: string_content
|
1727
|
+
| word string_content
|
1728
|
+
{
|
1729
|
+
result = self.literal_concat val[0], val[1]
|
1730
|
+
}
|
1731
|
+
|
1732
|
+
symbols: tSYMBOLS_BEG tSPACE tSTRING_END
|
1733
|
+
{
|
1734
|
+
result = s(:array)
|
1735
|
+
}
|
1736
|
+
| tSYMBOLS_BEG symbol_list tSTRING_END
|
1737
|
+
{
|
1738
|
+
result = val[1]
|
1739
|
+
}
|
1740
|
+
|
1741
|
+
symbol_list: none
|
1742
|
+
{
|
1743
|
+
result = new_symbol_list
|
1744
|
+
}
|
1745
|
+
| symbol_list word tSPACE
|
1746
|
+
{
|
1747
|
+
result = val[0].dup << new_symbol_list_entry(val)
|
1748
|
+
}
|
1749
|
+
|
1750
|
+
qwords: tQWORDS_BEG tSPACE tSTRING_END
|
1751
|
+
{
|
1752
|
+
result = s(:array)
|
1753
|
+
}
|
1754
|
+
| tQWORDS_BEG qword_list tSTRING_END
|
1755
|
+
{
|
1756
|
+
result = val[1]
|
1757
|
+
}
|
1758
|
+
|
1759
|
+
qsymbols: tQSYMBOLS_BEG tSPACE tSTRING_END
|
1760
|
+
{
|
1761
|
+
result = s(:array)
|
1762
|
+
}
|
1763
|
+
| tQSYMBOLS_BEG qsym_list tSTRING_END
|
1764
|
+
{
|
1765
|
+
result = val[1]
|
1766
|
+
}
|
1767
|
+
|
1768
|
+
qword_list: none
|
1769
|
+
{
|
1770
|
+
result = new_qword_list
|
1771
|
+
}
|
1772
|
+
| qword_list tSTRING_CONTENT tSPACE
|
1773
|
+
{
|
1774
|
+
result = val[0].dup << new_qword_list_entry(val)
|
1775
|
+
}
|
1776
|
+
|
1777
|
+
qsym_list: none
|
1778
|
+
{
|
1779
|
+
result = new_qsym_list
|
1780
|
+
}
|
1781
|
+
| qsym_list tSTRING_CONTENT tSPACE
|
1782
|
+
{
|
1783
|
+
result = val[0].dup << new_qsym_list_entry(val)
|
1784
|
+
}
|
1785
|
+
|
1786
|
+
string_contents: none
|
1787
|
+
{
|
1788
|
+
result = s(:str, "")
|
1789
|
+
}
|
1790
|
+
| string_contents string_content
|
1791
|
+
{
|
1792
|
+
result = literal_concat(val[0], val[1])
|
1793
|
+
}
|
1794
|
+
|
1795
|
+
xstring_contents: none
|
1796
|
+
{
|
1797
|
+
result = nil
|
1798
|
+
}
|
1799
|
+
| xstring_contents string_content
|
1800
|
+
{
|
1801
|
+
result = literal_concat(val[0], val[1])
|
1802
|
+
}
|
1803
|
+
|
1804
|
+
regexp_contents: none
|
1805
|
+
{
|
1806
|
+
result = nil
|
1807
|
+
}
|
1808
|
+
| regexp_contents string_content
|
1809
|
+
{
|
1810
|
+
result = literal_concat(val[0], val[1])
|
1811
|
+
}
|
1812
|
+
|
1813
|
+
string_content: tSTRING_CONTENT
|
1814
|
+
{
|
1815
|
+
result = new_string val
|
1816
|
+
}
|
1817
|
+
| tSTRING_DVAR
|
1818
|
+
{
|
1819
|
+
result = lexer.lex_strterm
|
1820
|
+
|
1821
|
+
lexer.lex_strterm = nil
|
1822
|
+
lexer.lex_state = :expr_beg # TODO: expr_value ?
|
1823
|
+
}
|
1824
|
+
string_dvar
|
1825
|
+
{
|
1826
|
+
lexer.lex_strterm = val[1]
|
1827
|
+
result = s(:evstr, val[2])
|
1828
|
+
}
|
1829
|
+
| tSTRING_DBEG
|
1830
|
+
{
|
1831
|
+
result = [lexer.lex_strterm,
|
1832
|
+
lexer.brace_nest,
|
1833
|
+
lexer.string_nest, # TODO: remove
|
1834
|
+
lexer.cond.store,
|
1835
|
+
lexer.cmdarg.store,
|
1836
|
+
lexer.lex_state,
|
1837
|
+
]
|
1838
|
+
|
1839
|
+
lexer.lex_strterm = nil
|
1840
|
+
lexer.brace_nest = 0
|
1841
|
+
lexer.string_nest = 0
|
1842
|
+
|
1843
|
+
lexer.lex_state = :expr_value
|
1844
|
+
}
|
1845
|
+
compstmt tRCURLY
|
1846
|
+
{
|
1847
|
+
# TODO: tRCURLY -> tSTRING_END
|
1848
|
+
_, memo, stmt, _ = val
|
1849
|
+
|
1850
|
+
lex_strterm, brace_nest, string_nest, oldcond, oldcmdarg, oldlex_state = memo
|
1851
|
+
|
1852
|
+
lexer.lex_strterm = lex_strterm
|
1853
|
+
lexer.brace_nest = brace_nest
|
1854
|
+
lexer.string_nest = string_nest
|
1855
|
+
|
1856
|
+
lexer.cond.restore oldcond
|
1857
|
+
lexer.cmdarg.restore oldcmdarg
|
1858
|
+
|
1859
|
+
lexer.lex_state = oldlex_state
|
1860
|
+
|
1861
|
+
case stmt
|
1862
|
+
when Sexp then
|
1863
|
+
case stmt[0]
|
1864
|
+
when :str, :dstr, :evstr then
|
1865
|
+
result = stmt
|
1866
|
+
else
|
1867
|
+
result = s(:evstr, stmt)
|
1868
|
+
end
|
1869
|
+
when nil then
|
1870
|
+
result = s(:evstr)
|
1871
|
+
else
|
1872
|
+
debug20 25
|
1873
|
+
raise "unknown string body: #{stmt.inspect}"
|
1874
|
+
end
|
1875
|
+
}
|
1876
|
+
|
1877
|
+
string_dvar: tGVAR { result = s(:gvar, val[0].to_sym) }
|
1878
|
+
| tIVAR { result = s(:ivar, val[0].to_sym) }
|
1879
|
+
| tCVAR { result = s(:cvar, val[0].to_sym) }
|
1880
|
+
| backref
|
1881
|
+
|
1882
|
+
symbol: tSYMBEG sym
|
1883
|
+
{
|
1884
|
+
lexer.lex_state = :expr_end
|
1885
|
+
result = val[1].to_sym
|
1886
|
+
}
|
1887
|
+
| tSYMBOL
|
1888
|
+
{
|
1889
|
+
result = val[0].to_sym
|
1890
|
+
}
|
1891
|
+
|
1892
|
+
sym: fname | tIVAR | tGVAR | tCVAR
|
1893
|
+
|
1894
|
+
dsym: tSYMBEG xstring_contents tSTRING_END
|
1895
|
+
{
|
1896
|
+
lexer.lex_state = :expr_end
|
1897
|
+
result = val[1]
|
1898
|
+
|
1899
|
+
result ||= s(:str, "")
|
1900
|
+
|
1901
|
+
case result[0]
|
1902
|
+
when :dstr then
|
1903
|
+
result[0] = :dsym
|
1904
|
+
when :str then
|
1905
|
+
result = s(:lit, result.last.to_sym)
|
1906
|
+
when :evstr then
|
1907
|
+
result = s(:dsym, "", result)
|
1908
|
+
else
|
1909
|
+
debug20 26, val, result
|
1910
|
+
end
|
1911
|
+
}
|
1912
|
+
|
1913
|
+
numeric: simple_numeric
|
1914
|
+
| tUMINUS_NUM simple_numeric
|
1915
|
+
{
|
1916
|
+
result = -val[1] # TODO: pt_testcase
|
1917
|
+
}
|
1918
|
+
|
1919
|
+
simple_numeric: tINTEGER
|
1920
|
+
| tFLOAT
|
1921
|
+
| tRATIONAL
|
1922
|
+
| tIMAGINARY
|
1923
|
+
|
1924
|
+
user_variable: tIDENTIFIER
|
1925
|
+
| tIVAR
|
1926
|
+
| tGVAR
|
1927
|
+
| tCONSTANT
|
1928
|
+
| tCVAR
|
1929
|
+
|
1930
|
+
keyword_variable: kNIL { result = s(:nil) }
|
1931
|
+
| kSELF { result = s(:self) }
|
1932
|
+
| kTRUE { result = s(:true) }
|
1933
|
+
| kFALSE { result = s(:false) }
|
1934
|
+
| k__FILE__ { result = s(:str, self.file) }
|
1935
|
+
| k__LINE__ { result = s(:lit, lexer.lineno) }
|
1936
|
+
| k__ENCODING__
|
1937
|
+
{
|
1938
|
+
result =
|
1939
|
+
if defined? Encoding then
|
1940
|
+
s(:colon2, s(:const, :Encoding), :UTF_8)
|
1941
|
+
else
|
1942
|
+
s(:str, "Unsupported!")
|
1943
|
+
end
|
1944
|
+
}
|
1945
|
+
|
1946
|
+
var_ref: user_variable
|
1947
|
+
{
|
1948
|
+
var = val[0]
|
1949
|
+
result = Sexp === var ? var : self.gettable(var)
|
1950
|
+
}
|
1951
|
+
| keyword_variable
|
1952
|
+
{
|
1953
|
+
var = val[0]
|
1954
|
+
result = Sexp === var ? var : self.gettable(var)
|
1955
|
+
}
|
1956
|
+
|
1957
|
+
var_lhs: user_variable
|
1958
|
+
{
|
1959
|
+
result = self.assignable val[0]
|
1960
|
+
}
|
1961
|
+
| keyword_variable
|
1962
|
+
{
|
1963
|
+
result = self.assignable val[0]
|
1964
|
+
debug20 29, val, result
|
1965
|
+
}
|
1966
|
+
|
1967
|
+
backref: tNTH_REF { result = s(:nth_ref, val[0]) }
|
1968
|
+
| tBACK_REF { result = s(:back_ref, val[0]) }
|
1969
|
+
|
1970
|
+
superclass: term
|
1971
|
+
{
|
1972
|
+
result = nil
|
1973
|
+
}
|
1974
|
+
| tLT
|
1975
|
+
{
|
1976
|
+
lexer.lex_state = :expr_beg
|
1977
|
+
}
|
1978
|
+
expr_value term
|
1979
|
+
{
|
1980
|
+
result = val[2]
|
1981
|
+
}
|
1982
|
+
| error term
|
1983
|
+
{
|
1984
|
+
yyerrok
|
1985
|
+
result = nil
|
1986
|
+
debug20 30, val, result
|
1987
|
+
}
|
1988
|
+
|
1989
|
+
f_arglist: tLPAREN2 f_args rparen
|
1990
|
+
{
|
1991
|
+
result = val[1]
|
1992
|
+
self.lexer.lex_state = :expr_beg
|
1993
|
+
self.lexer.command_start = true
|
1994
|
+
# TODO:
|
1995
|
+
# $<num>$ = parser->parser_in_kwarg;
|
1996
|
+
# parser->parser_in_kwarg = 1;
|
1997
|
+
}
|
1998
|
+
| f_args term
|
1999
|
+
{
|
2000
|
+
# TODO: parser->parser_in_kwarg = $<num>1;
|
2001
|
+
result = val[0]
|
2002
|
+
self.lexer.lex_state = :expr_beg
|
2003
|
+
self.lexer.command_start = true
|
2004
|
+
}
|
2005
|
+
|
2006
|
+
args_tail: f_kwarg tCOMMA f_kwrest opt_f_block_arg
|
2007
|
+
{
|
2008
|
+
result = args val
|
2009
|
+
}
|
2010
|
+
| f_kwarg opt_f_block_arg
|
2011
|
+
{
|
2012
|
+
result = args val
|
2013
|
+
}
|
2014
|
+
| f_kwrest opt_f_block_arg
|
2015
|
+
{
|
2016
|
+
result = args val
|
2017
|
+
}
|
2018
|
+
| f_block_arg
|
2019
|
+
|
2020
|
+
opt_args_tail: tCOMMA args_tail
|
2021
|
+
{
|
2022
|
+
result = val[1]
|
2023
|
+
}
|
2024
|
+
|
|
2025
|
+
{
|
2026
|
+
result = nil
|
2027
|
+
}
|
2028
|
+
|
2029
|
+
f_args: f_arg tCOMMA f_optarg tCOMMA f_rest_arg opt_args_tail
|
2030
|
+
{
|
2031
|
+
result = args val
|
2032
|
+
}
|
2033
|
+
| f_arg tCOMMA f_optarg tCOMMA f_rest_arg tCOMMA f_arg opt_args_tail
|
2034
|
+
{
|
2035
|
+
result = args val
|
2036
|
+
}
|
2037
|
+
| f_arg tCOMMA f_optarg opt_args_tail
|
2038
|
+
{
|
2039
|
+
result = args val
|
2040
|
+
}
|
2041
|
+
| f_arg tCOMMA f_optarg tCOMMA f_arg opt_args_tail
|
2042
|
+
{
|
2043
|
+
result = args val
|
2044
|
+
}
|
2045
|
+
| f_arg tCOMMA f_rest_arg opt_args_tail
|
2046
|
+
{
|
2047
|
+
result = args val
|
2048
|
+
}
|
2049
|
+
| f_arg tCOMMA f_rest_arg tCOMMA f_arg opt_args_tail
|
2050
|
+
{
|
2051
|
+
result = args val
|
2052
|
+
}
|
2053
|
+
| f_arg opt_args_tail
|
2054
|
+
{
|
2055
|
+
result = args val
|
2056
|
+
}
|
2057
|
+
| f_optarg tCOMMA f_rest_arg opt_args_tail
|
2058
|
+
{
|
2059
|
+
result = args val
|
2060
|
+
}
|
2061
|
+
| f_optarg tCOMMA f_rest_arg tCOMMA f_arg opt_args_tail
|
2062
|
+
{
|
2063
|
+
result = args val
|
2064
|
+
}
|
2065
|
+
| f_optarg opt_args_tail
|
2066
|
+
{
|
2067
|
+
result = args val
|
2068
|
+
}
|
2069
|
+
| f_optarg tCOMMA f_arg opt_args_tail
|
2070
|
+
{
|
2071
|
+
result = args val
|
2072
|
+
}
|
2073
|
+
| f_rest_arg opt_args_tail
|
2074
|
+
{
|
2075
|
+
result = args val
|
2076
|
+
}
|
2077
|
+
| f_rest_arg tCOMMA f_arg opt_args_tail
|
2078
|
+
{
|
2079
|
+
result = args val
|
2080
|
+
}
|
2081
|
+
| args_tail
|
2082
|
+
{
|
2083
|
+
result = args val
|
2084
|
+
}
|
2085
|
+
|
|
2086
|
+
{
|
2087
|
+
result = args val
|
2088
|
+
}
|
2089
|
+
|
2090
|
+
f_bad_arg: tCONSTANT
|
2091
|
+
{
|
2092
|
+
yyerror "formal argument cannot be a constant"
|
2093
|
+
}
|
2094
|
+
| tIVAR
|
2095
|
+
{
|
2096
|
+
yyerror "formal argument cannot be an instance variable"
|
2097
|
+
}
|
2098
|
+
| tGVAR
|
2099
|
+
{
|
2100
|
+
yyerror "formal argument cannot be a global variable"
|
2101
|
+
}
|
2102
|
+
| tCVAR
|
2103
|
+
{
|
2104
|
+
yyerror "formal argument cannot be a class variable"
|
2105
|
+
}
|
2106
|
+
|
2107
|
+
f_norm_arg: f_bad_arg
|
2108
|
+
| tIDENTIFIER
|
2109
|
+
{
|
2110
|
+
identifier = val[0].to_sym
|
2111
|
+
self.env[identifier] = :lvar
|
2112
|
+
|
2113
|
+
result = identifier
|
2114
|
+
}
|
2115
|
+
|
2116
|
+
f_arg_asgn: f_norm_arg
|
2117
|
+
|
2118
|
+
f_arg_item: f_arg_asgn
|
2119
|
+
| tLPAREN f_margs rparen
|
2120
|
+
{
|
2121
|
+
result = val[1]
|
2122
|
+
}
|
2123
|
+
|
2124
|
+
f_arg: f_arg_item
|
2125
|
+
{
|
2126
|
+
case val[0]
|
2127
|
+
when Symbol then
|
2128
|
+
result = s(:args)
|
2129
|
+
result << val[0]
|
2130
|
+
when Sexp then
|
2131
|
+
result = val[0]
|
2132
|
+
else
|
2133
|
+
debug20 32
|
2134
|
+
raise "Unknown f_arg type: #{val.inspect}"
|
2135
|
+
end
|
2136
|
+
}
|
2137
|
+
| f_arg tCOMMA f_arg_item
|
2138
|
+
{
|
2139
|
+
list, _, item = val
|
2140
|
+
|
2141
|
+
if list.sexp_type == :args then
|
2142
|
+
result = list
|
2143
|
+
else
|
2144
|
+
result = s(:args, list)
|
2145
|
+
end
|
2146
|
+
|
2147
|
+
result << item
|
2148
|
+
}
|
2149
|
+
|
2150
|
+
f_label: tLABEL
|
2151
|
+
|
2152
|
+
f_kw: f_label arg_value
|
2153
|
+
{
|
2154
|
+
# TODO: call_args
|
2155
|
+
label, _ = val[0] # TODO: fix lineno?
|
2156
|
+
identifier = label.to_sym
|
2157
|
+
self.env[identifier] = :lvar
|
2158
|
+
|
2159
|
+
result = s(:array, s(:kwarg, identifier, val[1]))
|
2160
|
+
}
|
2161
|
+
| f_label
|
2162
|
+
{
|
2163
|
+
label, _ = val[0] # TODO: fix lineno?
|
2164
|
+
identifier = label.to_sym
|
2165
|
+
self.env[identifier] = :lvar
|
2166
|
+
|
2167
|
+
result = s(:array, s(:kwarg, identifier))
|
2168
|
+
}
|
2169
|
+
|
2170
|
+
f_block_kw: f_label primary_value
|
2171
|
+
{
|
2172
|
+
# TODO: call_args
|
2173
|
+
label, _ = val[0] # TODO: fix lineno?
|
2174
|
+
identifier = label.to_sym
|
2175
|
+
self.env[identifier] = :lvar
|
2176
|
+
|
2177
|
+
result = s(:array, s(:kwarg, identifier, val[1]))
|
2178
|
+
}
|
2179
|
+
| f_label
|
2180
|
+
{
|
2181
|
+
label, _ = val[0] # TODO: fix lineno?
|
2182
|
+
identifier = label.to_sym
|
2183
|
+
self.env[identifier] = :lvar
|
2184
|
+
|
2185
|
+
result = s(:array, s(:kwarg, identifier))
|
2186
|
+
}
|
2187
|
+
|
2188
|
+
f_block_kwarg: f_block_kw
|
2189
|
+
| f_block_kwarg tCOMMA f_block_kw
|
2190
|
+
{
|
2191
|
+
list, _, item = val
|
2192
|
+
result = list << item.last
|
2193
|
+
}
|
2194
|
+
|
2195
|
+
f_kwarg: f_kw
|
2196
|
+
| f_kwarg tCOMMA f_kw
|
2197
|
+
{
|
2198
|
+
result = args val
|
2199
|
+
}
|
2200
|
+
|
2201
|
+
kwrest_mark: tPOW
|
2202
|
+
| tDSTAR
|
2203
|
+
|
2204
|
+
f_kwrest: kwrest_mark tIDENTIFIER
|
2205
|
+
{
|
2206
|
+
result = :"**#{val[1]}"
|
2207
|
+
}
|
2208
|
+
| kwrest_mark
|
2209
|
+
{
|
2210
|
+
result = :"**"
|
2211
|
+
}
|
2212
|
+
|
2213
|
+
f_opt: f_arg_asgn tEQL arg_value
|
2214
|
+
{
|
2215
|
+
result = self.assignable val[0], val[2]
|
2216
|
+
# TODO: detect duplicate names
|
2217
|
+
}
|
2218
|
+
|
2219
|
+
f_block_opt: f_arg_asgn tEQL primary_value
|
2220
|
+
{
|
2221
|
+
result = self.assignable val[0], val[2]
|
2222
|
+
}
|
2223
|
+
|
2224
|
+
f_block_optarg: f_block_opt
|
2225
|
+
{
|
2226
|
+
result = s(:block, val[0])
|
2227
|
+
}
|
2228
|
+
| f_block_optarg tCOMMA f_block_opt
|
2229
|
+
{
|
2230
|
+
result = val[0]
|
2231
|
+
result << val[2]
|
2232
|
+
}
|
2233
|
+
|
2234
|
+
f_optarg: f_opt
|
2235
|
+
{
|
2236
|
+
result = s(:block, val[0])
|
2237
|
+
}
|
2238
|
+
| f_optarg tCOMMA f_opt
|
2239
|
+
{
|
2240
|
+
result = self.block_append val[0], val[2]
|
2241
|
+
}
|
2242
|
+
|
2243
|
+
restarg_mark: tSTAR2 | tSTAR
|
2244
|
+
|
2245
|
+
f_rest_arg: restarg_mark tIDENTIFIER
|
2246
|
+
{
|
2247
|
+
# TODO: differs from parse.y - needs tests
|
2248
|
+
name = val[1].to_sym
|
2249
|
+
self.assignable name
|
2250
|
+
result = :"*#{name}"
|
2251
|
+
}
|
2252
|
+
| restarg_mark
|
2253
|
+
{
|
2254
|
+
name = :"*"
|
2255
|
+
self.env[name] = :lvar
|
2256
|
+
result = name
|
2257
|
+
}
|
2258
|
+
|
2259
|
+
blkarg_mark: tAMPER2 | tAMPER
|
2260
|
+
|
2261
|
+
f_block_arg: blkarg_mark tIDENTIFIER
|
2262
|
+
{
|
2263
|
+
identifier = val[1].to_sym
|
2264
|
+
|
2265
|
+
self.env[identifier] = :lvar
|
2266
|
+
result = "&#{identifier}".to_sym
|
2267
|
+
}
|
2268
|
+
|
2269
|
+
opt_f_block_arg: tCOMMA f_block_arg
|
2270
|
+
{
|
2271
|
+
result = val[1]
|
2272
|
+
}
|
2273
|
+
|
|
2274
|
+
{
|
2275
|
+
result = nil
|
2276
|
+
}
|
2277
|
+
|
2278
|
+
singleton: var_ref
|
2279
|
+
| tLPAREN2
|
2280
|
+
{
|
2281
|
+
lexer.lex_state = :expr_beg
|
2282
|
+
}
|
2283
|
+
expr rparen
|
2284
|
+
{
|
2285
|
+
result = val[2]
|
2286
|
+
yyerror "Can't define single method for literals." if
|
2287
|
+
result[0] == :lit
|
2288
|
+
}
|
2289
|
+
|
2290
|
+
assoc_list: none # [!nil]
|
2291
|
+
{
|
2292
|
+
result = s(:array)
|
2293
|
+
}
|
2294
|
+
| assocs trailer # [!nil]
|
2295
|
+
{
|
2296
|
+
result = val[0]
|
2297
|
+
}
|
2298
|
+
|
2299
|
+
assocs: assoc
|
2300
|
+
| assocs tCOMMA assoc
|
2301
|
+
{
|
2302
|
+
list = val[0].dup
|
2303
|
+
more = val[2][1..-1]
|
2304
|
+
list.push(*more) unless more.empty?
|
2305
|
+
result = list
|
2306
|
+
result[0] = :hash
|
2307
|
+
# TODO: shouldn't this be a hash?
|
2308
|
+
}
|
2309
|
+
|
2310
|
+
assoc: arg_value tASSOC arg_value
|
2311
|
+
{
|
2312
|
+
result = s(:array, val[0], val[2])
|
2313
|
+
}
|
2314
|
+
| tLABEL arg_value
|
2315
|
+
{
|
2316
|
+
result = s(:array, s(:lit, val[0][0].to_sym), val[1])
|
2317
|
+
}
|
2318
|
+
| tSTRING_BEG string_contents tLABEL_END arg_value
|
2319
|
+
{
|
2320
|
+
_, sym, _, value = val
|
2321
|
+
sym[0] = :dsym
|
2322
|
+
result = s(:array, sym, value)
|
2323
|
+
}
|
2324
|
+
| tSYMBOL arg_value
|
2325
|
+
{
|
2326
|
+
raise "not yet: #{val.inspect}"
|
2327
|
+
# result = s(:array, s(:lit, val[1].to_sym), val[1])
|
2328
|
+
}
|
2329
|
+
| tDSTAR arg_value
|
2330
|
+
{
|
2331
|
+
result = s(:array, s(:kwsplat, val[1]))
|
2332
|
+
}
|
2333
|
+
|
2334
|
+
operation: tIDENTIFIER | tCONSTANT | tFID
|
2335
|
+
operation2: tIDENTIFIER | tCONSTANT | tFID | op
|
2336
|
+
operation3: tIDENTIFIER | tFID | op
|
2337
|
+
dot_or_colon: tDOT | tCOLON2
|
2338
|
+
call_op: tDOT
|
2339
|
+
| tLONELY
|
2340
|
+
opt_terms: | terms
|
2341
|
+
opt_nl: | tNL
|
2342
|
+
rparen: opt_nl tRPAREN
|
2343
|
+
rbracket: opt_nl tRBRACK
|
2344
|
+
trailer: | tNL | tCOMMA
|
2345
|
+
|
2346
|
+
term: tSEMI { yyerrok }
|
2347
|
+
| tNL
|
2348
|
+
|
2349
|
+
terms: term
|
2350
|
+
| terms tSEMI { yyerrok }
|
2351
|
+
|
2352
|
+
none: { result = nil; }
|
2353
|
+
end
|
2354
|
+
|
2355
|
+
---- inner
|
2356
|
+
|
2357
|
+
require "ruby_lexer"
|
2358
|
+
require "ruby_parser_extras"
|
2359
|
+
|
2360
|
+
# :stopdoc:
|
2361
|
+
|
2362
|
+
# Local Variables: **
|
2363
|
+
# racc-token-length-max:14 **
|
2364
|
+
# End: **
|