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
@@ -3,9 +3,9 @@
|
|
3
3
|
class RubyLexer
|
4
4
|
|
5
5
|
# :stopdoc:
|
6
|
-
|
6
|
+
HAS_ENC = "".respond_to? :encoding
|
7
7
|
|
8
|
-
IDENT_CHAR = if
|
8
|
+
IDENT_CHAR = if HAS_ENC then
|
9
9
|
/[\w\u0080-\u{10ffff}]/u
|
10
10
|
else
|
11
11
|
/[\w\x80-\xFF]/n
|
@@ -285,7 +285,7 @@ class RubyLexer
|
|
285
285
|
end
|
286
286
|
|
287
287
|
def ruby22_label?
|
288
|
-
|
288
|
+
ruby22plus? and is_label_possible?
|
289
289
|
end
|
290
290
|
|
291
291
|
def is_label_possible?
|
@@ -481,7 +481,7 @@ class RubyLexer
|
|
481
481
|
return if in_lex_state?(:expr_beg, :expr_value, :expr_class,
|
482
482
|
:expr_fname, :expr_dot, :expr_labelarg)
|
483
483
|
|
484
|
-
if scan(/([\ \t\r\f\v]*)
|
484
|
+
if scan(/([\ \t\r\f\v]*)(\.|&)/) then
|
485
485
|
self.space_seen = true unless ss[1].empty?
|
486
486
|
|
487
487
|
ss.pos -= 1
|
@@ -778,7 +778,7 @@ class RubyLexer
|
|
778
778
|
when lpar_beg && lpar_beg == paren_nest then
|
779
779
|
self.lpar_beg = nil
|
780
780
|
self.paren_nest -= 1
|
781
|
-
|
781
|
+
expr_result(:kDO_LAMBDA, value)
|
782
782
|
when cond.is_in_state then
|
783
783
|
result(state, :kDO_COND, value)
|
784
784
|
when cmdarg.is_in_state && lex_state != :expr_cmdarg then
|
@@ -817,6 +817,7 @@ class RubyLexer
|
|
817
817
|
when scan(/\\/) then # Backslash
|
818
818
|
'\\'
|
819
819
|
when scan(/n/) then # newline
|
820
|
+
self.extra_lineno -= 1
|
820
821
|
"\n"
|
821
822
|
when scan(/t/) then # horizontal tab
|
822
823
|
"\t"
|
@@ -909,11 +910,7 @@ class RubyLexer
|
|
909
910
|
end
|
910
911
|
|
911
912
|
def ruby18
|
912
|
-
|
913
|
-
end
|
914
|
-
|
915
|
-
def ruby19
|
916
|
-
Ruby19Parser === parser
|
913
|
+
RubyParser::V18 === parser
|
917
914
|
end
|
918
915
|
|
919
916
|
def scan re
|
@@ -1047,7 +1044,7 @@ class RubyLexer
|
|
1047
1044
|
t = Regexp.escape term
|
1048
1045
|
x = Regexp.escape(paren) if paren && paren != "\000"
|
1049
1046
|
re = if qwords then
|
1050
|
-
if
|
1047
|
+
if HAS_ENC then
|
1051
1048
|
/[^#{t}#{x}\#\0\\\s]+|./ # |. to pick up whatever
|
1052
1049
|
else
|
1053
1050
|
/[^#{t}#{x}\#\0\\\s\v]+|./ # argh. 1.8's \s doesn't pick up \v
|
@@ -1098,7 +1095,7 @@ class RubyLexer
|
|
1098
1095
|
else
|
1099
1096
|
s
|
1100
1097
|
end
|
1101
|
-
x.force_encoding "UTF-8" if
|
1098
|
+
x.force_encoding "UTF-8" if HAS_ENC
|
1102
1099
|
x
|
1103
1100
|
end
|
1104
1101
|
|
@@ -1106,9 +1103,8 @@ class RubyLexer
|
|
1106
1103
|
# do nothing for now
|
1107
1104
|
end
|
1108
1105
|
|
1109
|
-
def
|
1110
|
-
|
1111
|
-
Ruby23Parser === parser
|
1106
|
+
def ruby22plus?
|
1107
|
+
parser.class.version >= 22
|
1112
1108
|
end
|
1113
1109
|
|
1114
1110
|
def process_string # TODO: rewrite / remove
|
@@ -1120,7 +1116,7 @@ class RubyLexer
|
|
1120
1116
|
|
1121
1117
|
token_type, c = token
|
1122
1118
|
|
1123
|
-
if
|
1119
|
+
if ruby22plus? && token_type == :tSTRING_END && ["'", '"'].include?(c) then
|
1124
1120
|
if (([:expr_beg, :expr_endfn].include?(lex_state) &&
|
1125
1121
|
!cond.is_in_state) || is_arg?) &&
|
1126
1122
|
is_label_suffix? then
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
#--
|
3
3
|
# This file is automatically generated. Do not modify it.
|
4
|
-
# Generated by: oedipus_lex version 2.
|
4
|
+
# Generated by: oedipus_lex version 2.4.1.
|
5
5
|
# Source: lib/ruby_lexer.rex
|
6
6
|
#++
|
7
7
|
|
@@ -25,8 +25,7 @@ class RubyLexer
|
|
25
25
|
INT_OCT_BAD = /[+]?0o?[0-7_]*[89]/i
|
26
26
|
FLOAT_BAD = /[+]?\d[\d_]*_(e|\.)/i
|
27
27
|
|
28
|
-
class
|
29
|
-
class ScanError < LexerError ; end
|
28
|
+
class ScanError < StandardError ; end
|
30
29
|
|
31
30
|
attr_accessor :filename
|
32
31
|
attr_accessor :ss
|
@@ -44,6 +43,7 @@ class RubyLexer
|
|
44
43
|
yield
|
45
44
|
end
|
46
45
|
|
46
|
+
|
47
47
|
def scanner_class
|
48
48
|
StringScanner
|
49
49
|
end unless instance_methods(false).map(&:to_s).include?("scanner_class")
|
@@ -62,12 +62,6 @@ class RubyLexer
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
-
def location
|
66
|
-
[
|
67
|
-
(filename || "<input>"),
|
68
|
-
].compact.join(":")
|
69
|
-
end
|
70
|
-
|
71
65
|
def next_token
|
72
66
|
return process_string if lex_strterm
|
73
67
|
self.command_state = self.command_start
|
@@ -303,16 +297,16 @@ class RubyLexer
|
|
303
297
|
action { rb_compile_error "Invalid char #{text.inspect} in expression" }
|
304
298
|
else
|
305
299
|
text = ss.string[ss.pos .. -1]
|
306
|
-
raise ScanError, "can not match (#{state.inspect})
|
300
|
+
raise ScanError, "can not match (#{state.inspect}): '#{text}'"
|
307
301
|
end
|
308
302
|
else
|
309
|
-
raise ScanError, "undefined state
|
303
|
+
raise ScanError, "undefined state: '#{state}'"
|
310
304
|
end # token = case state
|
311
305
|
|
312
306
|
next unless token # allow functions to trigger redo w/ nil
|
313
307
|
end # while
|
314
308
|
|
315
|
-
raise
|
309
|
+
raise "bad lexical result: #{token.inspect}" unless
|
316
310
|
token.nil? || (Array === token && token.size >= 2)
|
317
311
|
|
318
312
|
# auto-switch state
|
@@ -1,7 +1,86 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
require "ruby_parser_extras"
|
2
|
+
require "racc/parser"
|
3
|
+
|
4
|
+
##
|
5
|
+
# RubyParser is a compound parser that uses all known versions to
|
6
|
+
# attempt to parse.
|
7
|
+
|
8
|
+
class RubyParser
|
9
|
+
|
10
|
+
VERSIONS = []
|
11
|
+
|
12
|
+
class Parser < Racc::Parser
|
13
|
+
include RubyParserStuff
|
14
|
+
|
15
|
+
def self.inherited x
|
16
|
+
RubyParser::VERSIONS << x
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.version
|
20
|
+
Parser > self and self.name[/V(\d+)$/, 1].to_i
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class SyntaxError < RuntimeError; end
|
25
|
+
|
26
|
+
def process s, f = "(string)", t = 10
|
27
|
+
e = nil
|
28
|
+
VERSIONS.each do |klass|
|
29
|
+
parser = klass.new
|
30
|
+
begin
|
31
|
+
return parser.process s, f, t
|
32
|
+
rescue Racc::ParseError, RubyParser::SyntaxError => exc
|
33
|
+
e = exc
|
34
|
+
end
|
35
|
+
end
|
36
|
+
raise e
|
37
|
+
end
|
38
|
+
|
39
|
+
alias :parse :process
|
40
|
+
|
41
|
+
def reset
|
42
|
+
# do nothing
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.latest
|
46
|
+
VERSIONS.first.new
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.for_current_ruby
|
50
|
+
name = "V#{RUBY_VERSION[/^\d+\.\d+/].delete "."}"
|
51
|
+
klass = if const_defined? name then
|
52
|
+
const_get name
|
53
|
+
else
|
54
|
+
latest = VERSIONS.first
|
55
|
+
warn "NOTE: RubyParser::#{name} undefined, using #{latest}."
|
56
|
+
latest
|
57
|
+
end
|
58
|
+
|
59
|
+
klass.new
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
##
|
64
|
+
# Unfortunately a problem with racc is that it won't let me namespace
|
65
|
+
# properly, so instead of RubyParser::V18, I still have to generate
|
66
|
+
# the old Ruby23Parser and shove it in as V23.
|
67
|
+
|
68
|
+
require "ruby18_parser"
|
69
|
+
require "ruby19_parser"
|
70
|
+
require "ruby20_parser"
|
71
|
+
require "ruby21_parser"
|
72
|
+
require "ruby22_parser"
|
73
|
+
require "ruby23_parser"
|
74
|
+
require "ruby24_parser"
|
75
|
+
|
76
|
+
class RubyParser # HACK
|
77
|
+
VERSIONS.clear # also a HACK caused by racc namespace issues
|
78
|
+
|
79
|
+
class V24 < ::Ruby24Parser; end
|
80
|
+
class V23 < ::Ruby23Parser; end
|
81
|
+
class V22 < ::Ruby22Parser; end
|
82
|
+
class V21 < ::Ruby21Parser; end
|
83
|
+
class V20 < ::Ruby20Parser; end
|
84
|
+
class V19 < ::Ruby19Parser; end
|
85
|
+
class V18 < ::Ruby18Parser; end
|
86
|
+
end
|
@@ -1,13 +1,17 @@
|
|
1
1
|
# -*- racc -*-
|
2
2
|
|
3
|
-
#if
|
3
|
+
#if V==20
|
4
4
|
class Ruby20Parser
|
5
|
-
#elif
|
5
|
+
#elif V==21
|
6
6
|
class Ruby21Parser
|
7
|
-
#elif
|
7
|
+
#elif V == 22
|
8
8
|
class Ruby22Parser
|
9
|
-
#elif
|
9
|
+
#elif V == 23
|
10
10
|
class Ruby23Parser
|
11
|
+
#elif V == 24
|
12
|
+
class Ruby24Parser
|
13
|
+
#else
|
14
|
+
fail "version not specified or supported on code generation"
|
11
15
|
#endif
|
12
16
|
|
13
17
|
token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
|
@@ -27,13 +31,13 @@ token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
|
|
27
31
|
tWORDS_BEG tQWORDS_BEG tSTRING_DBEG tSTRING_DVAR tSTRING_END
|
28
32
|
tSTRING tSYMBOL tNL tEH tCOLON tCOMMA tSPACE tSEMI tLAMBDA
|
29
33
|
tLAMBEG tDSTAR tCHAR tSYMBOLS_BEG tQSYMBOLS_BEG tSTRING_DEND tUBANG
|
30
|
-
#if
|
34
|
+
#if V >= 21
|
31
35
|
tRATIONAL tIMAGINARY
|
32
36
|
#endif
|
33
|
-
#if
|
37
|
+
#if V >= 22
|
34
38
|
tLABEL_END
|
35
39
|
#endif
|
36
|
-
#if
|
40
|
+
#if V >= 23
|
37
41
|
tLONELY
|
38
42
|
#endif
|
39
43
|
|
@@ -227,15 +231,15 @@ rule
|
|
227
231
|
}
|
228
232
|
| lhs tEQL mrhs
|
229
233
|
{
|
230
|
-
result =
|
234
|
+
result = new_assign val[0], s(:svalue, val[2])
|
231
235
|
}
|
232
|
-
#if
|
236
|
+
#if V == 20
|
233
237
|
| mlhs tEQL arg_value
|
234
238
|
{
|
235
239
|
result = new_masgn val[0], val[2], :wrap
|
236
240
|
}
|
237
241
|
| mlhs tEQL mrhs
|
238
|
-
#
|
242
|
+
#else
|
239
243
|
| mlhs tEQL mrhs_arg
|
240
244
|
#endif
|
241
245
|
{
|
@@ -245,21 +249,21 @@ rule
|
|
245
249
|
|
246
250
|
command_asgn: lhs tEQL command_call
|
247
251
|
{
|
248
|
-
result =
|
252
|
+
result = new_assign val[0], val[2]
|
249
253
|
}
|
250
254
|
| lhs tEQL command_asgn
|
251
255
|
{
|
252
|
-
result =
|
256
|
+
result = new_assign val[0], val[2]
|
253
257
|
}
|
254
258
|
|
255
259
|
expr: command_call
|
256
260
|
| expr kAND expr
|
257
261
|
{
|
258
|
-
result =
|
262
|
+
result = logical_op :and, val[0], val[2]
|
259
263
|
}
|
260
264
|
| expr kOR expr
|
261
265
|
{
|
262
|
-
result =
|
266
|
+
result = logical_op :or, val[0], val[2]
|
263
267
|
}
|
264
268
|
| kNOT opt_nl expr
|
265
269
|
{
|
@@ -612,7 +616,7 @@ rule
|
|
612
616
|
| tNEQ | tLSHFT | tRSHFT | tPLUS | tMINUS | tSTAR2
|
613
617
|
| tSTAR | tDIVIDE | tPERCENT | tPOW | tDSTAR | tBANG | tTILDE
|
614
618
|
| tUPLUS | tUMINUS | tAREF | tASET | tBACK_REF2
|
615
|
-
#if
|
619
|
+
#if V == 20
|
616
620
|
| tUBANG
|
617
621
|
#endif
|
618
622
|
|
@@ -628,11 +632,11 @@ rule
|
|
628
632
|
|
629
633
|
arg: lhs tEQL arg
|
630
634
|
{
|
631
|
-
result =
|
635
|
+
result = new_assign val[0], val[2]
|
632
636
|
}
|
633
637
|
| lhs tEQL arg kRESCUE_MOD arg
|
634
638
|
{
|
635
|
-
result =
|
639
|
+
result = new_assign val[0], s(:rescue, val[2], new_resbody(s(:array), val[4]))
|
636
640
|
}
|
637
641
|
| var_lhs tOP_ASGN arg
|
638
642
|
{
|
@@ -714,18 +718,18 @@ rule
|
|
714
718
|
{
|
715
719
|
result = new_call val[0], :**, argl(val[2])
|
716
720
|
}
|
717
|
-
#if
|
721
|
+
#if V == 20
|
718
722
|
| tUMINUS_NUM tINTEGER tPOW arg
|
719
723
|
{
|
720
724
|
result = new_call(new_call(s(:lit, val[1]), :"**", argl(val[3])), :"-@")
|
721
725
|
}
|
722
726
|
| tUMINUS_NUM tFLOAT tPOW arg
|
723
|
-
#
|
727
|
+
#else
|
724
728
|
| tUMINUS_NUM simple_numeric tPOW arg
|
725
729
|
#endif
|
726
730
|
{
|
727
731
|
result = new_call(new_call(s(:lit, val[1]), :"**", argl(val[3])), :"-@")
|
728
|
-
#if
|
732
|
+
#if V == 20
|
729
733
|
## TODO: why is this 2.0 only?
|
730
734
|
debug20 12, val, result
|
731
735
|
#endif
|
@@ -784,11 +788,11 @@ rule
|
|
784
788
|
}
|
785
789
|
| arg tMATCH arg
|
786
790
|
{
|
787
|
-
result =
|
791
|
+
result = new_match val[0], val[2]
|
788
792
|
}
|
789
793
|
| arg tNMATCH arg
|
790
794
|
{
|
791
|
-
result = s(:not,
|
795
|
+
result = s(:not, new_match(val[0], val[2]))
|
792
796
|
}
|
793
797
|
| tBANG arg
|
794
798
|
{
|
@@ -812,11 +816,11 @@ rule
|
|
812
816
|
}
|
813
817
|
| arg tANDOP arg
|
814
818
|
{
|
815
|
-
result =
|
819
|
+
result = logical_op :and, val[0], val[2]
|
816
820
|
}
|
817
821
|
| arg tOROP arg
|
818
822
|
{
|
819
|
-
result =
|
823
|
+
result = logical_op :or, val[0], val[2]
|
820
824
|
}
|
821
825
|
| kDEFINED opt_nl arg
|
822
826
|
{
|
@@ -939,7 +943,7 @@ rule
|
|
939
943
|
result = self.list_append val[0], s(:splat, val[3])
|
940
944
|
}
|
941
945
|
|
942
|
-
#if
|
946
|
+
#if V >= 21
|
943
947
|
mrhs_arg: mrhs
|
944
948
|
{
|
945
949
|
result = new_masgn_arg val[0]
|
@@ -1332,7 +1336,6 @@ rule
|
|
1332
1336
|
args, _, _, _, args2 = val
|
1333
1337
|
|
1334
1338
|
result = block_var args, :*, args2
|
1335
|
-
debug20 16, val, result
|
1336
1339
|
}
|
1337
1340
|
| tSTAR f_norm_arg
|
1338
1341
|
{
|
@@ -1345,12 +1348,10 @@ rule
|
|
1345
1348
|
_, splat, _, args = val
|
1346
1349
|
|
1347
1350
|
result = block_var :"*#{splat}", args
|
1348
|
-
debug20 17, val, result
|
1349
1351
|
}
|
1350
1352
|
| tSTAR
|
1351
1353
|
{
|
1352
1354
|
result = block_var :*
|
1353
|
-
debug20 18, val, result
|
1354
1355
|
}
|
1355
1356
|
| tSTAR tCOMMA f_marg_list
|
1356
1357
|
{
|
@@ -1671,7 +1672,7 @@ opt_block_args_tail: tCOMMA block_args_tail
|
|
1671
1672
|
_, klasses, var, _, body, rest = val
|
1672
1673
|
|
1673
1674
|
klasses ||= s(:array)
|
1674
|
-
klasses <<
|
1675
|
+
klasses << new_assign(var, s(:gvar, :"$!")) if var
|
1675
1676
|
|
1676
1677
|
result = new_resbody(klasses, body)
|
1677
1678
|
result << rest if rest # UGH, rewritten above
|
@@ -1886,9 +1887,9 @@ regexp_contents: none
|
|
1886
1887
|
}
|
1887
1888
|
compstmt tRCURLY
|
1888
1889
|
{
|
1889
|
-
#if
|
1890
|
+
#if V == 20
|
1890
1891
|
# TODO: tRCURLY -> tSTRING_DEND
|
1891
|
-
#
|
1892
|
+
#else
|
1892
1893
|
# TODO: tRCURLY -> tSTRING_END
|
1893
1894
|
#endif
|
1894
1895
|
_, memo, stmt, _ = val
|
@@ -1956,17 +1957,17 @@ regexp_contents: none
|
|
1956
1957
|
end
|
1957
1958
|
}
|
1958
1959
|
|
1959
|
-
#if
|
1960
|
+
#if V == 20
|
1960
1961
|
numeric: tINTEGER
|
1961
1962
|
| tFLOAT
|
1962
1963
|
| tUMINUS_NUM tINTEGER =tLOWEST
|
1963
|
-
#
|
1964
|
+
#else
|
1964
1965
|
numeric: simple_numeric
|
1965
1966
|
| tUMINUS_NUM simple_numeric
|
1966
1967
|
#endif
|
1967
1968
|
{
|
1968
1969
|
result = -val[1] # TODO: pt_testcase
|
1969
|
-
#if
|
1970
|
+
#if V == 20
|
1970
1971
|
}
|
1971
1972
|
| tUMINUS_NUM tFLOAT =tLOWEST
|
1972
1973
|
{
|
@@ -1974,7 +1975,7 @@ regexp_contents: none
|
|
1974
1975
|
#endif
|
1975
1976
|
}
|
1976
1977
|
|
1977
|
-
#if
|
1978
|
+
#if V >= 21
|
1978
1979
|
simple_numeric: tINTEGER
|
1979
1980
|
| tFLOAT
|
1980
1981
|
| tRATIONAL
|
@@ -2173,7 +2174,7 @@ keyword_variable: kNIL { result = s(:nil) }
|
|
2173
2174
|
result = identifier
|
2174
2175
|
}
|
2175
2176
|
|
2176
|
-
#if
|
2177
|
+
#if V >= 22
|
2177
2178
|
f_arg_asgn: f_norm_arg
|
2178
2179
|
|
2179
2180
|
f_arg_item: f_arg_asgn
|
@@ -2215,9 +2216,9 @@ keyword_variable: kNIL { result = s(:nil) }
|
|
2215
2216
|
result << item
|
2216
2217
|
}
|
2217
2218
|
|
2218
|
-
#if
|
2219
|
+
#if V == 20
|
2219
2220
|
f_kw: tLABEL arg_value
|
2220
|
-
#
|
2221
|
+
#else
|
2221
2222
|
f_label: tLABEL
|
2222
2223
|
|
2223
2224
|
f_kw: f_label arg_value
|
@@ -2230,7 +2231,7 @@ keyword_variable: kNIL { result = s(:nil) }
|
|
2230
2231
|
|
2231
2232
|
result = s(:array, s(:kwarg, identifier, val[1]))
|
2232
2233
|
}
|
2233
|
-
#if
|
2234
|
+
#if V >= 21
|
2234
2235
|
| f_label
|
2235
2236
|
{
|
2236
2237
|
label, _ = val[0] # TODO: fix lineno?
|
@@ -2241,9 +2242,9 @@ keyword_variable: kNIL { result = s(:nil) }
|
|
2241
2242
|
}
|
2242
2243
|
#endif
|
2243
2244
|
|
2244
|
-
#if
|
2245
|
+
#if V == 20
|
2245
2246
|
f_block_kw: tLABEL primary_value
|
2246
|
-
#
|
2247
|
+
#else
|
2247
2248
|
f_block_kw: f_label primary_value
|
2248
2249
|
#endif
|
2249
2250
|
{
|
@@ -2254,7 +2255,7 @@ keyword_variable: kNIL { result = s(:nil) }
|
|
2254
2255
|
|
2255
2256
|
result = s(:array, s(:kwarg, identifier, val[1]))
|
2256
2257
|
}
|
2257
|
-
#if
|
2258
|
+
#if V >= 21
|
2258
2259
|
| f_label
|
2259
2260
|
{
|
2260
2261
|
label, _ = val[0] # TODO: fix lineno?
|
@@ -2290,11 +2291,11 @@ keyword_variable: kNIL { result = s(:nil) }
|
|
2290
2291
|
result = :"**"
|
2291
2292
|
}
|
2292
2293
|
|
2293
|
-
#if
|
2294
|
+
#if V == 20
|
2294
2295
|
f_opt: tIDENTIFIER tEQL arg_value
|
2295
|
-
#elif
|
2296
|
+
#elif V == 21
|
2296
2297
|
f_opt: f_norm_arg tEQL arg_value
|
2297
|
-
#
|
2298
|
+
#else
|
2298
2299
|
f_opt: f_arg_asgn tEQL arg_value
|
2299
2300
|
#endif
|
2300
2301
|
{
|
@@ -2302,11 +2303,11 @@ keyword_variable: kNIL { result = s(:nil) }
|
|
2302
2303
|
# TODO: detect duplicate names
|
2303
2304
|
}
|
2304
2305
|
|
2305
|
-
#if
|
2306
|
+
#if V == 20
|
2306
2307
|
f_block_opt: tIDENTIFIER tEQL primary_value
|
2307
|
-
#elif
|
2308
|
+
#elif V == 21
|
2308
2309
|
f_block_opt: f_norm_arg tEQL primary_value
|
2309
|
-
#
|
2310
|
+
#else
|
2310
2311
|
f_block_opt: f_arg_asgn tEQL primary_value
|
2311
2312
|
#endif
|
2312
2313
|
{
|
@@ -2407,7 +2408,7 @@ keyword_variable: kNIL { result = s(:nil) }
|
|
2407
2408
|
{
|
2408
2409
|
result = s(:array, s(:lit, val[0][0].to_sym), val[1])
|
2409
2410
|
}
|
2410
|
-
#if
|
2411
|
+
#if V >= 22
|
2411
2412
|
| tSTRING_BEG string_contents tLABEL_END arg_value
|
2412
2413
|
{
|
2413
2414
|
_, sym, _, value = val
|
@@ -2430,7 +2431,7 @@ keyword_variable: kNIL { result = s(:nil) }
|
|
2430
2431
|
operation3: tIDENTIFIER | tFID | op
|
2431
2432
|
dot_or_colon: tDOT | tCOLON2
|
2432
2433
|
call_op: tDOT
|
2433
|
-
#if
|
2434
|
+
#if V >= 23
|
2434
2435
|
| tLONELY
|
2435
2436
|
#endif
|
2436
2437
|
opt_terms: | terms
|