brakeman 5.1.1 → 5.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +18 -1
- data/README.md +1 -1
- data/bundle/load.rb +5 -5
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/CHANGELOG.md +8 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/FAQ.md +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/Gemfile +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/MIT-LICENSE +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/README.md +19 -13
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/REFERENCE.md +10 -3
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/TODO +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/haml.gemspec +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/attribute_builder.rb +55 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/attribute_compiler.rb +4 -2
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/attribute_parser.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/buffer.rb +0 -56
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/compiler.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/engine.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/error.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/escapable.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/exec.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/filters.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/generator.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers/action_view_extensions.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers/action_view_mods.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers/action_view_xss_mods.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers/safe_erubi_template.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers/safe_erubis_template.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers/xss_mods.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/options.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/parser.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/plugin.rb +18 -1
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/railtie.rb +5 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/sass_rails_filter.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/template/options.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/template.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/temple_engine.rb +2 -1
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/temple_line_counter.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/util.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/version.rb +1 -1
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/yard/default/fulldoc/html/css/common.sass +0 -0
- data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/yard/default/layout/html/footer.erb +0 -0
- data/bundle/ruby/2.7.0/gems/{parallel-1.20.1 → parallel-1.21.0}/MIT-LICENSE.txt +0 -0
- data/bundle/ruby/2.7.0/gems/parallel-1.21.0/lib/parallel/processor_count.rb +45 -0
- data/bundle/ruby/2.7.0/gems/parallel-1.21.0/lib/parallel/version.rb +4 -0
- data/bundle/ruby/2.7.0/gems/{parallel-1.20.1 → parallel-1.21.0}/lib/parallel.rb +52 -43
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/History.rdoc +88 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/Manifest.txt +3 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/README.rdoc +1 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/compare/normalize.rb +6 -1
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/debugging.md +0 -0
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/gauntlet.md +106 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/rp_extensions.rb +15 -36
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/rp_stringscanner.rb +33 -0
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby20_parser.rb +7128 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby20_parser.y +335 -252
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby21_parser.rb +7182 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby21_parser.y +330 -249
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby22_parser.rb +7228 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby22_parser.y +334 -251
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby23_parser.rb +7237 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0/lib/ruby26_parser.y → ruby_parser-3.18.1/lib/ruby23_parser.y} +336 -276
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby24_parser.rb +7268 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby24_parser.y +334 -251
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby25_parser.rb +7268 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0/lib/ruby30_parser.y → ruby_parser-3.18.1/lib/ruby25_parser.y} +335 -304
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby26_parser.rb +7287 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0/lib/ruby27_parser.y → ruby_parser-3.18.1/lib/ruby26_parser.y} +334 -288
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby27_parser.rb +8517 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0/lib/ruby_parser.yy → ruby_parser-3.18.1/lib/ruby27_parser.y} +906 -380
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby30_parser.rb +8751 -0
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby30_parser.y +3472 -0
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby3_parser.yy +3476 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby_lexer.rb +261 -609
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby_lexer.rex +27 -20
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby_lexer.rex.rb +59 -23
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby_lexer_strings.rb +638 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby_parser.rb +0 -0
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby_parser.yy +3487 -0
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby_parser_extras.rb +296 -115
- data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/tools/munge.rb +34 -6
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/tools/ripper.rb +44 -0
- data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/History.rdoc +15 -0
- data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/Manifest.txt +0 -0
- data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/README.rdoc +0 -0
- data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/composite_sexp_processor.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/pt_testcase.rb +7 -2
- data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/sexp.rb +19 -9
- data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/sexp_matcher.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/sexp_processor.rb +1 -1
- data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/strict_sexp.rb +25 -3
- data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/unique.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/CHANGELOG.md +4 -0
- data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/MIT-LICENSE.txt +0 -0
- data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/README.md +1 -1
- data/bundle/ruby/2.7.0/gems/unicode-display_width-1.8.0/data/display_width.marshal.gz +0 -0
- data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/lib/unicode/display_width/constants.rb +2 -2
- data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/lib/unicode/display_width/index.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/lib/unicode/display_width/no_string_ext.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/lib/unicode/display_width/string_ext.rb +0 -0
- data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/lib/unicode/display_width.rb +0 -0
- data/lib/brakeman/app_tree.rb +1 -1
- data/lib/brakeman/checks/base_check.rb +10 -0
- data/lib/brakeman/checks/check_eol_rails.rb +23 -0
- data/lib/brakeman/checks/check_eol_ruby.rb +26 -0
- data/lib/brakeman/checks/check_json_parsing.rb +1 -1
- data/lib/brakeman/checks/check_sql.rb +3 -2
- data/lib/brakeman/checks/check_symbol_dos.rb +1 -1
- data/lib/brakeman/checks/eol_check.rb +47 -0
- data/lib/brakeman/options.rb +8 -0
- data/lib/brakeman/processors/alias_processor.rb +7 -1
- data/lib/brakeman/processors/gem_processor.rb +3 -0
- data/lib/brakeman/processors/haml_template_processor.rb +9 -0
- data/lib/brakeman/processors/lib/call_conversion_helper.rb +2 -0
- data/lib/brakeman/processors/lib/rails3_route_processor.rb +2 -0
- data/lib/brakeman/processors/model_processor.rb +1 -0
- data/lib/brakeman/report/ignore/config.rb +1 -1
- data/lib/brakeman/report/report_csv.rb +1 -1
- data/lib/brakeman/report/report_sarif.rb +1 -1
- data/lib/brakeman/report/report_text.rb +1 -1
- data/lib/brakeman/scanner.rb +15 -13
- data/lib/brakeman/tracker/config.rb +8 -1
- data/lib/brakeman/version.rb +1 -1
- data/lib/brakeman/warning_codes.rb +2 -0
- data/lib/brakeman.rb +2 -2
- data/lib/ruby_parser/bm_sexp.rb +11 -1
- metadata +105 -99
- data/bundle/ruby/2.7.0/gems/parallel-1.20.1/lib/parallel/processor_count.rb +0 -42
- data/bundle/ruby/2.7.0/gems/parallel-1.20.1/lib/parallel/version.rb +0 -3
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/rp_stringscanner.rb +0 -64
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby20_parser.rb +0 -7075
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby21_parser.rb +0 -7148
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby22_parser.rb +0 -7185
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby23_parser.rb +0 -7199
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby23_parser.y +0 -2643
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby24_parser.rb +0 -7219
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby25_parser.rb +0 -7218
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby25_parser.y +0 -2651
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby26_parser.rb +0 -7240
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby27_parser.rb +0 -7358
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby30_parser.rb +0 -7358
- data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/tools/ripper.rb +0 -39
- data/bundle/ruby/2.7.0/gems/unicode-display_width-1.7.0/data/display_width.marshal.gz +0 -0
@@ -4,6 +4,11 @@
|
|
4
4
|
|
5
5
|
class RubyLexer
|
6
6
|
|
7
|
+
option
|
8
|
+
|
9
|
+
lineno
|
10
|
+
column
|
11
|
+
|
7
12
|
macro
|
8
13
|
|
9
14
|
IDENT_CHAR /[a-zA-Z0-9_[:^ascii:]]/
|
@@ -25,7 +30,8 @@ macro
|
|
25
30
|
|
26
31
|
start
|
27
32
|
|
28
|
-
|
33
|
+
maybe_pop_stack
|
34
|
+
return process_string_or_heredoc if lex_strterm
|
29
35
|
|
30
36
|
self.cmd_state = self.command_start
|
31
37
|
self.command_start = false
|
@@ -37,14 +43,14 @@ rule
|
|
37
43
|
# [:state] pattern [actions]
|
38
44
|
|
39
45
|
# \s - \n + \v
|
40
|
-
/[\ \t\r\f\v]
|
46
|
+
/[\ \t\r\f\v]+/ { self.space_seen = true; next }
|
41
47
|
|
42
48
|
/\n|\#/ process_newline_or_comment
|
43
49
|
|
44
50
|
/[\]\)\}]/ process_brace_close
|
45
51
|
|
46
52
|
: /\!/
|
47
|
-
| is_after_operator? /\!\@/ { result EXPR_ARG,
|
53
|
+
| is_after_operator? /\!\@/ { result EXPR_ARG, TOKENS[text], text }
|
48
54
|
| /\![=~]?/ { result :arg_state, TOKENS[text], text }
|
49
55
|
|
50
56
|
: /\./
|
@@ -63,7 +69,7 @@ rule
|
|
63
69
|
|
64
70
|
ruby22_label? /\"#{SIMPLE_STRING}\":/o process_label
|
65
71
|
/\"(#{SIMPLE_STRING})\"/o process_simple_string
|
66
|
-
/\"/ { string STR_DQUOTE; result nil, :tSTRING_BEG, text }
|
72
|
+
/\"/ { string STR_DQUOTE, '"'; result nil, :tSTRING_BEG, text }
|
67
73
|
|
68
74
|
/\@\@?\d/ { rb_compile_error "`#{text}` is not allowed as a variable name" }
|
69
75
|
/\@\@?#{IDENT_CHAR}+/o process_ivar
|
@@ -75,7 +81,7 @@ ruby22_label? /\"#{SIMPLE_STRING}\":/o process_label
|
|
75
81
|
| /\:\:/ process_colon2
|
76
82
|
| /\:/ process_colon1
|
77
83
|
|
78
|
-
/->/ { result EXPR_ENDFN, :tLAMBDA,
|
84
|
+
/->/ { result EXPR_ENDFN, :tLAMBDA, text }
|
79
85
|
|
80
86
|
/[+-]/ process_plus_minus
|
81
87
|
|
@@ -94,6 +100,7 @@ ruby22_label? /\"#{SIMPLE_STRING}\":/o process_label
|
|
94
100
|
/\[/ process_square_bracket
|
95
101
|
|
96
102
|
was_label? /\'#{SSTRING}\':?/o process_label_or_string
|
103
|
+
/\'/ { string STR_SQUOTE, "'"; result nil, :tSTRING_BEG, text }
|
97
104
|
|
98
105
|
: /\|/
|
99
106
|
| /\|\|\=/ { result EXPR_BEG, :tOP_ASGN, "||" }
|
@@ -105,9 +112,9 @@ was_label? /\'#{SSTRING}\':?/o process_label_or_string
|
|
105
112
|
|
106
113
|
: /\*/
|
107
114
|
| /\*\*=/ { result EXPR_BEG, :tOP_ASGN, "**" }
|
108
|
-
| /\*\*/ { result
|
109
|
-
| /\*\=/ { result
|
110
|
-
| /\*/ { result
|
115
|
+
| /\*\*/ { result :arg_state, space_vs_beginning(:tDSTAR, :tDSTAR, :tPOW), "**" }
|
116
|
+
| /\*\=/ { result EXPR_BEG, :tOP_ASGN, "*" }
|
117
|
+
| /\*/ { result :arg_state, space_vs_beginning(:tSTAR, :tSTAR, :tSTAR2), "*" }
|
111
118
|
|
112
119
|
# TODO: fix result+process_lchevron to set command_start = true
|
113
120
|
: /</
|
@@ -124,30 +131,30 @@ was_label? /\'#{SSTRING}\':?/o process_label_or_string
|
|
124
131
|
| /\>/ { result :arg_state, :tGT, ">" }
|
125
132
|
|
126
133
|
: /\`/
|
127
|
-
| expr_fname? /\`/ { result
|
134
|
+
| expr_fname? /\`/ { result EXPR_END, :tBACK_REF2, "`" }
|
128
135
|
| expr_dot? /\`/ { result((cmd_state ? EXPR_CMDARG : EXPR_ARG), :tBACK_REF2, "`") }
|
129
|
-
| /\`/ { string STR_XQUOTE, '`'; result
|
136
|
+
| /\`/ { string STR_XQUOTE, '`'; result nil, :tXSTRING_BEG, "`" }
|
130
137
|
|
131
138
|
/\?/ process_questionmark
|
132
139
|
|
133
140
|
: /&/
|
134
|
-
| /\&\&\=/ { result
|
135
|
-
| /\&\&/ { result
|
136
|
-
| /\&\=/ { result
|
137
|
-
| /\&\./ { result
|
141
|
+
| /\&\&\=/ { result EXPR_BEG, :tOP_ASGN, "&&" }
|
142
|
+
| /\&\&/ { result EXPR_BEG, :tANDOP, "&&" }
|
143
|
+
| /\&\=/ { result EXPR_BEG, :tOP_ASGN, "&" }
|
144
|
+
| /\&\./ { result EXPR_DOT, :tLONELY, "&." }
|
138
145
|
| /\&/ process_amper
|
139
146
|
|
140
147
|
/\// process_slash
|
141
148
|
|
142
149
|
: /\^/
|
143
|
-
| /\^=/ { result
|
144
|
-
| /\^/ { result
|
150
|
+
| /\^=/ { result EXPR_BEG, :tOP_ASGN, "^" }
|
151
|
+
| /\^/ { result :arg_state, :tCARET, "^" }
|
145
152
|
|
146
|
-
/\;/ { self.command_start = true; result
|
153
|
+
/\;/ { self.command_start = true; result EXPR_BEG, :tSEMI, ";" }
|
147
154
|
|
148
155
|
: /~/
|
149
|
-
| is_after_operator? /\~@/ { result
|
150
|
-
| /\~/ { result
|
156
|
+
| is_after_operator? /\~@/ { result :arg_state, :tTILDE, "~" }
|
157
|
+
| /\~/ { result :arg_state, :tTILDE, "~" }
|
151
158
|
|
152
159
|
: /\\/
|
153
160
|
| /\\\r?\n/ { self.lineno += 1; self.space_seen = true; next }
|
@@ -165,7 +172,7 @@ was_label? /\'#{SSTRING}\':?/o process_label_or_string
|
|
165
172
|
| /\$([1-9]\d*)/ process_nthref
|
166
173
|
| /\$0/ process_gvar
|
167
174
|
| /\$#{IDENT_CHAR}+/ process_gvar
|
168
|
-
| /\$\W
|
175
|
+
| /\$\W/ process_gvar_oddity
|
169
176
|
|
170
177
|
/\_/ process_underscore
|
171
178
|
|
@@ -1,7 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
# encoding: UTF-8
|
2
3
|
#--
|
3
4
|
# This file is automatically generated. Do not modify it.
|
4
|
-
# Generated by: oedipus_lex version 2.
|
5
|
+
# Generated by: oedipus_lex version 2.6.0.
|
5
6
|
# Source: lib/ruby_lexer.rex
|
6
7
|
#++
|
7
8
|
|
@@ -35,6 +36,10 @@ class RubyLexer
|
|
35
36
|
class ScanError < LexerError ; end
|
36
37
|
# :startdoc:
|
37
38
|
|
39
|
+
##
|
40
|
+
# The current line number.
|
41
|
+
|
42
|
+
attr_accessor :lineno
|
38
43
|
##
|
39
44
|
# The file name / path
|
40
45
|
|
@@ -68,6 +73,24 @@ class RubyLexer
|
|
68
73
|
yield
|
69
74
|
end
|
70
75
|
|
76
|
+
##
|
77
|
+
# The previous position. Only available if the :column option is on.
|
78
|
+
|
79
|
+
attr_accessor :old_pos
|
80
|
+
|
81
|
+
##
|
82
|
+
# The position of the start of the current line. Only available if the
|
83
|
+
# :column option is on.
|
84
|
+
|
85
|
+
attr_accessor :start_of_current_line_pos
|
86
|
+
|
87
|
+
##
|
88
|
+
# The current column, starting at 0. Only available if the
|
89
|
+
# :column option is on.
|
90
|
+
def column
|
91
|
+
old_pos - start_of_current_line_pos
|
92
|
+
end
|
93
|
+
|
71
94
|
|
72
95
|
##
|
73
96
|
# The current scanner class. Must be overridden in subclasses.
|
@@ -81,6 +104,8 @@ class RubyLexer
|
|
81
104
|
|
82
105
|
def parse str
|
83
106
|
self.ss = scanner_class.new str
|
107
|
+
self.lineno = 1
|
108
|
+
self.start_of_current_line_pos = 0
|
84
109
|
self.state ||= nil
|
85
110
|
|
86
111
|
do_parse
|
@@ -102,6 +127,8 @@ class RubyLexer
|
|
102
127
|
def location
|
103
128
|
[
|
104
129
|
(filename || "<input>"),
|
130
|
+
lineno,
|
131
|
+
column,
|
105
132
|
].compact.join(":")
|
106
133
|
end
|
107
134
|
|
@@ -109,7 +136,8 @@ class RubyLexer
|
|
109
136
|
# Lex the next token.
|
110
137
|
|
111
138
|
def next_token
|
112
|
-
|
139
|
+
maybe_pop_stack
|
140
|
+
return process_string_or_heredoc if lex_strterm
|
113
141
|
self.cmd_state = self.command_start
|
114
142
|
self.command_start = false
|
115
143
|
self.space_seen = false # TODO: rename token_seen?
|
@@ -118,11 +146,17 @@ class RubyLexer
|
|
118
146
|
token = nil
|
119
147
|
|
120
148
|
until ss.eos? or token do
|
149
|
+
if ss.check(/\n/) then
|
150
|
+
self.lineno += 1
|
151
|
+
# line starts 1 position after the newline
|
152
|
+
self.start_of_current_line_pos = ss.pos + 1
|
153
|
+
end
|
154
|
+
self.old_pos = ss.pos
|
121
155
|
token =
|
122
156
|
case state
|
123
157
|
when nil then
|
124
158
|
case
|
125
|
-
when ss.skip(/[\ \t\r\f\v]
|
159
|
+
when ss.skip(/[\ \t\r\f\v]+/) then
|
126
160
|
action { self.space_seen = true; next }
|
127
161
|
when text = ss.scan(/\n|\#/) then
|
128
162
|
process_newline_or_comment text
|
@@ -130,8 +164,8 @@ class RubyLexer
|
|
130
164
|
process_brace_close text
|
131
165
|
when ss.match?(/\!/) then
|
132
166
|
case
|
133
|
-
when is_after_operator? && (ss.
|
134
|
-
action { result EXPR_ARG,
|
167
|
+
when is_after_operator? && (text = ss.scan(/\!\@/)) then
|
168
|
+
action { result EXPR_ARG, TOKENS[text], text }
|
135
169
|
when text = ss.scan(/\![=~]?/) then
|
136
170
|
action { result :arg_state, TOKENS[text], text }
|
137
171
|
end # group /\!/
|
@@ -162,7 +196,7 @@ class RubyLexer
|
|
162
196
|
when text = ss.scan(/\"(#{SIMPLE_STRING})\"/o) then
|
163
197
|
process_simple_string text
|
164
198
|
when text = ss.scan(/\"/) then
|
165
|
-
action { string STR_DQUOTE; result nil, :tSTRING_BEG, text }
|
199
|
+
action { string STR_DQUOTE, '"'; result nil, :tSTRING_BEG, text }
|
166
200
|
when text = ss.scan(/\@\@?\d/) then
|
167
201
|
action { rb_compile_error "`#{text}` is not allowed as a variable name" }
|
168
202
|
when text = ss.scan(/\@\@?#{IDENT_CHAR}+/o) then
|
@@ -180,8 +214,8 @@ class RubyLexer
|
|
180
214
|
when text = ss.scan(/\:/) then
|
181
215
|
process_colon1 text
|
182
216
|
end # group /:/
|
183
|
-
when ss.
|
184
|
-
action { result EXPR_ENDFN, :tLAMBDA,
|
217
|
+
when text = ss.scan(/->/) then
|
218
|
+
action { result EXPR_ENDFN, :tLAMBDA, text }
|
185
219
|
when text = ss.scan(/[+-]/) then
|
186
220
|
process_plus_minus text
|
187
221
|
when ss.match?(/[+\d]/) then
|
@@ -211,6 +245,8 @@ class RubyLexer
|
|
211
245
|
process_square_bracket text
|
212
246
|
when was_label? && (text = ss.scan(/\'#{SSTRING}\':?/o)) then
|
213
247
|
process_label_or_string text
|
248
|
+
when text = ss.scan(/\'/) then
|
249
|
+
action { string STR_SQUOTE, "'"; result nil, :tSTRING_BEG, text }
|
214
250
|
when ss.match?(/\|/) then
|
215
251
|
case
|
216
252
|
when ss.skip(/\|\|\=/) then
|
@@ -229,11 +265,11 @@ class RubyLexer
|
|
229
265
|
when ss.skip(/\*\*=/) then
|
230
266
|
action { result EXPR_BEG, :tOP_ASGN, "**" }
|
231
267
|
when ss.skip(/\*\*/) then
|
232
|
-
action { result
|
268
|
+
action { result :arg_state, space_vs_beginning(:tDSTAR, :tDSTAR, :tPOW), "**" }
|
233
269
|
when ss.skip(/\*\=/) then
|
234
|
-
action { result
|
270
|
+
action { result EXPR_BEG, :tOP_ASGN, "*" }
|
235
271
|
when ss.skip(/\*/) then
|
236
|
-
action { result
|
272
|
+
action { result :arg_state, space_vs_beginning(:tSTAR, :tSTAR, :tSTAR2), "*" }
|
237
273
|
end # group /\*/
|
238
274
|
when ss.match?(/</) then
|
239
275
|
case
|
@@ -262,24 +298,24 @@ class RubyLexer
|
|
262
298
|
when ss.match?(/\`/) then
|
263
299
|
case
|
264
300
|
when expr_fname? && (ss.skip(/\`/)) then
|
265
|
-
action { result
|
301
|
+
action { result EXPR_END, :tBACK_REF2, "`" }
|
266
302
|
when expr_dot? && (ss.skip(/\`/)) then
|
267
303
|
action { result((cmd_state ? EXPR_CMDARG : EXPR_ARG), :tBACK_REF2, "`") }
|
268
304
|
when ss.skip(/\`/) then
|
269
|
-
action { string STR_XQUOTE, '`'; result
|
305
|
+
action { string STR_XQUOTE, '`'; result nil, :tXSTRING_BEG, "`" }
|
270
306
|
end # group /\`/
|
271
307
|
when text = ss.scan(/\?/) then
|
272
308
|
process_questionmark text
|
273
309
|
when ss.match?(/&/) then
|
274
310
|
case
|
275
311
|
when ss.skip(/\&\&\=/) then
|
276
|
-
action { result
|
312
|
+
action { result EXPR_BEG, :tOP_ASGN, "&&" }
|
277
313
|
when ss.skip(/\&\&/) then
|
278
|
-
action { result
|
314
|
+
action { result EXPR_BEG, :tANDOP, "&&" }
|
279
315
|
when ss.skip(/\&\=/) then
|
280
|
-
action { result
|
316
|
+
action { result EXPR_BEG, :tOP_ASGN, "&" }
|
281
317
|
when ss.skip(/\&\./) then
|
282
|
-
action { result
|
318
|
+
action { result EXPR_DOT, :tLONELY, "&." }
|
283
319
|
when text = ss.scan(/\&/) then
|
284
320
|
process_amper text
|
285
321
|
end # group /&/
|
@@ -288,18 +324,18 @@ class RubyLexer
|
|
288
324
|
when ss.match?(/\^/) then
|
289
325
|
case
|
290
326
|
when ss.skip(/\^=/) then
|
291
|
-
action { result
|
327
|
+
action { result EXPR_BEG, :tOP_ASGN, "^" }
|
292
328
|
when ss.skip(/\^/) then
|
293
|
-
action { result
|
329
|
+
action { result :arg_state, :tCARET, "^" }
|
294
330
|
end # group /\^/
|
295
331
|
when ss.skip(/\;/) then
|
296
|
-
action { self.command_start = true; result
|
332
|
+
action { self.command_start = true; result EXPR_BEG, :tSEMI, ";" }
|
297
333
|
when ss.match?(/~/) then
|
298
334
|
case
|
299
335
|
when is_after_operator? && (ss.skip(/\~@/)) then
|
300
|
-
action { result
|
336
|
+
action { result :arg_state, :tTILDE, "~" }
|
301
337
|
when ss.skip(/\~/) then
|
302
|
-
action { result
|
338
|
+
action { result :arg_state, :tTILDE, "~" }
|
303
339
|
end # group /~/
|
304
340
|
when ss.match?(/\\/) then
|
305
341
|
case
|
@@ -330,7 +366,7 @@ class RubyLexer
|
|
330
366
|
process_gvar text
|
331
367
|
when text = ss.scan(/\$#{IDENT_CHAR}+/) then
|
332
368
|
process_gvar text
|
333
|
-
when text = ss.scan(/\$\W
|
369
|
+
when text = ss.scan(/\$\W/) then
|
334
370
|
process_gvar_oddity text
|
335
371
|
end # group /\$/
|
336
372
|
when text = ss.scan(/\_/) then
|