brakeman 4.4.0 → 4.5.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of brakeman might be problematic. Click here for more details.

Files changed (362) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +17 -0
  3. data/bundle/load.rb +7 -8
  4. data/bundle/ruby/2.5.0/gems/{ruby2ruby-2.4.1 → ruby2ruby-2.4.2}/History.rdoc +8 -0
  5. data/bundle/ruby/2.5.0/gems/{ruby2ruby-2.4.1 → ruby2ruby-2.4.2}/Manifest.txt +0 -0
  6. data/bundle/ruby/2.5.0/gems/{ruby2ruby-2.4.1 → ruby2ruby-2.4.2}/README.rdoc +0 -0
  7. data/bundle/ruby/2.5.0/gems/{ruby2ruby-2.4.1 → ruby2ruby-2.4.2}/lib/ruby2ruby.rb +34 -36
  8. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/History.rdoc +47 -0
  9. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/Manifest.txt +5 -4
  10. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/README.rdoc +0 -0
  11. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/compare/normalize.rb +29 -2
  12. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/debugging.md +18 -0
  13. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/rp_extensions.rb +0 -7
  14. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/rp_stringscanner.rb +0 -0
  15. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby20_parser.rb +6874 -0
  16. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby20_parser.y +284 -201
  17. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby21_parser.rb +6952 -0
  18. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby21_parser.y +281 -197
  19. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby22_parser.rb +6983 -0
  20. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0/lib/ruby_parser.yy → ruby_parser-3.13.0/lib/ruby22_parser.y} +280 -306
  21. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby23_parser.rb +6982 -0
  22. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby23_parser.y +282 -203
  23. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby24_parser.rb +6982 -0
  24. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby24_parser.y +282 -203
  25. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby25_parser.rb +6981 -0
  26. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby25_parser.y +282 -203
  27. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby26_parser.rb +6999 -0
  28. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby26_parser.y +2469 -0
  29. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby_lexer.rb +116 -118
  30. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby_lexer.rex +10 -8
  31. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby_lexer.rex.rb +8 -8
  32. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby_parser.rb +5 -7
  33. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby_parser.yy +2571 -0
  34. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby_parser_extras.rb +1360 -0
  35. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/tools/munge.rb +216 -0
  36. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/tools/ripper.rb +23 -0
  37. data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/History.rdoc +6 -0
  38. data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/Manifest.txt +19 -0
  39. data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/README.rdoc +54 -0
  40. data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy.rb +5 -0
  41. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0/lib → ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy}/ruby18_parser.rb +7 -6
  42. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0/lib → ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy}/ruby18_parser.y +5 -4
  43. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0/lib → ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy}/ruby19_parser.rb +7 -6
  44. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0/lib → ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy}/ruby19_parser.y +5 -4
  45. data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby_lexer.rb +1412 -0
  46. data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby_lexer.rex +179 -0
  47. data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby_lexer.rex.rb +323 -0
  48. data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby_parser.rb +30 -0
  49. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0/lib → ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy}/ruby_parser_extras.rb +43 -33
  50. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/CHANGES.md +5 -0
  51. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/Gemfile +0 -0
  52. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/LICENSE.txt +0 -0
  53. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/README.md +0 -0
  54. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/bundle_install_all_ruby_versions.sh +0 -0
  55. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml.rb +0 -0
  56. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/deep.rb +0 -0
  57. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/libyaml_checker.rb +0 -0
  58. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/load.rb +0 -0
  59. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/parse/date.rb +2 -0
  60. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/parse/hexadecimal.rb +0 -0
  61. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/parse/sexagesimal.rb +0 -0
  62. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/psych_handler.rb +0 -0
  63. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/psych_resolver.rb +0 -0
  64. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/resolver.rb +0 -0
  65. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/safe_to_ruby_visitor.rb +0 -0
  66. data/bundle/ruby/2.5.0/gems/safe_yaml-1.0.5/lib/safe_yaml/store.rb +39 -0
  67. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/syck_hack.rb +0 -0
  68. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/syck_node_monkeypatch.rb +0 -0
  69. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/syck_resolver.rb +0 -0
  70. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform.rb +0 -0
  71. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform/to_boolean.rb +0 -0
  72. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform/to_date.rb +0 -0
  73. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform/to_float.rb +0 -0
  74. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform/to_integer.rb +0 -0
  75. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform/to_nil.rb +0 -0
  76. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform/to_symbol.rb +0 -0
  77. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform/transformation_map.rb +0 -0
  78. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/version.rb +1 -1
  79. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/run_specs_all_ruby_versions.sh +0 -0
  80. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/safe_yaml.gemspec +0 -0
  81. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/History.rdoc +8 -0
  82. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/Manifest.txt +0 -0
  83. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/README.rdoc +0 -0
  84. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/lib/composite_sexp_processor.rb +0 -0
  85. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/lib/pt_testcase.rb +2 -2
  86. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/lib/sexp.rb +4 -4
  87. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/lib/sexp_processor.rb +1 -1
  88. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/lib/strict_sexp.rb +3 -3
  89. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/lib/unique.rb +0 -0
  90. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/CHANGES +6 -0
  91. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/EXPRESSIONS.md +1 -1
  92. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/Gemfile +0 -0
  93. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/LICENSE +0 -0
  94. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/README.md +1 -1
  95. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple.rb +0 -0
  96. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/engine.rb +0 -0
  97. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/erb/engine.rb +0 -0
  98. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/erb/parser.rb +0 -0
  99. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/erb/template.rb +0 -0
  100. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/erb/trimming.rb +0 -0
  101. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/exceptions.rb +0 -0
  102. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filter.rb +0 -0
  103. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/code_merger.rb +0 -0
  104. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/control_flow.rb +0 -0
  105. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/dynamic_inliner.rb +0 -0
  106. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/encoding.rb +0 -0
  107. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/eraser.rb +0 -0
  108. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/escapable.rb +0 -0
  109. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/multi_flattener.rb +0 -0
  110. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/remove_bom.rb +0 -0
  111. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/static_analyzer.rb +0 -0
  112. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/static_merger.rb +0 -0
  113. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/string_splitter.rb +0 -0
  114. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/validator.rb +0 -0
  115. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/generator.rb +0 -0
  116. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/generators/array.rb +0 -0
  117. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/generators/array_buffer.rb +0 -0
  118. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/generators/erb.rb +0 -0
  119. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/generators/rails_output_buffer.rb +0 -0
  120. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/generators/string_buffer.rb +0 -0
  121. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/grammar.rb +0 -0
  122. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/attribute_merger.rb +0 -0
  123. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/attribute_remover.rb +0 -0
  124. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/attribute_sorter.rb +0 -0
  125. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/dispatcher.rb +0 -0
  126. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/fast.rb +0 -0
  127. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/filter.rb +0 -0
  128. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/pretty.rb +0 -0
  129. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/safe.rb +0 -0
  130. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/map.rb +0 -0
  131. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/mixins/dispatcher.rb +2 -1
  132. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/mixins/engine_dsl.rb +0 -0
  133. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/mixins/grammar_dsl.rb +0 -0
  134. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/mixins/options.rb +0 -0
  135. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/mixins/template.rb +0 -0
  136. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/parser.rb +0 -0
  137. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/static_analyzer.rb +0 -0
  138. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/templates.rb +0 -0
  139. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/templates/rails.rb +2 -2
  140. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/templates/tilt.rb +0 -0
  141. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/utils.rb +0 -0
  142. data/bundle/ruby/2.5.0/gems/temple-0.8.1/lib/temple/version.rb +3 -0
  143. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/temple.gemspec +0 -0
  144. data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/CHANGELOG.md +4 -0
  145. data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/MIT-LICENSE.txt +1 -1
  146. data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/README.md +10 -10
  147. data/bundle/ruby/2.5.0/gems/unicode-display_width-1.5.0/data/display_width.marshal.gz +0 -0
  148. data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/lib/unicode/display_width.rb +0 -0
  149. data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/lib/unicode/display_width/constants.rb +2 -2
  150. data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/lib/unicode/display_width/index.rb +0 -0
  151. data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/lib/unicode/display_width/no_string_ext.rb +0 -0
  152. data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/lib/unicode/display_width/string_ext.rb +0 -0
  153. data/lib/brakeman/checks/base_check.rb +16 -0
  154. data/lib/brakeman/checks/check_content_tag.rb +12 -0
  155. data/lib/brakeman/checks/check_cross_site_scripting.rb +6 -6
  156. data/lib/brakeman/checks/check_evaluation.rb +0 -1
  157. data/lib/brakeman/checks/check_execute.rb +18 -0
  158. data/lib/brakeman/checks/check_send.rb +0 -1
  159. data/lib/brakeman/checks/check_session_manipulation.rb +0 -1
  160. data/lib/brakeman/checks/check_sql.rb +12 -3
  161. data/lib/brakeman/file_parser.rb +8 -4
  162. data/lib/brakeman/parsers/haml_embedded.rb +44 -0
  163. data/lib/brakeman/parsers/slim_embedded.rb +44 -0
  164. data/lib/brakeman/parsers/template_parser.rb +2 -4
  165. data/lib/brakeman/processors/alias_processor.rb +23 -1
  166. data/lib/brakeman/processors/lib/call_conversion_helper.rb +4 -0
  167. data/lib/brakeman/processors/slim_template_processor.rb +16 -0
  168. data/lib/brakeman/processors/template_alias_processor.rb +2 -2
  169. data/lib/brakeman/scanner.rb +11 -10
  170. data/lib/brakeman/tracker.rb +5 -1
  171. data/lib/brakeman/tracker/config.rb +32 -7
  172. data/lib/brakeman/util.rb +17 -0
  173. data/lib/brakeman/version.rb +1 -1
  174. metadata +157 -320
  175. data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby20_parser.rb +0 -6687
  176. data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby21_parser.rb +0 -6767
  177. data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby22_parser.rb +0 -6803
  178. data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby22_parser.y +0 -2376
  179. data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby23_parser.rb +0 -6818
  180. data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby24_parser.rb +0 -6818
  181. data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby25_parser.rb +0 -6818
  182. data/bundle/ruby/2.5.0/gems/sass-3.4.25/CODE_OF_CONDUCT.md +0 -10
  183. data/bundle/ruby/2.5.0/gems/sass-3.4.25/CONTRIBUTING.md +0 -148
  184. data/bundle/ruby/2.5.0/gems/sass-3.4.25/MIT-LICENSE +0 -20
  185. data/bundle/ruby/2.5.0/gems/sass-3.4.25/README.md +0 -227
  186. data/bundle/ruby/2.5.0/gems/sass-3.4.25/REVISION +0 -1
  187. data/bundle/ruby/2.5.0/gems/sass-3.4.25/VERSION +0 -1
  188. data/bundle/ruby/2.5.0/gems/sass-3.4.25/VERSION_DATE +0 -1
  189. data/bundle/ruby/2.5.0/gems/sass-3.4.25/VERSION_NAME +0 -1
  190. data/bundle/ruby/2.5.0/gems/sass-3.4.25/extra/sass-spec-ref.sh +0 -32
  191. data/bundle/ruby/2.5.0/gems/sass-3.4.25/extra/update_watch.rb +0 -13
  192. data/bundle/ruby/2.5.0/gems/sass-3.4.25/init.rb +0 -18
  193. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass.rb +0 -109
  194. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/cache_stores.rb +0 -15
  195. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/cache_stores/base.rb +0 -88
  196. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/cache_stores/chain.rb +0 -34
  197. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/cache_stores/filesystem.rb +0 -60
  198. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/cache_stores/memory.rb +0 -46
  199. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/cache_stores/null.rb +0 -25
  200. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/callbacks.rb +0 -67
  201. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/css.rb +0 -408
  202. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/deprecation.rb +0 -55
  203. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/engine.rb +0 -1226
  204. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/environment.rb +0 -215
  205. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/error.rb +0 -198
  206. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/exec.rb +0 -9
  207. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/exec/base.rb +0 -199
  208. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/exec/sass_convert.rb +0 -283
  209. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/exec/sass_scss.rb +0 -440
  210. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/features.rb +0 -47
  211. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/importers.rb +0 -23
  212. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/importers/base.rb +0 -182
  213. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/importers/deprecated_path.rb +0 -51
  214. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/importers/filesystem.rb +0 -219
  215. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/logger.rb +0 -17
  216. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/logger/base.rb +0 -36
  217. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/logger/delayed.rb +0 -50
  218. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/logger/log_level.rb +0 -45
  219. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/media.rb +0 -210
  220. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin.rb +0 -134
  221. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/compiler.rb +0 -582
  222. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/configuration.rb +0 -134
  223. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/generic.rb +0 -15
  224. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/merb.rb +0 -48
  225. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/rack.rb +0 -60
  226. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/rails.rb +0 -47
  227. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/staleness_checker.rb +0 -199
  228. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/railtie.rb +0 -10
  229. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/repl.rb +0 -57
  230. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/root.rb +0 -7
  231. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script.rb +0 -66
  232. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/css_lexer.rb +0 -33
  233. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/css_parser.rb +0 -33
  234. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/css_variable_warning.rb +0 -52
  235. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/functions.rb +0 -2693
  236. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/lexer.rb +0 -464
  237. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/parser.rb +0 -832
  238. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree.rb +0 -16
  239. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/funcall.rb +0 -313
  240. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/interpolation.rb +0 -223
  241. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/list_literal.rb +0 -104
  242. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/literal.rb +0 -49
  243. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/map_literal.rb +0 -64
  244. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/node.rb +0 -127
  245. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/operation.rb +0 -156
  246. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/selector.rb +0 -26
  247. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/string_interpolation.rb +0 -125
  248. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/unary_operation.rb +0 -69
  249. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/variable.rb +0 -57
  250. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value.rb +0 -11
  251. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/arg_list.rb +0 -36
  252. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/base.rb +0 -241
  253. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/bool.rb +0 -35
  254. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/color.rb +0 -698
  255. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/helpers.rb +0 -272
  256. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/list.rb +0 -113
  257. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/map.rb +0 -70
  258. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/null.rb +0 -44
  259. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/number.rb +0 -563
  260. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/string.rb +0 -138
  261. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/scss.rb +0 -14
  262. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/scss/css_parser.rb +0 -56
  263. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/scss/parser.rb +0 -1254
  264. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/scss/rx.rb +0 -140
  265. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/scss/static_parser.rb +0 -373
  266. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector.rb +0 -323
  267. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector/abstract_sequence.rb +0 -111
  268. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector/comma_sequence.rb +0 -191
  269. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector/pseudo.rb +0 -266
  270. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector/sequence.rb +0 -636
  271. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector/simple.rb +0 -117
  272. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector/simple_sequence.rb +0 -344
  273. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/shared.rb +0 -76
  274. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/source/map.rb +0 -213
  275. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/source/position.rb +0 -39
  276. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/source/range.rb +0 -41
  277. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/stack.rb +0 -120
  278. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/supports.rb +0 -225
  279. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/at_root_node.rb +0 -83
  280. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/charset_node.rb +0 -22
  281. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/comment_node.rb +0 -82
  282. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/content_node.rb +0 -9
  283. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/css_import_node.rb +0 -68
  284. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/debug_node.rb +0 -18
  285. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/directive_node.rb +0 -59
  286. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/each_node.rb +0 -24
  287. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/error_node.rb +0 -18
  288. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/extend_node.rb +0 -43
  289. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/for_node.rb +0 -36
  290. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/function_node.rb +0 -44
  291. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/if_node.rb +0 -52
  292. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/import_node.rb +0 -75
  293. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/keyframe_rule_node.rb +0 -15
  294. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/media_node.rb +0 -48
  295. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/mixin_def_node.rb +0 -38
  296. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/mixin_node.rb +0 -52
  297. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/node.rb +0 -240
  298. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/prop_node.rb +0 -170
  299. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/return_node.rb +0 -19
  300. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/root_node.rb +0 -44
  301. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/rule_node.rb +0 -155
  302. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/supports_node.rb +0 -38
  303. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/trace_node.rb +0 -33
  304. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/variable_node.rb +0 -36
  305. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/base.rb +0 -72
  306. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/check_nesting.rb +0 -173
  307. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/convert.rb +0 -351
  308. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/cssize.rb +0 -373
  309. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/deep_copy.rb +0 -107
  310. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/extend.rb +0 -70
  311. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/perform.rb +0 -564
  312. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/set_options.rb +0 -139
  313. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/to_css.rb +0 -409
  314. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/warn_node.rb +0 -18
  315. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/while_node.rb +0 -18
  316. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util.rb +0 -1375
  317. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util/cross_platform_random.rb +0 -19
  318. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util/multibyte_string_scanner.rb +0 -155
  319. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util/normalized_map.rb +0 -129
  320. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util/ordered_hash.rb +0 -192
  321. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util/subset_map.rb +0 -109
  322. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util/test.rb +0 -9
  323. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/version.rb +0 -124
  324. data/bundle/ruby/2.5.0/gems/sass-3.4.25/rails/init.rb +0 -1
  325. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/CHANGELOG.md +0 -1
  326. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/CONTRIBUTING.md +0 -38
  327. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/Gemfile +0 -20
  328. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/Guardfile +0 -8
  329. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/LICENSE +0 -20
  330. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/README.md +0 -349
  331. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/Rakefile +0 -5
  332. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/Vagrantfile +0 -96
  333. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen.rb +0 -54
  334. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/adapter.rb +0 -327
  335. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/adapters/bsd.rb +0 -75
  336. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/adapters/darwin.rb +0 -48
  337. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/adapters/linux.rb +0 -81
  338. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/adapters/polling.rb +0 -58
  339. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/adapters/windows.rb +0 -91
  340. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/directory_record.rb +0 -406
  341. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/listener.rb +0 -323
  342. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/turnstile.rb +0 -32
  343. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/version.rb +0 -3
  344. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/listen.gemspec +0 -28
  345. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/adapter_spec.rb +0 -149
  346. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/adapters/bsd_spec.rb +0 -36
  347. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/adapters/darwin_spec.rb +0 -37
  348. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/adapters/linux_spec.rb +0 -47
  349. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/adapters/polling_spec.rb +0 -68
  350. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/adapters/windows_spec.rb +0 -30
  351. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/directory_record_spec.rb +0 -1250
  352. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/listener_spec.rb +0 -258
  353. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/turnstile_spec.rb +0 -56
  354. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen_spec.rb +0 -67
  355. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/spec_helper.rb +0 -25
  356. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/support/adapter_helper.rb +0 -666
  357. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/support/directory_record_helper.rb +0 -57
  358. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/support/fixtures_helper.rb +0 -29
  359. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/support/listeners_helper.rb +0 -179
  360. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/support/platform_helper.rb +0 -15
  361. data/bundle/ruby/2.5.0/gems/temple-0.8.0/lib/temple/version.rb +0 -3
  362. data/bundle/ruby/2.5.0/gems/unicode-display_width-1.4.1/data/display_width.marshal.gz +0 -0
@@ -0,0 +1,1412 @@
1
+ # frozen_string_literal: true
2
+ # encoding: UTF-8
3
+
4
+ $DEBUG = true if ENV["DEBUG"]
5
+
6
+ class RubyParser::Legacy::RubyLexer
7
+
8
+ # :stopdoc:
9
+ HAS_ENC = "".respond_to? :encoding
10
+
11
+ IDENT_CHAR = if HAS_ENC then
12
+ /[\w\u0080-\u{10ffff}]/u
13
+ else
14
+ /[\w\x80-\xFF]/n
15
+ end
16
+
17
+ EOF = :eof_haha!
18
+
19
+ # ruby constants for strings (should this be moved somewhere else?)
20
+
21
+ STR_FUNC_BORING = 0x00
22
+ STR_FUNC_ESCAPE = 0x01 # TODO: remove and replace with REGEXP
23
+ STR_FUNC_EXPAND = 0x02
24
+ STR_FUNC_REGEXP = 0x04
25
+ STR_FUNC_QWORDS = 0x08
26
+ STR_FUNC_SYMBOL = 0x10
27
+ STR_FUNC_INDENT = 0x20 # <<-HEREDOC
28
+ STR_FUNC_ICNTNT = 0x40 # <<~HEREDOC
29
+
30
+ STR_SQUOTE = STR_FUNC_BORING
31
+ STR_DQUOTE = STR_FUNC_BORING | STR_FUNC_EXPAND
32
+ STR_XQUOTE = STR_FUNC_BORING | STR_FUNC_EXPAND
33
+ STR_REGEXP = STR_FUNC_REGEXP | STR_FUNC_ESCAPE | STR_FUNC_EXPAND
34
+ STR_SSYM = STR_FUNC_SYMBOL
35
+ STR_DSYM = STR_FUNC_SYMBOL | STR_FUNC_EXPAND
36
+
37
+ EXPR_BEG_ANY = [:expr_beg, :expr_mid, :expr_class ]
38
+ EXPR_ARG_ANY = [:expr_arg, :expr_cmdarg, ]
39
+ EXPR_END_ANY = [:expr_end, :expr_endarg, :expr_endfn]
40
+
41
+ ESCAPES = {
42
+ "a" => "\007",
43
+ "b" => "\010",
44
+ "e" => "\033",
45
+ "f" => "\f",
46
+ "n" => "\n",
47
+ "r" => "\r",
48
+ "s" => " ",
49
+ "t" => "\t",
50
+ "v" => "\13",
51
+ "\\" => '\\',
52
+ "\n" => "",
53
+ "C-\?" => 127.chr,
54
+ "c\?" => 127.chr,
55
+ }
56
+
57
+ TOKENS = {
58
+ "!" => :tBANG,
59
+ "!=" => :tNEQ,
60
+ # "!@" => :tUBANG,
61
+ "!~" => :tNMATCH,
62
+ "," => :tCOMMA,
63
+ ".." => :tDOT2,
64
+ "..." => :tDOT3,
65
+ "=" => :tEQL,
66
+ "==" => :tEQ,
67
+ "===" => :tEQQ,
68
+ "=>" => :tASSOC,
69
+ "=~" => :tMATCH,
70
+ "->" => :tLAMBDA,
71
+ }
72
+
73
+ TAB_WIDTH = 8
74
+
75
+ @@regexp_cache = Hash.new { |h,k| h[k] = Regexp.new(Regexp.escape(k)) }
76
+ @@regexp_cache[nil] = nil
77
+
78
+ # :startdoc:
79
+
80
+ attr_accessor :lineno # we're bypassing oedipus' lineno handling.
81
+ attr_accessor :brace_nest
82
+ attr_accessor :cmdarg
83
+ attr_accessor :command_start
84
+ attr_accessor :cmd_state # temporary--ivar to avoid passing everywhere
85
+ attr_accessor :last_state
86
+ attr_accessor :cond
87
+ attr_accessor :extra_lineno
88
+
89
+ ##
90
+ # Additional context surrounding tokens that both the lexer and
91
+ # grammar use.
92
+
93
+ attr_accessor :lex_state
94
+ attr_accessor :lex_strterm
95
+ attr_accessor :lpar_beg
96
+ attr_accessor :paren_nest
97
+ attr_accessor :parser # HACK for very end of lexer... *sigh*
98
+ attr_accessor :space_seen
99
+ attr_accessor :string_buffer
100
+ attr_accessor :string_nest
101
+
102
+ if $DEBUG then
103
+ alias lex_state= lex_state=
104
+ def lex_state=o
105
+ return if @lex_state == o
106
+ c = caller.first
107
+ c = caller[1] if c =~ /\bresult\b/
108
+ warn "lex_state: %p -> %p from %s" % [@lex_state, o, c.clean_caller]
109
+ @lex_state = o
110
+ end
111
+ end
112
+
113
+ # Last token read via next_token.
114
+ attr_accessor :token
115
+
116
+ ##
117
+ # What version of ruby to parse. 18 and 19 are the only valid values
118
+ # currently supported.
119
+
120
+ attr_accessor :version
121
+
122
+ attr_writer :comments
123
+
124
+ def initialize v = 18
125
+ self.version = v
126
+ @lex_state = :expr_none
127
+
128
+ self.cond = RubyParser::Legacy::RubyParserStuff::StackState.new(:cond, $DEBUG)
129
+ self.cmdarg = RubyParser::Legacy::RubyParserStuff::StackState.new(:cmdarg, $DEBUG)
130
+
131
+ reset
132
+ end
133
+
134
+ def arg_ambiguous
135
+ self.warning("Ambiguous first argument. make sure.")
136
+ end
137
+
138
+ def arg_state
139
+ in_arg_state? ? :expr_arg : :expr_beg
140
+ end
141
+
142
+ def beginning_of_line?
143
+ ss.bol?
144
+ end
145
+ alias :bol? :beginning_of_line? # to make .rex file more readable
146
+
147
+ def comments # TODO: remove this... maybe comment_string + attr_accessor
148
+ c = @comments.join
149
+ @comments.clear
150
+ c
151
+ end
152
+
153
+ def end_of_stream?
154
+ ss.eos?
155
+ end
156
+
157
+ def expr_dot?
158
+ lex_state == :expr_dot
159
+ end
160
+
161
+ def expr_fname?
162
+ lex_state == :expr_fname
163
+ end
164
+
165
+ def expr_result token, text
166
+ cond.push false
167
+ cmdarg.push false
168
+ result :expr_beg, token, text
169
+ end
170
+
171
+ def heredoc here # TODO: rewrite / remove
172
+ _, eos, func, last_line = here
173
+
174
+ indent = (func & STR_FUNC_INDENT) != 0 ? "[ \t]*" : nil
175
+ content_indent = (func & STR_FUNC_ICNTNT) != 0
176
+ expand = (func & STR_FUNC_EXPAND) != 0
177
+ eos_re = /#{indent}#{Regexp.escape eos}(\r*\n|\z)/
178
+ err_msg = "can't match #{eos_re.inspect} anywhere in "
179
+
180
+ rb_compile_error err_msg if end_of_stream?
181
+
182
+ if beginning_of_line? && scan(eos_re) then
183
+ self.lineno += 1
184
+ ss.unread_many last_line # TODO: figure out how to remove this
185
+ return :tSTRING_END, eos
186
+ end
187
+
188
+ self.string_buffer = []
189
+
190
+ if expand then
191
+ case
192
+ when scan(/#[$@]/) then
193
+ ss.pos -= 1 # FIX omg stupid
194
+ return :tSTRING_DVAR, matched
195
+ when scan(/#[{]/) then
196
+ return :tSTRING_DBEG, matched
197
+ when scan(/#/) then
198
+ string_buffer << '#'
199
+ end
200
+
201
+ begin
202
+ c = tokadd_string func, "\n", nil
203
+
204
+ rb_compile_error err_msg if
205
+ c == RubyLexer::EOF
206
+
207
+ if c != "\n" then
208
+ return :tSTRING_CONTENT, string_buffer.join.delete("\r")
209
+ else
210
+ string_buffer << scan(/\n/)
211
+ end
212
+
213
+ rb_compile_error err_msg if end_of_stream?
214
+ end until check(eos_re)
215
+ else
216
+ until check(eos_re) do
217
+ string_buffer << scan(/.*(\n|\z)/)
218
+ rb_compile_error err_msg if end_of_stream?
219
+ end
220
+ end
221
+
222
+ self.lex_strterm = [:heredoc, eos, func, last_line]
223
+
224
+ string_content = string_buffer.join.delete("\r")
225
+
226
+ string_content = heredoc_dedent(string_content) if content_indent && ruby23plus?
227
+
228
+ return :tSTRING_CONTENT, string_content
229
+ end
230
+
231
+ def heredoc_dedent(string_content)
232
+ width = string_content.scan(/^[ \t]*(?=\S)/).map do |whitespace|
233
+ heredoc_whitespace_indent_size whitespace
234
+ end.min || 0
235
+
236
+ string_content.split("\n", -1).map do |line|
237
+ dedent_string line, width
238
+ end.join "\n"
239
+ end
240
+
241
+ def dedent_string(string, width)
242
+ characters_skipped = 0
243
+ indentation_skipped = 0
244
+
245
+ string.chars.each do |char|
246
+ break if indentation_skipped >= width
247
+ if char == ' '
248
+ characters_skipped += 1
249
+ indentation_skipped += 1
250
+ elsif char == "\t"
251
+ proposed = TAB_WIDTH * (indentation_skipped / TAB_WIDTH + 1)
252
+ break if (proposed > width)
253
+ characters_skipped += 1
254
+ indentation_skipped = proposed
255
+ end
256
+ end
257
+ string[characters_skipped..-1]
258
+ end
259
+
260
+ def heredoc_whitespace_indent_size(whitespace)
261
+ whitespace.chars.inject 0 do |size, char|
262
+ if char == "\t"
263
+ size + TAB_WIDTH
264
+ else
265
+ size + 1
266
+ end
267
+ end
268
+ end
269
+
270
+ def heredoc_identifier # TODO: remove / rewrite
271
+ term, func = nil, STR_FUNC_BORING
272
+ self.string_buffer = []
273
+
274
+ heredoc_indent_mods = '-'
275
+ heredoc_indent_mods += '\~' if ruby23plus?
276
+
277
+ case
278
+ when scan(/([#{heredoc_indent_mods}]?)([\'\"\`])(.*?)\2/) then
279
+ term = ss[2]
280
+ func |= STR_FUNC_INDENT unless ss[1].empty?
281
+ func |= STR_FUNC_ICNTNT if ss[1] == '~'
282
+ func |= case term
283
+ when "\'" then
284
+ STR_SQUOTE
285
+ when '"' then
286
+ STR_DQUOTE
287
+ else
288
+ STR_XQUOTE
289
+ end
290
+ string_buffer << ss[3]
291
+ when scan(/[#{heredoc_indent_mods}]?([\'\"\`])(?!\1*\Z)/) then
292
+ rb_compile_error "unterminated here document identifier"
293
+ when scan(/([#{heredoc_indent_mods}]?)(#{IDENT_CHAR}+)/) then
294
+ term = '"'
295
+ func |= STR_DQUOTE
296
+ unless ss[1].empty? then
297
+ func |= STR_FUNC_INDENT
298
+ func |= STR_FUNC_ICNTNT if ss[1] == '~'
299
+ end
300
+ string_buffer << ss[2]
301
+ else
302
+ return nil
303
+ end
304
+
305
+ if scan(/.*\n/) then
306
+ # TODO: think about storing off the char range instead
307
+ line = matched
308
+ else
309
+ line = nil
310
+ end
311
+
312
+ self.lex_strterm = [:heredoc, string_buffer.join, func, line]
313
+
314
+ if term == '`' then
315
+ result nil, :tXSTRING_BEG, "`"
316
+ else
317
+ result nil, :tSTRING_BEG, "\""
318
+ end
319
+ end
320
+
321
+ def in_fname?
322
+ in_lex_state? :expr_fname
323
+ end
324
+
325
+ def in_arg_state? # TODO: rename is_after_operator?
326
+ in_lex_state? :expr_fname, :expr_dot
327
+ end
328
+
329
+ def in_lex_state?(*states)
330
+ states.include? lex_state
331
+ end
332
+
333
+ def int_with_base base
334
+ rb_compile_error "Invalid numeric format" if matched =~ /__/
335
+
336
+ text = matched
337
+ case
338
+ when text.end_with?('ri')
339
+ return result(:expr_end, :tIMAGINARY, Complex(0, Rational(text.chop.chop.to_i(base))))
340
+ when text.end_with?('r')
341
+ return result(:expr_end, :tRATIONAL, Rational(text.chop.to_i(base)))
342
+ when text.end_with?('i')
343
+ return result(:expr_end, :tIMAGINARY, Complex(0, text.chop.to_i(base)))
344
+ else
345
+ return result(:expr_end, :tINTEGER, text.to_i(base))
346
+ end
347
+ end
348
+
349
+ def is_arg?
350
+ in_lex_state?(*EXPR_ARG_ANY)
351
+ end
352
+
353
+ def is_beg?
354
+ # TODO: in_lex_state?(*EXPR_BEG_ANY) || lex_state == [:expr_arg, :expr_labeled]
355
+ in_lex_state?(*EXPR_BEG_ANY, :expr_value, :expr_labeled)
356
+ end
357
+
358
+ def is_end?
359
+ in_lex_state?(*EXPR_END_ANY)
360
+ end
361
+
362
+ def lvar_defined? id
363
+ # TODO: (dyna_in_block? && dvar_defined?(id)) || local_id?(id)
364
+ self.parser.env[id.to_sym] == :lvar
365
+ end
366
+
367
+
368
+ def ruby22_label?
369
+ ruby22plus? and is_label_possible?
370
+ end
371
+
372
+ def is_label_possible?
373
+ (in_lex_state?(:expr_beg, :expr_endfn) && !cmd_state) || is_arg?
374
+ end
375
+
376
+ def is_label_suffix?
377
+ check(/:(?!:)/)
378
+ end
379
+
380
+ def is_space_arg? c = "x"
381
+ is_arg? and space_seen and c !~ /\s/
382
+ end
383
+
384
+ def lambda_beginning?
385
+ lpar_beg && lpar_beg == paren_nest
386
+ end
387
+
388
+ def matched
389
+ ss.matched
390
+ end
391
+
392
+ def not_end?
393
+ not is_end?
394
+ end
395
+
396
+ def process_amper text
397
+ token = if is_arg? && space_seen && !check(/\s/) then
398
+ warning("`&' interpreted as argument prefix")
399
+ :tAMPER
400
+ elsif in_lex_state? :expr_beg, :expr_mid then
401
+ :tAMPER
402
+ else
403
+ :tAMPER2
404
+ end
405
+
406
+ return result(:arg_state, token, "&")
407
+ end
408
+
409
+ def process_backref text
410
+ token = ss[1].to_sym
411
+ # TODO: can't do lineno hack w/ symbol
412
+ result :expr_end, :tBACK_REF, token
413
+ end
414
+
415
+ def process_begin text
416
+ @comments << matched
417
+
418
+ unless scan(/.*?\n=end( |\t|\f)*[^\n]*(\n|\z)/m) then
419
+ @comments.clear
420
+ rb_compile_error("embedded document meets end of file")
421
+ end
422
+
423
+ @comments << matched
424
+ self.lineno += matched.count("\n")
425
+
426
+ nil # TODO
427
+ end
428
+
429
+ def process_brace_close text
430
+ # matching compare/parse23.y:8561
431
+ cond.lexpop
432
+ cmdarg.lexpop
433
+
434
+ case matched
435
+ when "}" then
436
+ self.brace_nest -= 1
437
+ self.lex_state = :expr_endarg # TODO: :expr_end ? Look at 2.6
438
+
439
+ return :tSTRING_DEND, matched if brace_nest < 0 unless ruby18 || ruby19
440
+ return :tRCURLY, matched
441
+ when "]" then
442
+ self.paren_nest -= 1
443
+ self.lex_state = :expr_endarg
444
+ return :tRBRACK, matched
445
+ when ")" then
446
+ self.paren_nest -= 1
447
+ self.lex_state = :expr_endfn
448
+ return :tRPAREN, matched
449
+ else
450
+ raise "Unknown bracing: #{matched.inspect}"
451
+ end
452
+ end
453
+
454
+ def process_colon1 text
455
+ # ?: / then / when
456
+ if is_end? || check(/\s/) then
457
+ return result :expr_beg, :tCOLON, text
458
+ end
459
+
460
+ case
461
+ when scan(/\'/) then
462
+ string STR_SSYM
463
+ when scan(/\"/) then
464
+ string STR_DSYM
465
+ end
466
+
467
+ result :expr_fname, :tSYMBEG, text
468
+ end
469
+
470
+ def process_colon2 text
471
+ if is_beg? || in_lex_state?(:expr_class) || is_space_arg? then
472
+ result :expr_beg, :tCOLON3, text
473
+ else
474
+ result :expr_dot, :tCOLON2, text
475
+ end
476
+ end
477
+
478
+ def process_brace_open text
479
+ # matching compare/parse23.y:8694
480
+ self.brace_nest += 1
481
+
482
+ if lambda_beginning? then
483
+ self.lpar_beg = nil
484
+ self.paren_nest -= 1 # close arg list when lambda opens body
485
+
486
+ return expr_result(:tLAMBEG, "{")
487
+ end
488
+
489
+ token = case lex_state
490
+ when :expr_labeled then
491
+ :tLBRACE # hash
492
+ when *EXPR_ARG_ANY, :expr_end, :expr_endfn then
493
+ :tLCURLY # block (primary)
494
+ when :expr_endarg
495
+ :tLBRACE_ARG # block (expr)
496
+ else
497
+ :tLBRACE # hash
498
+ end
499
+
500
+ # TODO: self.lex_state |= :expr_label if token != :tLBRACE_ARG
501
+ self.command_start = true if token != :tLBRACE
502
+
503
+ return expr_result(token, "{")
504
+ end
505
+
506
+ def process_float text
507
+ rb_compile_error "Invalid numeric format" if text =~ /__/
508
+
509
+ case
510
+ when text.end_with?('ri')
511
+ return result(:expr_end, :tIMAGINARY, Complex(0, Rational(text.chop.chop)))
512
+ when text.end_with?('r')
513
+ return result(:expr_end, :tRATIONAL, Rational(text.chop))
514
+ when text.end_with?('i')
515
+ return result(:expr_end, :tIMAGINARY, Complex(0, text.chop.to_f))
516
+ else
517
+ return result(:expr_end, :tFLOAT, text.to_f)
518
+ end
519
+ end
520
+
521
+ def process_gvar text
522
+ text.lineno = self.lineno
523
+ result(:expr_end, :tGVAR, text)
524
+ end
525
+
526
+ def process_gvar_oddity text
527
+ return result :expr_end, "$", "$" if text == "$" # TODO: wtf is this?
528
+ rb_compile_error "#{text.inspect} is not allowed as a global variable name"
529
+ end
530
+
531
+ def process_ivar text
532
+ tok_id = text =~ /^@@/ ? :tCVAR : :tIVAR
533
+ text.lineno = self.lineno
534
+ return result(:expr_end, tok_id, text)
535
+ end
536
+
537
+ def process_lchevron text
538
+ if (!in_lex_state?(:expr_dot, :expr_class) &&
539
+ !is_end? &&
540
+ (!is_arg? || space_seen)) then # TODO: || in_state(:expr_labeled)
541
+ tok = self.heredoc_identifier
542
+ return tok if tok
543
+ end
544
+
545
+ if in_arg_state? then
546
+ self.lex_state = :expr_arg
547
+ else
548
+ self.command_start = true if lex_state == :expr_class
549
+ self.lex_state = :expr_beg
550
+ end
551
+
552
+ return result(lex_state, :tLSHFT, "\<\<")
553
+ end
554
+
555
+ def process_newline_or_comment text
556
+ c = matched
557
+ hit = false
558
+
559
+ if c == '#' then
560
+ ss.pos -= 1
561
+
562
+ # TODO: handle magic comments
563
+ while scan(/\s*\#.*(\n+|\z)/) do
564
+ hit = true
565
+ self.lineno += matched.lines.to_a.size
566
+ @comments << matched.gsub(/^ +#/, '#').gsub(/^ +$/, '')
567
+ end
568
+
569
+ return nil if end_of_stream?
570
+ end
571
+
572
+ self.lineno += 1 unless hit
573
+
574
+ # Replace a string of newlines with a single one
575
+ self.lineno += matched.lines.to_a.size if scan(/\n+/)
576
+
577
+ # TODO: remove :expr_value -- audit all uses of it
578
+ c = in_lex_state?(:expr_beg, :expr_value, :expr_class,
579
+ :expr_fname, :expr_dot) && !in_lex_state?(:expr_labeled)
580
+
581
+ # TODO: figure out what token_seen is for
582
+ # TODO: if c || self.lex_state == [:expr_beg, :expr_labeled] then
583
+ if c || self.lex_state == :expr_labeled then
584
+ # ignore if !fallthrough?
585
+ if !c && parser.in_kwarg then
586
+ # normal newline
587
+ return result(:expr_beg, :tNL, nil)
588
+ else
589
+ return # skip
590
+ end
591
+ end
592
+
593
+ if scan(/([\ \t\r\f\v]*)(\.|&)/) then
594
+ self.space_seen = true unless ss[1].empty?
595
+
596
+ ss.pos -= 1
597
+ return unless check(/\.\./)
598
+ end
599
+
600
+ self.command_start = true
601
+
602
+ return result(:expr_beg, :tNL, nil)
603
+ end
604
+
605
+ def process_nthref text
606
+ # TODO: can't do lineno hack w/ number
607
+ result :expr_end, :tNTH_REF, ss[1].to_i
608
+ end
609
+
610
+ def process_paren text
611
+ token = if ruby18 then
612
+ process_paren18
613
+ else
614
+ process_paren19
615
+ end
616
+
617
+ self.paren_nest += 1
618
+
619
+ # TODO: add :expr_label to :expr_beg (set in expr_result below)
620
+ return expr_result(token, "(")
621
+ end
622
+
623
+ def process_paren18
624
+ self.command_start = true
625
+ token = :tLPAREN2
626
+
627
+ if in_lex_state? :expr_beg, :expr_mid then
628
+ token = :tLPAREN
629
+ elsif space_seen then
630
+ if in_lex_state? :expr_cmdarg then
631
+ token = :tLPAREN_ARG
632
+ elsif in_lex_state? :expr_arg then
633
+ warning "don't put space before argument parentheses"
634
+ end
635
+ else
636
+ # not a ternary -- do nothing?
637
+ end
638
+
639
+ token
640
+ end
641
+
642
+ def process_paren19
643
+ if is_beg? then
644
+ :tLPAREN
645
+ elsif is_space_arg? then
646
+ :tLPAREN_ARG
647
+ else
648
+ :tLPAREN2 # plain '(' in parse.y
649
+ end
650
+ end
651
+
652
+ def process_percent text
653
+ return parse_quote if is_beg?
654
+
655
+ return result(:expr_beg, :tOP_ASGN, "%") if scan(/\=/)
656
+
657
+ return parse_quote if is_arg? && space_seen && ! check(/\s/)
658
+
659
+ return result(:arg_state, :tPERCENT, "%")
660
+ end
661
+
662
+ def process_plus_minus text
663
+ sign = matched
664
+ utype, type = if sign == "+" then
665
+ [:tUPLUS, :tPLUS]
666
+ else
667
+ [:tUMINUS, :tMINUS]
668
+ end
669
+
670
+ if in_arg_state? then
671
+ if scan(/@/) then
672
+ return result(:expr_arg, utype, "#{sign}@")
673
+ else
674
+ return result(:expr_arg, type, sign)
675
+ end
676
+ end
677
+
678
+ return result(:expr_beg, :tOP_ASGN, sign) if scan(/\=/)
679
+
680
+ if (is_beg? || (is_arg? && space_seen && !check(/\s/))) then
681
+ arg_ambiguous if is_arg?
682
+
683
+ if check(/\d/) then
684
+ return nil if utype == :tUPLUS
685
+ return result(:expr_beg, :tUMINUS_NUM, sign)
686
+ end
687
+
688
+ return result(:expr_beg, utype, sign)
689
+ end
690
+
691
+ return result(:expr_beg, type, sign)
692
+ end
693
+
694
+ def process_questionmark text
695
+ if is_end? then
696
+ state = ruby18 ? :expr_beg : :expr_value # HACK?
697
+ return result(state, :tEH, "?")
698
+ end
699
+
700
+ if end_of_stream? then
701
+ rb_compile_error "incomplete character syntax: parsed #{text.inspect}"
702
+ end
703
+
704
+ if check(/\s|\v/) then
705
+ unless is_arg? then
706
+ c2 = { " " => 's',
707
+ "\n" => 'n',
708
+ "\t" => 't',
709
+ "\v" => 'v',
710
+ "\r" => 'r',
711
+ "\f" => 'f' }[matched]
712
+
713
+ if c2 then
714
+ warning("invalid character syntax; use ?\\" + c2)
715
+ end
716
+ end
717
+
718
+ # ternary
719
+ state = ruby18 ? :expr_beg : :expr_value # HACK?
720
+ return result(state, :tEH, "?")
721
+ elsif check(/\w(?=\w)/) then # ternary, also
722
+ return result(:expr_beg, :tEH, "?")
723
+ end
724
+
725
+ c = if scan(/\\/) then
726
+ self.read_escape
727
+ else
728
+ ss.getch
729
+ end
730
+
731
+ if version == 18 then
732
+ return result(:expr_end, :tINTEGER, c[0].ord & 0xff)
733
+ else
734
+ return result(:expr_end, :tSTRING, c)
735
+ end
736
+ end
737
+
738
+ def process_slash text
739
+ if is_beg? then
740
+ string STR_REGEXP
741
+
742
+ return result(nil, :tREGEXP_BEG, "/")
743
+ end
744
+
745
+ if scan(/\=/) then
746
+ return result(:expr_beg, :tOP_ASGN, "/")
747
+ end
748
+
749
+ if is_arg? && space_seen then
750
+ unless scan(/\s/) then
751
+ arg_ambiguous
752
+ string STR_REGEXP, "/"
753
+ return result(nil, :tREGEXP_BEG, "/")
754
+ end
755
+ end
756
+
757
+ return result(:arg_state, :tDIVIDE, "/")
758
+ end
759
+
760
+ def process_square_bracket text
761
+ self.paren_nest += 1
762
+
763
+ token = nil
764
+
765
+ if in_arg_state? then
766
+ case
767
+ when scan(/\]\=/) then
768
+ self.paren_nest -= 1 # HACK? I dunno, or bug in MRI
769
+ return result(:expr_arg, :tASET, "[]=")
770
+ when scan(/\]/) then
771
+ self.paren_nest -= 1 # HACK? I dunno, or bug in MRI
772
+ return result(:expr_arg, :tAREF, "[]")
773
+ else
774
+ rb_compile_error "unexpected '['"
775
+ end
776
+ elsif is_beg? then
777
+ token = :tLBRACK
778
+ elsif is_arg? && space_seen then
779
+ token = :tLBRACK
780
+ else
781
+ token = :tLBRACK2
782
+ end
783
+
784
+ # TODO: this is done by expr_result except "|EXPR_LABEL")
785
+ # SET_LEX_STATE(EXPR_BEG|EXPR_LABEL);
786
+ expr_result token, "["
787
+ end
788
+
789
+ def possibly_escape_string text, check
790
+ content = match[1]
791
+
792
+ if text =~ check then
793
+ content.gsub(ESC) { unescape $1 }
794
+ else
795
+ content.gsub(/\\\\/, "\\").gsub(/\\'/, "'")
796
+ end
797
+ end
798
+
799
+ def process_symbol text
800
+ symbol = possibly_escape_string text, /^:"/
801
+
802
+ rb_compile_error "symbol cannot contain '\\0'" if
803
+ ruby18 && symbol =~ /\0/
804
+
805
+ return result(:expr_end, :tSYMBOL, symbol)
806
+ end
807
+
808
+ def was_label?
809
+ @was_label = ruby22_label?
810
+ true
811
+ end
812
+
813
+ def process_label_or_string text
814
+ if @was_label && text =~ /:\Z/ then
815
+ @was_label = nil
816
+ return process_label text
817
+ elsif text =~ /:\Z/ then
818
+ ss.pos -= 1 # put back ":"
819
+ text = text[0..-2]
820
+ end
821
+
822
+ result :expr_end, :tSTRING, text[1..-2].gsub(/\\\\/, "\\").gsub(/\\'/, "'")
823
+ end
824
+
825
+ def process_label text
826
+ symbol = possibly_escape_string text, /^"/
827
+
828
+ result(:expr_labeled, :tLABEL, [symbol, self.lineno]) # TODO: expr_arg|expr_labeled
829
+ end
830
+
831
+ def process_token text
832
+ # matching: parse_ident in compare/parse23.y:7989
833
+ # TODO: make this always return [token, lineno]
834
+ self.last_state = lex_state
835
+
836
+ token = self.token = text
837
+ token << matched if scan(/[\!\?](?!=)/)
838
+
839
+ tok_id =
840
+ case
841
+ when token =~ /[!?]$/ then
842
+ :tFID
843
+ when in_lex_state?(:expr_fname) && scan(/=(?:(?![~>=])|(?==>))/) then
844
+ # ident=, not =~ => == or followed by =>
845
+ # TODO test lexing of a=>b vs a==>b
846
+ token << matched
847
+ :tIDENTIFIER
848
+ when token =~ /^[A-Z]/ then
849
+ :tCONSTANT
850
+ else
851
+ :tIDENTIFIER
852
+ end
853
+
854
+ if !ruby18 and is_label_possible? and is_label_suffix? then
855
+ scan(/:/)
856
+ # TODO: :expr_arg|:expr_labeled
857
+ return result :expr_labeled, :tLABEL, [token, self.lineno]
858
+ end
859
+
860
+ # TODO: mb == ENC_CODERANGE_7BIT && !in_lex_state?(:expr_dot)
861
+ unless in_lex_state? :expr_dot then
862
+ # See if it is a reserved word.
863
+ keyword = if ruby18 then # REFACTOR need 18/19 lexer subclasses
864
+ RubyParser::Legacy::RubyParserStuff::Keyword.keyword18 token
865
+ else
866
+ RubyParser::Legacy::RubyParserStuff::Keyword.keyword19 token
867
+ end
868
+
869
+ return process_token_keyword keyword if keyword
870
+ end # unless in_lex_state? :expr_dot
871
+
872
+ # matching: compare/parse23.y:8079
873
+ state = if is_beg? or is_arg? or in_lex_state? :expr_dot then
874
+ cmd_state ? :expr_cmdarg : :expr_arg
875
+ elsif not ruby18 and in_lex_state? :expr_fname then
876
+ :expr_endfn
877
+ else
878
+ :expr_end
879
+ end
880
+
881
+ if not [:expr_dot, :expr_fname].include? last_state and
882
+ (tok_id == :tIDENTIFIER) and # not :expr_fname, not attrasgn
883
+ lvar_defined?(token) then
884
+ state = :expr_end # TODO: EXPR_END|EXPR_LABEL
885
+ end
886
+
887
+ token.lineno = self.lineno # yes, on a string. I know... I know...
888
+
889
+ return result(state, tok_id, token)
890
+ end
891
+
892
+ def process_token_keyword keyword
893
+ # matching MIDDLE of parse_ident in compare/parse23.y:8046
894
+ state = lex_state
895
+ self.lex_state = keyword.state
896
+
897
+ value = [token, self.lineno]
898
+
899
+ return result(lex_state, keyword.id0, value) if state == :expr_fname
900
+
901
+ self.command_start = true if lex_state == :expr_beg
902
+
903
+ case
904
+ when keyword.id0 == :kDO then
905
+ case
906
+ when lambda_beginning? then
907
+ self.lpar_beg = nil # lambda_beginning? == FALSE in the body of "-> do ... end"
908
+ self.paren_nest -= 1
909
+ result(lex_state, :kDO_LAMBDA, value)
910
+ when cond.is_in_state then
911
+ result(lex_state, :kDO_COND, value)
912
+ when cmdarg.is_in_state && state != :expr_cmdarg then
913
+ result(lex_state, :kDO_BLOCK, value)
914
+ when [:expr_beg, :expr_endarg].include?(state) then
915
+ result(lex_state, :kDO_BLOCK, value)
916
+ else
917
+ result(lex_state, :kDO, value)
918
+ end
919
+ when [:expr_beg, :expr_labeled].include?(state) then
920
+ result(lex_state, keyword.id0, value)
921
+ when keyword.id0 != keyword.id1 then
922
+ result(:expr_beg, keyword.id1, value) # TODO: :expr_beg|:expr_label
923
+ else
924
+ result(lex_state, keyword.id1, value)
925
+ end
926
+ end
927
+
928
+ def process_underscore text
929
+ ss.unscan # put back "_"
930
+
931
+ if beginning_of_line? && scan(/\__END__(\r?\n|\Z)/) then
932
+ return [RubyLexer::EOF, RubyLexer::EOF]
933
+ elsif scan(/\_\w*/) then
934
+ return process_token matched
935
+ end
936
+ end
937
+
938
+ def rb_compile_error msg
939
+ msg += ". near line #{self.lineno}: #{ss.rest[/^.*/].inspect}"
940
+ raise RubyParser::SyntaxError, msg
941
+ end
942
+
943
+ def read_escape # TODO: remove / rewrite
944
+ case
945
+ when scan(/\\/) then # Backslash
946
+ '\\'
947
+ when scan(/n/) then # newline
948
+ self.extra_lineno -= 1
949
+ "\n"
950
+ when scan(/t/) then # horizontal tab
951
+ "\t"
952
+ when scan(/r/) then # carriage-return
953
+ "\r"
954
+ when scan(/f/) then # form-feed
955
+ "\f"
956
+ when scan(/v/) then # vertical tab
957
+ "\13"
958
+ when scan(/a/) then # alarm(bell)
959
+ "\007"
960
+ when scan(/e/) then # escape
961
+ "\033"
962
+ when scan(/b/) then # backspace
963
+ "\010"
964
+ when scan(/s/) then # space
965
+ " "
966
+ when scan(/[0-7]{1,3}/) then # octal constant
967
+ (matched.to_i(8) & 0xFF).chr
968
+ when scan(/x([0-9a-fA-F]{1,2})/) then # hex constant
969
+ ss[1].to_i(16).chr
970
+ when check(/M-\\[\\MCc]/) then
971
+ scan(/M-\\/) # eat it
972
+ c = self.read_escape
973
+ c[0] = (c[0].ord | 0x80).chr
974
+ c
975
+ when scan(/M-(.)/) then
976
+ c = ss[1]
977
+ c[0] = (c[0].ord | 0x80).chr
978
+ c
979
+ when check(/(C-|c)\\[\\MCc]/) then
980
+ scan(/(C-|c)\\/) # eat it
981
+ c = self.read_escape
982
+ c[0] = (c[0].ord & 0x9f).chr
983
+ c
984
+ when scan(/C-\?|c\?/) then
985
+ 127.chr
986
+ when scan(/(C-|c)(.)/) then
987
+ c = ss[2]
988
+ c[0] = (c[0].ord & 0x9f).chr
989
+ c
990
+ when scan(/^[89]/i) then # bad octal or hex... MRI ignores them :(
991
+ matched
992
+ when scan(/u([0-9a-fA-F]{2,4}|\{[0-9a-fA-F]{2,6}\})/) then
993
+ [ss[1].delete("{}").to_i(16)].pack("U")
994
+ when scan(/[McCx0-9]/) || end_of_stream? then
995
+ rb_compile_error("Invalid escape character syntax")
996
+ else
997
+ ss.getch
998
+ end.dup
999
+ end
1000
+
1001
+ def regx_options # TODO: rewrite / remove
1002
+ good, bad = [], []
1003
+
1004
+ if scan(/[a-z]+/) then
1005
+ good, bad = matched.split(//).partition { |s| s =~ /^[ixmonesu]$/ }
1006
+ end
1007
+
1008
+ unless bad.empty? then
1009
+ rb_compile_error("unknown regexp option%s - %s" %
1010
+ [(bad.size > 1 ? "s" : ""), bad.join.inspect])
1011
+ end
1012
+
1013
+ return good.join
1014
+ end
1015
+
1016
+ def reset
1017
+ self.brace_nest = 0
1018
+ self.command_start = true
1019
+ self.comments = []
1020
+ self.lex_state = :expr_none
1021
+ self.lex_strterm = nil
1022
+ self.lineno = 1
1023
+ self.lpar_beg = nil
1024
+ self.paren_nest = 0
1025
+ self.space_seen = false
1026
+ self.string_nest = 0
1027
+ self.token = nil
1028
+ self.extra_lineno = 0
1029
+
1030
+ self.cond.reset
1031
+ self.cmdarg.reset
1032
+ end
1033
+
1034
+ def result lex_state, token, text # :nodoc:
1035
+ lex_state = self.arg_state if lex_state == :arg_state
1036
+ self.lex_state = lex_state if lex_state
1037
+ [token, text]
1038
+ end
1039
+
1040
+ def ruby18
1041
+ RubyParser::V18 === parser
1042
+ end
1043
+
1044
+ def ruby19
1045
+ RubyParser::V19 === parser
1046
+ end
1047
+
1048
+ def scan re
1049
+ ss.scan re
1050
+ end
1051
+
1052
+ def check re
1053
+ ss.check re
1054
+ end
1055
+
1056
+ def eat_whitespace
1057
+ r = scan(/\s+/)
1058
+ self.extra_lineno += r.count("\n") if r
1059
+ r
1060
+ end
1061
+
1062
+ def fixup_lineno extra = 0
1063
+ self.lineno += self.extra_lineno + extra
1064
+ self.extra_lineno = 0
1065
+ end
1066
+
1067
+ def scanner_class # TODO: design this out of oedipus_lex. or something.
1068
+ RPStringScanner
1069
+ end
1070
+
1071
+ def space_vs_beginning space_type, beg_type, fallback
1072
+ if is_space_arg? check(/./m) then
1073
+ warning "`**' interpreted as argument prefix"
1074
+ space_type
1075
+ elsif is_beg? then
1076
+ beg_type
1077
+ else
1078
+ # TODO: warn_balanced("**", "argument prefix");
1079
+ fallback
1080
+ end
1081
+ end
1082
+
1083
+ def string type, beg = matched, nnd = "\0"
1084
+ self.lex_strterm = [:strterm, type, beg, nnd]
1085
+ end
1086
+
1087
+ # TODO: consider
1088
+ # def src= src
1089
+ # raise "bad src: #{src.inspect}" unless String === src
1090
+ # @src = RPStringScanner.new(src)
1091
+ # end
1092
+
1093
+ def tokadd_escape term # TODO: rewrite / remove
1094
+ case
1095
+ when scan(/\\\n/) then
1096
+ # just ignore
1097
+ when scan(/\\([0-7]{1,3}|x[0-9a-fA-F]{1,2})/) then
1098
+ self.string_buffer << matched
1099
+ when scan(/\\([MC]-|c)(?=\\)/) then
1100
+ self.string_buffer << matched
1101
+ self.tokadd_escape term
1102
+ when scan(/\\([MC]-|c)(.)/) then
1103
+ self.string_buffer << matched
1104
+ when scan(/\\[McCx]/) then
1105
+ rb_compile_error "Invalid escape character syntax"
1106
+ when scan(/\\(.)/m) then
1107
+ chr = ss[1]
1108
+ prev = self.string_buffer.last
1109
+ if term == chr && prev && prev.end_with?("(?") then
1110
+ self.string_buffer << chr
1111
+ else
1112
+ self.string_buffer << matched
1113
+ end
1114
+ else
1115
+ rb_compile_error "Invalid escape character syntax"
1116
+ end
1117
+ end
1118
+
1119
+ def tokadd_string(func, term, paren) # TODO: rewrite / remove
1120
+ qwords = (func & STR_FUNC_QWORDS) != 0
1121
+ escape = (func & STR_FUNC_ESCAPE) != 0
1122
+ expand = (func & STR_FUNC_EXPAND) != 0
1123
+ regexp = (func & STR_FUNC_REGEXP) != 0
1124
+ symbol = (func & STR_FUNC_SYMBOL) != 0
1125
+
1126
+ paren_re = @@regexp_cache[paren]
1127
+ term_re = @@regexp_cache[term]
1128
+
1129
+ until end_of_stream? do
1130
+ c = nil
1131
+ handled = true
1132
+
1133
+ case
1134
+ when paren_re && scan(paren_re) then
1135
+ self.string_nest += 1
1136
+ when scan(term_re) then
1137
+ if self.string_nest == 0 then
1138
+ ss.pos -= 1
1139
+ break
1140
+ else
1141
+ self.string_nest -= 1
1142
+ end
1143
+ when expand && scan(/#(?=[\$\@\{])/) then
1144
+ ss.pos -= 1
1145
+ break
1146
+ when qwords && scan(/\s/) then
1147
+ ss.pos -= 1
1148
+ break
1149
+ when expand && scan(/#(?!\n)/) then
1150
+ # do nothing
1151
+ when check(/\\/) then
1152
+ case
1153
+ when qwords && scan(/\\\n/) then
1154
+ string_buffer << "\n"
1155
+ next
1156
+ when qwords && scan(/\\\s/) then
1157
+ c = ' '
1158
+ when expand && scan(/\\\n/) then
1159
+ next
1160
+ when regexp && check(/\\/) then
1161
+ self.tokadd_escape term
1162
+ next
1163
+ when expand && scan(/\\/) then
1164
+ c = self.read_escape
1165
+ when scan(/\\\n/) then
1166
+ # do nothing
1167
+ when scan(/\\\\/) then
1168
+ string_buffer << '\\' if escape
1169
+ c = '\\'
1170
+ when scan(/\\/) then
1171
+ unless scan(term_re) || paren.nil? || scan(paren_re) then
1172
+ string_buffer << "\\"
1173
+ end
1174
+ else
1175
+ handled = false
1176
+ end # inner /\\/ case
1177
+ else
1178
+ handled = false
1179
+ end # top case
1180
+
1181
+ unless handled then
1182
+ t = Regexp.escape term
1183
+ x = Regexp.escape(paren) if paren && paren != "\000"
1184
+ re = if qwords then
1185
+ if HAS_ENC then
1186
+ /[^#{t}#{x}\#\0\\\s]+|./ # |. to pick up whatever
1187
+ else
1188
+ /[^#{t}#{x}\#\0\\\s\v]+|./ # argh. 1.8's \s doesn't pick up \v
1189
+ end
1190
+ else
1191
+ /[^#{t}#{x}\#\0\\]+|./
1192
+ end
1193
+
1194
+ scan re
1195
+ c = matched
1196
+
1197
+ rb_compile_error "symbol cannot contain '\\0'" if symbol && c =~ /\0/
1198
+ end # unless handled
1199
+
1200
+ c ||= matched
1201
+ string_buffer << c
1202
+ end # until
1203
+
1204
+ c ||= matched
1205
+ c = RubyLexer::EOF if end_of_stream?
1206
+
1207
+ return c
1208
+ end
1209
+
1210
+ def unescape s
1211
+ r = ESCAPES[s]
1212
+
1213
+ self.extra_lineno += 1 if s == "\n" # eg backslash newline strings
1214
+ self.extra_lineno -= 1 if r && s == "n" # literal \n, not newline
1215
+
1216
+ return r if r
1217
+
1218
+ x = case s
1219
+ when /^[0-7]{1,3}/ then
1220
+ ($&.to_i(8) & 0xFF).chr
1221
+ when /^x([0-9a-fA-F]{1,2})/ then
1222
+ $1.to_i(16).chr
1223
+ when /^M-(.)/ then
1224
+ ($1[0].ord | 0x80).chr
1225
+ when /^(C-|c)(.)/ then
1226
+ ($2[0].ord & 0x9f).chr
1227
+ when /^[89a-f]/i then # bad octal or hex... ignore? that's what MRI does :(
1228
+ s
1229
+ when /^[McCx0-9]/ then
1230
+ rb_compile_error("Invalid escape character syntax")
1231
+ when /u([0-9a-fA-F]{2,4}|\{[0-9a-fA-F]{2,6}\})/ then
1232
+ [$1.delete("{}").to_i(16)].pack("U")
1233
+ else
1234
+ s
1235
+ end
1236
+ x.force_encoding "UTF-8" if HAS_ENC
1237
+ x
1238
+ end
1239
+
1240
+ def warning s
1241
+ # do nothing for now
1242
+ end
1243
+
1244
+ def ruby22plus?
1245
+ parser.class.version >= 22
1246
+ end
1247
+
1248
+ def ruby23plus?
1249
+ parser.class.version >= 23
1250
+ end
1251
+
1252
+ def process_string # TODO: rewrite / remove
1253
+ # matches top of parser_yylex in compare/parse23.y:8113
1254
+ token = if lex_strterm[0] == :heredoc then
1255
+ self.heredoc lex_strterm
1256
+ else
1257
+ self.parse_string lex_strterm
1258
+ end
1259
+
1260
+ token_type, c = token
1261
+
1262
+ # matches parser_string_term
1263
+ if ruby22plus? && token_type == :tSTRING_END && ["'", '"'].include?(c) then
1264
+ if (([:expr_beg, :expr_endfn].include?(lex_state) &&
1265
+ !cond.is_in_state) || is_arg?) &&
1266
+ is_label_suffix? then
1267
+ scan(/:/)
1268
+ token_type = token[0] = :tLABEL_END
1269
+ end
1270
+ end
1271
+
1272
+ if [:tSTRING_END, :tREGEXP_END, :tLABEL_END].include? token_type then
1273
+ self.lex_strterm = nil
1274
+ # TODO: :expr_beg|:expr_label
1275
+ self.lex_state = (token_type == :tLABEL_END) ? :expr_label : :expr_end
1276
+ end
1277
+
1278
+ return token
1279
+ end
1280
+
1281
+ def parse_quote # TODO: remove / rewrite
1282
+ beg, nnd, short_hand, c = nil, nil, false, nil
1283
+
1284
+ if scan(/[a-z0-9]{1,2}/i) then # Long-hand (e.g. %Q{}).
1285
+ rb_compile_error "unknown type of %string" if ss.matched_size == 2
1286
+ c, beg, short_hand = matched, ss.getch, false
1287
+ else # Short-hand (e.g. %{, %., %!, etc)
1288
+ c, beg, short_hand = 'Q', ss.getch, true
1289
+ end
1290
+
1291
+ if end_of_stream? or c == RubyLexer::EOF or beg == RubyLexer::EOF then
1292
+ rb_compile_error "unterminated quoted string meets end of file"
1293
+ end
1294
+
1295
+ # Figure nnd-char. "\0" is special to indicate beg=nnd and that no nesting?
1296
+ nnd = { "(" => ")", "[" => "]", "{" => "}", "<" => ">" }[beg]
1297
+ nnd, beg = beg, "\0" if nnd.nil?
1298
+
1299
+ token_type, text = nil, "%#{c}#{beg}"
1300
+ token_type, string_type = case c
1301
+ when 'Q' then
1302
+ ch = short_hand ? nnd : c + beg
1303
+ text = "%#{ch}"
1304
+ [:tSTRING_BEG, STR_DQUOTE]
1305
+ when 'q' then
1306
+ [:tSTRING_BEG, STR_SQUOTE]
1307
+ when 'W' then
1308
+ eat_whitespace
1309
+ [:tWORDS_BEG, STR_DQUOTE | STR_FUNC_QWORDS]
1310
+ when 'w' then
1311
+ eat_whitespace
1312
+ [:tQWORDS_BEG, STR_SQUOTE | STR_FUNC_QWORDS]
1313
+ when 'x' then
1314
+ [:tXSTRING_BEG, STR_XQUOTE]
1315
+ when 'r' then
1316
+ [:tREGEXP_BEG, STR_REGEXP]
1317
+ when 's' then
1318
+ self.lex_state = :expr_fname
1319
+ [:tSYMBEG, STR_SSYM]
1320
+ when 'I' then
1321
+ eat_whitespace
1322
+ [:tSYMBOLS_BEG, STR_DQUOTE | STR_FUNC_QWORDS]
1323
+ when 'i' then
1324
+ eat_whitespace
1325
+ [:tQSYMBOLS_BEG, STR_SQUOTE | STR_FUNC_QWORDS]
1326
+ end
1327
+
1328
+ rb_compile_error "Bad %string type. Expected [QqWwIixrs], found '#{c}'." if
1329
+ token_type.nil?
1330
+
1331
+ raise "huh" unless string_type
1332
+
1333
+ string string_type, nnd, beg
1334
+
1335
+ return token_type, text
1336
+ end
1337
+
1338
+ def parse_string quote # TODO: rewrite / remove
1339
+ _, string_type, term, open = quote
1340
+
1341
+ space = false # FIX: remove these
1342
+ func = string_type
1343
+ paren = open
1344
+ term_re = @@regexp_cache[term]
1345
+
1346
+ qwords = (func & STR_FUNC_QWORDS) != 0
1347
+ regexp = (func & STR_FUNC_REGEXP) != 0
1348
+ expand = (func & STR_FUNC_EXPAND) != 0
1349
+
1350
+ unless func then # nil'ed from qwords below. *sigh*
1351
+ return :tSTRING_END, nil
1352
+ end
1353
+
1354
+ space = true if qwords and eat_whitespace
1355
+
1356
+ if self.string_nest == 0 && scan(/#{term_re}/) then
1357
+ if qwords then
1358
+ quote[1] = nil
1359
+ return :tSPACE, nil
1360
+ elsif regexp then
1361
+ return :tREGEXP_END, self.regx_options
1362
+ else
1363
+ return :tSTRING_END, term
1364
+ end
1365
+ end
1366
+
1367
+ return :tSPACE, nil if space
1368
+
1369
+ self.string_buffer = []
1370
+
1371
+ if expand
1372
+ case
1373
+ when scan(/#(?=\$(-.|[a-zA-Z_0-9~\*\$\?!@\/\\;,\.=:<>\"\&\`\'+]))/) then
1374
+ # TODO: !ISASCII
1375
+ # ?! see parser_peek_variable_name
1376
+ return :tSTRING_DVAR, nil
1377
+ when scan(/#(?=\@\@?[a-zA-Z_])/) then
1378
+ # TODO: !ISASCII
1379
+ return :tSTRING_DVAR, nil
1380
+ when scan(/#[{]/) then
1381
+ self.command_start = true
1382
+ return :tSTRING_DBEG, nil
1383
+ when scan(/#/) then
1384
+ string_buffer << '#'
1385
+ end
1386
+ end
1387
+
1388
+ if tokadd_string(func, term, paren) == RubyLexer::EOF then
1389
+ rb_compile_error "unterminated string meets end of file"
1390
+ end
1391
+
1392
+ return :tSTRING_CONTENT, string_buffer.join
1393
+ end
1394
+ end
1395
+
1396
+ require "ruby_parser/legacy/ruby_lexer.rex"
1397
+
1398
+ if ENV["RP_LINENO_DEBUG"] then
1399
+ class RubyParser::Legacy::RubyLexer
1400
+ alias :old_lineno= :lineno=
1401
+
1402
+ def d o
1403
+ $stderr.puts o.inspect
1404
+ end
1405
+
1406
+ def lineno= n
1407
+ self.old_lineno= n
1408
+ where = caller.first.split(/:/).first(2).join(":")
1409
+ d :lineno => [n, where, ss && ss.rest[0,40]]
1410
+ end
1411
+ end
1412
+ end