brakeman 5.0.4 → 5.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +53 -1
  3. data/README.md +1 -1
  4. data/bundle/load.rb +5 -4
  5. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/CHANGELOG.md +8 -0
  6. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/FAQ.md +0 -0
  7. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/Gemfile +0 -0
  8. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/MIT-LICENSE +0 -0
  9. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/README.md +19 -13
  10. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/REFERENCE.md +10 -3
  11. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/TODO +0 -0
  12. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/haml.gemspec +0 -0
  13. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/attribute_builder.rb +55 -0
  14. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/attribute_compiler.rb +4 -2
  15. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/attribute_parser.rb +0 -0
  16. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/buffer.rb +0 -56
  17. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/compiler.rb +0 -0
  18. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/engine.rb +0 -0
  19. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/error.rb +0 -0
  20. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/escapable.rb +0 -0
  21. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/exec.rb +0 -0
  22. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/filters.rb +0 -0
  23. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/generator.rb +0 -0
  24. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers/action_view_extensions.rb +0 -0
  25. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers/action_view_mods.rb +0 -0
  26. 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
  27. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers/safe_erubi_template.rb +0 -0
  28. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers/safe_erubis_template.rb +0 -0
  29. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers/xss_mods.rb +0 -0
  30. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/helpers.rb +0 -0
  31. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/options.rb +0 -0
  32. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/parser.rb +0 -0
  33. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/plugin.rb +18 -1
  34. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/railtie.rb +5 -0
  35. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/sass_rails_filter.rb +0 -0
  36. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/template/options.rb +0 -0
  37. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/template.rb +0 -0
  38. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/temple_engine.rb +2 -1
  39. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/temple_line_counter.rb +0 -0
  40. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/util.rb +0 -0
  41. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml/version.rb +1 -1
  42. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/lib/haml.rb +0 -0
  43. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/yard/default/fulldoc/html/css/common.sass +0 -0
  44. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.2}/yard/default/layout/html/footer.erb +0 -0
  45. data/bundle/ruby/2.7.0/gems/parallel-1.21.0/MIT-LICENSE.txt +20 -0
  46. data/bundle/ruby/2.7.0/gems/parallel-1.21.0/lib/parallel/processor_count.rb +45 -0
  47. data/bundle/ruby/2.7.0/gems/parallel-1.21.0/lib/parallel/version.rb +4 -0
  48. data/bundle/ruby/2.7.0/gems/parallel-1.21.0/lib/parallel.rb +532 -0
  49. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/History.rdoc +88 -0
  50. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/Manifest.txt +3 -0
  51. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/README.rdoc +1 -0
  52. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/compare/normalize.rb +6 -1
  53. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/debugging.md +0 -0
  54. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/gauntlet.md +106 -0
  55. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/rp_extensions.rb +15 -36
  56. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/rp_stringscanner.rb +33 -0
  57. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby20_parser.rb +7128 -0
  58. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby20_parser.y +335 -252
  59. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby21_parser.rb +7182 -0
  60. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby21_parser.y +330 -249
  61. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby22_parser.rb +7228 -0
  62. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby22_parser.y +334 -251
  63. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby23_parser.rb +7237 -0
  64. 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
  65. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby24_parser.rb +7268 -0
  66. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby24_parser.y +334 -251
  67. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby25_parser.rb +7268 -0
  68. 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
  69. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby26_parser.rb +7287 -0
  70. 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
  71. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby27_parser.rb +8517 -0
  72. 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
  73. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby30_parser.rb +8751 -0
  74. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby30_parser.y +3472 -0
  75. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby3_parser.yy +3476 -0
  76. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby_lexer.rb +261 -609
  77. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby_lexer.rex +27 -20
  78. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby_lexer.rex.rb +59 -23
  79. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby_lexer_strings.rb +638 -0
  80. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby_parser.rb +0 -0
  81. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby_parser.yy +3487 -0
  82. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/lib/ruby_parser_extras.rb +296 -115
  83. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.16.0 → ruby_parser-3.18.1}/tools/munge.rb +34 -6
  84. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/tools/ripper.rb +44 -0
  85. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/History.rdoc +15 -0
  86. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/Manifest.txt +0 -0
  87. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/README.rdoc +0 -0
  88. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/composite_sexp_processor.rb +0 -0
  89. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/pt_testcase.rb +7 -2
  90. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/sexp.rb +19 -9
  91. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/sexp_matcher.rb +0 -0
  92. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/sexp_processor.rb +1 -1
  93. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/strict_sexp.rb +25 -3
  94. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.15.3 → sexp_processor-4.16.0}/lib/unique.rb +0 -0
  95. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/CHANGELOG.md +4 -0
  96. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/MIT-LICENSE.txt +0 -0
  97. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.7.0 → unicode-display_width-1.8.0}/README.md +1 -1
  98. data/bundle/ruby/2.7.0/gems/unicode-display_width-1.8.0/data/display_width.marshal.gz +0 -0
  99. 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
  100. 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
  101. 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
  102. 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
  103. 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
  104. data/lib/brakeman/app_tree.rb +1 -1
  105. data/lib/brakeman/checks/base_check.rb +10 -0
  106. data/lib/brakeman/checks/check_detailed_exceptions.rb +1 -1
  107. data/lib/brakeman/checks/check_eol_rails.rb +23 -0
  108. data/lib/brakeman/checks/check_eol_ruby.rb +26 -0
  109. data/lib/brakeman/checks/check_evaluation.rb +1 -1
  110. data/lib/brakeman/checks/check_execute.rb +10 -0
  111. data/lib/brakeman/checks/check_json_parsing.rb +1 -1
  112. data/lib/brakeman/checks/check_render.rb +15 -1
  113. data/lib/brakeman/checks/check_sql.rb +58 -7
  114. data/lib/brakeman/checks/check_symbol_dos.rb +1 -1
  115. data/lib/brakeman/checks/check_verb_confusion.rb +1 -1
  116. data/lib/brakeman/checks/eol_check.rb +47 -0
  117. data/lib/brakeman/file_parser.rb +45 -15
  118. data/lib/brakeman/options.rb +15 -2
  119. data/lib/brakeman/processors/alias_processor.rb +91 -9
  120. data/lib/brakeman/processors/controller_alias_processor.rb +6 -43
  121. data/lib/brakeman/processors/gem_processor.rb +3 -0
  122. data/lib/brakeman/processors/haml_template_processor.rb +9 -0
  123. data/lib/brakeman/processors/lib/call_conversion_helper.rb +12 -6
  124. data/lib/brakeman/processors/lib/rails3_route_processor.rb +2 -0
  125. data/lib/brakeman/processors/library_processor.rb +9 -0
  126. data/lib/brakeman/processors/model_processor.rb +32 -0
  127. data/lib/brakeman/report/ignore/config.rb +1 -1
  128. data/lib/brakeman/report/ignore/interactive.rb +1 -1
  129. data/lib/brakeman/report/report_csv.rb +1 -1
  130. data/lib/brakeman/report/report_github.rb +31 -0
  131. data/lib/brakeman/report/report_sarif.rb +22 -3
  132. data/lib/brakeman/report/report_text.rb +1 -1
  133. data/lib/brakeman/report.rb +4 -1
  134. data/lib/brakeman/rescanner.rb +1 -1
  135. data/lib/brakeman/scanner.rb +19 -14
  136. data/lib/brakeman/tracker/collection.rb +57 -7
  137. data/lib/brakeman/tracker/config.rb +8 -1
  138. data/lib/brakeman/tracker/method_info.rb +70 -0
  139. data/lib/brakeman/tracker.rb +33 -4
  140. data/lib/brakeman/util.rb +34 -18
  141. data/lib/brakeman/version.rb +1 -1
  142. data/lib/brakeman/warning_codes.rb +4 -0
  143. data/lib/brakeman.rb +8 -2
  144. data/lib/ruby_parser/bm_sexp.rb +24 -0
  145. metadata +107 -95
  146. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/rp_stringscanner.rb +0 -64
  147. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby20_parser.rb +0 -7075
  148. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby21_parser.rb +0 -7148
  149. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby22_parser.rb +0 -7185
  150. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby23_parser.rb +0 -7199
  151. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby23_parser.y +0 -2643
  152. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby24_parser.rb +0 -7219
  153. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby25_parser.rb +0 -7218
  154. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby25_parser.y +0 -2651
  155. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby26_parser.rb +0 -7240
  156. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby27_parser.rb +0 -7358
  157. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/lib/ruby30_parser.rb +0 -7358
  158. data/bundle/ruby/2.7.0/gems/ruby_parser-3.16.0/tools/ripper.rb +0 -39
  159. 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
- return process_string if lex_strterm
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]/ { self.space_seen = true; next }
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, :tUBANG, "!@" }
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, nil }
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(:arg_state, space_vs_beginning(:tDSTAR, :tDSTAR, :tPOW), "**") }
109
- | /\*\=/ { result(EXPR_BEG, :tOP_ASGN, "*") }
110
- | /\*/ { result(:arg_state, space_vs_beginning(:tSTAR, :tSTAR, :tSTAR2), "*") }
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(EXPR_END, :tBACK_REF2, "`") }
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(nil, :tXSTRING_BEG, "`") }
136
+ | /\`/ { string STR_XQUOTE, '`'; result nil, :tXSTRING_BEG, "`" }
130
137
 
131
138
  /\?/ process_questionmark
132
139
 
133
140
  : /&/
134
- | /\&\&\=/ { result(EXPR_BEG, :tOP_ASGN, "&&") }
135
- | /\&\&/ { result(EXPR_BEG, :tANDOP, "&&") }
136
- | /\&\=/ { result(EXPR_BEG, :tOP_ASGN, "&" ) }
137
- | /\&\./ { result(EXPR_DOT, :tLONELY, "&.") }
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(EXPR_BEG, :tOP_ASGN, "^") }
144
- | /\^/ { result(:arg_state, :tCARET, "^") }
150
+ | /\^=/ { result EXPR_BEG, :tOP_ASGN, "^" }
151
+ | /\^/ { result :arg_state, :tCARET, "^" }
145
152
 
146
- /\;/ { self.command_start = true; result(EXPR_BEG, :tSEMI, ";") }
153
+ /\;/ { self.command_start = true; result EXPR_BEG, :tSEMI, ";" }
147
154
 
148
155
  : /~/
149
- | is_after_operator? /\~@/ { result(:arg_state, :tTILDE, "~") }
150
- | /\~/ { result(:arg_state, :tTILDE, "~") }
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|\$\z/ process_gvar_oddity
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.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
- return process_string if lex_strterm
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]/) then
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.skip(/\!\@/)) then
134
- action { result EXPR_ARG, :tUBANG, "!@" }
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.skip(/->/) then
184
- action { result EXPR_ENDFN, :tLAMBDA, nil }
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(:arg_state, space_vs_beginning(:tDSTAR, :tDSTAR, :tPOW), "**") }
268
+ action { result :arg_state, space_vs_beginning(:tDSTAR, :tDSTAR, :tPOW), "**" }
233
269
  when ss.skip(/\*\=/) then
234
- action { result(EXPR_BEG, :tOP_ASGN, "*") }
270
+ action { result EXPR_BEG, :tOP_ASGN, "*" }
235
271
  when ss.skip(/\*/) then
236
- action { result(:arg_state, space_vs_beginning(:tSTAR, :tSTAR, :tSTAR2), "*") }
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(EXPR_END, :tBACK_REF2, "`") }
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(nil, :tXSTRING_BEG, "`") }
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(EXPR_BEG, :tOP_ASGN, "&&") }
312
+ action { result EXPR_BEG, :tOP_ASGN, "&&" }
277
313
  when ss.skip(/\&\&/) then
278
- action { result(EXPR_BEG, :tANDOP, "&&") }
314
+ action { result EXPR_BEG, :tANDOP, "&&" }
279
315
  when ss.skip(/\&\=/) then
280
- action { result(EXPR_BEG, :tOP_ASGN, "&" ) }
316
+ action { result EXPR_BEG, :tOP_ASGN, "&" }
281
317
  when ss.skip(/\&\./) then
282
- action { result(EXPR_DOT, :tLONELY, "&.") }
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(EXPR_BEG, :tOP_ASGN, "^") }
327
+ action { result EXPR_BEG, :tOP_ASGN, "^" }
292
328
  when ss.skip(/\^/) then
293
- action { result(:arg_state, :tCARET, "^") }
329
+ action { result :arg_state, :tCARET, "^" }
294
330
  end # group /\^/
295
331
  when ss.skip(/\;/) then
296
- action { self.command_start = true; result(EXPR_BEG, :tSEMI, ";") }
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(:arg_state, :tTILDE, "~") }
336
+ action { result :arg_state, :tTILDE, "~" }
301
337
  when ss.skip(/\~/) then
302
- action { result(:arg_state, :tTILDE, "~") }
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|\$\z/) then
369
+ when text = ss.scan(/\$\W/) then
334
370
  process_gvar_oddity text
335
371
  end # group /\$/
336
372
  when text = ss.scan(/\_/) then