brakeman 4.8.0 → 5.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (273) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +144 -2
  3. data/README.md +23 -6
  4. data/bundle/load.rb +7 -5
  5. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/CHANGELOG.md +24 -0
  6. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/FAQ.md +0 -0
  7. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/Gemfile +1 -4
  8. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/MIT-LICENSE +0 -0
  9. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/README.md +21 -16
  10. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/REFERENCE.md +39 -10
  11. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/TODO +0 -0
  12. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/haml.gemspec +2 -1
  13. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/attribute_builder.rb +58 -3
  14. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/attribute_compiler.rb +45 -32
  15. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/attribute_parser.rb +0 -0
  16. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/buffer.rb +0 -56
  17. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/compiler.rb +0 -0
  18. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/engine.rb +0 -0
  19. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/error.rb +0 -0
  20. data/bundle/ruby/2.7.0/gems/haml-5.2.2/lib/haml/escapable.rb +77 -0
  21. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/exec.rb +0 -0
  22. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/filters.rb +0 -0
  23. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/generator.rb +0 -0
  24. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/helpers/action_view_extensions.rb +0 -0
  25. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/helpers/action_view_mods.rb +0 -0
  26. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/helpers/action_view_xss_mods.rb +0 -0
  27. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/helpers/safe_erubi_template.rb +0 -0
  28. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/helpers/safe_erubis_template.rb +0 -0
  29. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/helpers/xss_mods.rb +6 -3
  30. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/helpers.rb +7 -1
  31. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/options.rb +0 -0
  32. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/parser.rb +32 -4
  33. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/plugin.rb +18 -1
  34. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/railtie.rb +5 -0
  35. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/sass_rails_filter.rb +0 -0
  36. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/template/options.rb +0 -0
  37. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/template.rb +0 -0
  38. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/temple_engine.rb +2 -1
  39. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/temple_line_counter.rb +0 -0
  40. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/util.rb +1 -1
  41. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/version.rb +1 -1
  42. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml.rb +0 -0
  43. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/yard/default/fulldoc/html/css/common.sass +0 -0
  44. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → 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/rexml-3.2.5/LICENSE.txt +22 -0
  50. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/NEWS.md +178 -0
  51. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/README.md +48 -0
  52. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/attlistdecl.rb +63 -0
  53. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/attribute.rb +205 -0
  54. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/cdata.rb +68 -0
  55. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/child.rb +97 -0
  56. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/comment.rb +80 -0
  57. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/doctype.rb +311 -0
  58. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/document.rb +451 -0
  59. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/dtd/attlistdecl.rb +11 -0
  60. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/dtd/dtd.rb +47 -0
  61. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/dtd/elementdecl.rb +18 -0
  62. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/dtd/entitydecl.rb +57 -0
  63. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/dtd/notationdecl.rb +40 -0
  64. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/element.rb +2599 -0
  65. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/encoding.rb +51 -0
  66. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/entity.rb +171 -0
  67. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/formatters/default.rb +116 -0
  68. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/formatters/pretty.rb +142 -0
  69. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/formatters/transitive.rb +58 -0
  70. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/functions.rb +447 -0
  71. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/instruction.rb +79 -0
  72. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/light/node.rb +188 -0
  73. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/namespace.rb +59 -0
  74. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/node.rb +76 -0
  75. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/output.rb +30 -0
  76. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/parent.rb +166 -0
  77. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/parseexception.rb +52 -0
  78. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/parsers/baseparser.rb +694 -0
  79. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/parsers/lightparser.rb +59 -0
  80. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/parsers/pullparser.rb +197 -0
  81. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/parsers/sax2parser.rb +273 -0
  82. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/parsers/streamparser.rb +61 -0
  83. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/parsers/treeparser.rb +101 -0
  84. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/parsers/ultralightparser.rb +57 -0
  85. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/parsers/xpathparser.rb +689 -0
  86. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/quickpath.rb +266 -0
  87. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/rexml.rb +37 -0
  88. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/sax2listener.rb +98 -0
  89. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/security.rb +28 -0
  90. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/source.rb +298 -0
  91. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/streamlistener.rb +93 -0
  92. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/text.rb +424 -0
  93. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/undefinednamespaceexception.rb +9 -0
  94. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/validation/relaxng.rb +539 -0
  95. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/validation/validation.rb +144 -0
  96. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/validation/validationexception.rb +10 -0
  97. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/xmldecl.rb +130 -0
  98. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/xmltokens.rb +85 -0
  99. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/xpath.rb +81 -0
  100. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/xpath_parser.rb +974 -0
  101. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml.rb +3 -0
  102. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.18.1}/History.rdoc +148 -0
  103. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.18.1}/Manifest.txt +7 -0
  104. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.18.1}/README.rdoc +1 -0
  105. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.18.1}/compare/normalize.rb +51 -6
  106. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/debugging.md +190 -0
  107. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/gauntlet.md +106 -0
  108. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.18.1}/lib/rp_extensions.rb +15 -36
  109. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/rp_stringscanner.rb +33 -0
  110. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby20_parser.rb +7128 -0
  111. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.18.1}/lib/ruby20_parser.y +420 -296
  112. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby21_parser.rb +7182 -0
  113. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.18.1}/lib/ruby21_parser.y +415 -293
  114. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby22_parser.rb +7228 -0
  115. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.18.1}/lib/ruby22_parser.y +419 -295
  116. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby23_parser.rb +7237 -0
  117. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.18.1}/lib/ruby23_parser.y +419 -295
  118. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby24_parser.rb +7268 -0
  119. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.18.1}/lib/ruby24_parser.y +419 -295
  120. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby25_parser.rb +7268 -0
  121. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2/lib/ruby26_parser.y → ruby_parser-3.18.1/lib/ruby25_parser.y} +418 -308
  122. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby26_parser.rb +7287 -0
  123. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2/lib/ruby_parser.yy → ruby_parser-3.18.1/lib/ruby26_parser.y} +419 -399
  124. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby27_parser.rb +8517 -0
  125. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2/lib/ruby25_parser.y → ruby_parser-3.18.1/lib/ruby27_parser.y} +1030 -294
  126. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby30_parser.rb +8751 -0
  127. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby30_parser.y +3472 -0
  128. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby3_parser.yy +3476 -0
  129. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.18.1}/lib/ruby_lexer.rb +308 -605
  130. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.18.1}/lib/ruby_lexer.rex +33 -27
  131. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.18.1}/lib/ruby_lexer.rex.rb +65 -31
  132. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby_lexer_strings.rb +638 -0
  133. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.18.1}/lib/ruby_parser.rb +4 -0
  134. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby_parser.yy +3487 -0
  135. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.18.1}/lib/ruby_parser_extras.rb +341 -127
  136. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.18.1}/tools/munge.rb +43 -10
  137. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.18.1}/tools/ripper.rb +15 -10
  138. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.14.1 → sexp_processor-4.16.0}/History.rdoc +39 -0
  139. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.14.1 → sexp_processor-4.16.0}/Manifest.txt +0 -0
  140. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.14.1 → sexp_processor-4.16.0}/README.rdoc +0 -0
  141. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.14.1 → sexp_processor-4.16.0}/lib/composite_sexp_processor.rb +0 -0
  142. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.14.1 → sexp_processor-4.16.0}/lib/pt_testcase.rb +9 -4
  143. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.14.1 → sexp_processor-4.16.0}/lib/sexp.rb +19 -9
  144. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.14.1 → sexp_processor-4.16.0}/lib/sexp_matcher.rb +4 -7
  145. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.14.1 → sexp_processor-4.16.0}/lib/sexp_processor.rb +1 -1
  146. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.14.1 → sexp_processor-4.16.0}/lib/strict_sexp.rb +25 -3
  147. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.14.1 → sexp_processor-4.16.0}/lib/unique.rb +0 -0
  148. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/CHANGES +4 -0
  149. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/Gemfile +12 -13
  150. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/LICENSE +0 -0
  151. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/README.jp.md +0 -0
  152. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/README.md +0 -0
  153. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/code_attributes.rb +0 -0
  154. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/command.rb +13 -13
  155. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/controls.rb +0 -0
  156. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/do_inserter.rb +0 -0
  157. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/embedded.rb +0 -0
  158. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/end_inserter.rb +0 -0
  159. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/engine.rb +0 -0
  160. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/erb_converter.rb +0 -0
  161. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/filter.rb +0 -0
  162. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/grammar.rb +0 -0
  163. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/include.rb +0 -0
  164. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/interpolation.rb +0 -0
  165. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/logic_less/context.rb +0 -0
  166. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/logic_less/filter.rb +0 -0
  167. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/logic_less.rb +0 -0
  168. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/parser.rb +1 -1
  169. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/smart/escaper.rb +0 -0
  170. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/smart/filter.rb +0 -0
  171. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/smart/parser.rb +0 -0
  172. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/smart.rb +0 -0
  173. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/splat/builder.rb +0 -0
  174. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/splat/filter.rb +0 -0
  175. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/template.rb +0 -0
  176. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/translator.rb +0 -0
  177. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/version.rb +1 -1
  178. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim.rb +0 -0
  179. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/slim.gemspec +0 -0
  180. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.6.1 → unicode-display_width-1.8.0}/CHANGELOG.md +8 -0
  181. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.6.1 → unicode-display_width-1.8.0}/MIT-LICENSE.txt +0 -0
  182. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.6.1 → unicode-display_width-1.8.0}/README.md +1 -1
  183. data/bundle/ruby/2.7.0/gems/unicode-display_width-1.8.0/data/display_width.marshal.gz +0 -0
  184. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.6.1 → unicode-display_width-1.8.0}/lib/unicode/display_width/constants.rb +2 -2
  185. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.6.1 → unicode-display_width-1.8.0}/lib/unicode/display_width/index.rb +0 -0
  186. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.6.1 → unicode-display_width-1.8.0}/lib/unicode/display_width/no_string_ext.rb +0 -0
  187. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.6.1 → unicode-display_width-1.8.0}/lib/unicode/display_width/string_ext.rb +0 -0
  188. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.6.1 → unicode-display_width-1.8.0}/lib/unicode/display_width.rb +0 -0
  189. data/lib/brakeman/app_tree.rb +37 -4
  190. data/lib/brakeman/checks/base_check.rb +18 -2
  191. data/lib/brakeman/checks/check_basic_auth.rb +2 -0
  192. data/lib/brakeman/checks/check_csrf_token_forgery_cve.rb +28 -0
  193. data/lib/brakeman/checks/check_deserialize.rb +21 -1
  194. data/lib/brakeman/checks/check_detailed_exceptions.rb +1 -1
  195. data/lib/brakeman/checks/check_eol_rails.rb +23 -0
  196. data/lib/brakeman/checks/check_eol_ruby.rb +26 -0
  197. data/lib/brakeman/checks/check_evaluation.rb +1 -1
  198. data/lib/brakeman/checks/check_execute.rb +12 -1
  199. data/lib/brakeman/checks/check_json_entity_escape.rb +38 -0
  200. data/lib/brakeman/checks/check_json_parsing.rb +1 -1
  201. data/lib/brakeman/checks/check_mass_assignment.rb +37 -9
  202. data/lib/brakeman/checks/check_model_attr_accessible.rb +1 -1
  203. data/lib/brakeman/checks/check_model_attributes.rb +1 -1
  204. data/lib/brakeman/checks/check_page_caching_cve.rb +37 -0
  205. data/lib/brakeman/checks/check_permit_attributes.rb +1 -1
  206. data/lib/brakeman/checks/check_regex_dos.rb +1 -1
  207. data/lib/brakeman/checks/check_render.rb +15 -1
  208. data/lib/brakeman/checks/check_sanitize_methods.rb +2 -1
  209. data/lib/brakeman/checks/check_skip_before_filter.rb +4 -4
  210. data/lib/brakeman/checks/check_sql.rb +60 -9
  211. data/lib/brakeman/checks/check_symbol_dos.rb +1 -1
  212. data/lib/brakeman/checks/check_template_injection.rb +32 -0
  213. data/lib/brakeman/checks/check_unsafe_reflection_methods.rb +68 -0
  214. data/lib/brakeman/checks/check_verb_confusion.rb +75 -0
  215. data/lib/brakeman/checks/eol_check.rb +47 -0
  216. data/lib/brakeman/commandline.rb +25 -1
  217. data/lib/brakeman/file_parser.rb +58 -22
  218. data/lib/brakeman/options.rb +39 -2
  219. data/lib/brakeman/parsers/template_parser.rb +26 -3
  220. data/lib/brakeman/processors/alias_processor.rb +132 -24
  221. data/lib/brakeman/processors/base_processor.rb +4 -4
  222. data/lib/brakeman/processors/controller_alias_processor.rb +6 -43
  223. data/lib/brakeman/processors/controller_processor.rb +1 -1
  224. data/lib/brakeman/processors/gem_processor.rb +3 -0
  225. data/lib/brakeman/processors/haml_template_processor.rb +17 -1
  226. data/lib/brakeman/processors/lib/call_conversion_helper.rb +13 -7
  227. data/lib/brakeman/processors/lib/file_type_detector.rb +64 -0
  228. data/lib/brakeman/processors/lib/find_all_calls.rb +28 -13
  229. data/lib/brakeman/processors/lib/rails3_config_processor.rb +16 -16
  230. data/lib/brakeman/processors/lib/rails3_route_processor.rb +2 -0
  231. data/lib/brakeman/processors/lib/rails4_config_processor.rb +2 -1
  232. data/lib/brakeman/processors/lib/render_helper.rb +3 -1
  233. data/lib/brakeman/processors/library_processor.rb +9 -0
  234. data/lib/brakeman/processors/model_processor.rb +32 -0
  235. data/lib/brakeman/processors/output_processor.rb +1 -1
  236. data/lib/brakeman/processors/template_alias_processor.rb +5 -0
  237. data/lib/brakeman/report/ignore/config.rb +5 -1
  238. data/lib/brakeman/report/ignore/interactive.rb +1 -1
  239. data/lib/brakeman/report/report_base.rb +0 -2
  240. data/lib/brakeman/report/report_csv.rb +37 -60
  241. data/lib/brakeman/report/report_github.rb +31 -0
  242. data/lib/brakeman/report/report_junit.rb +2 -2
  243. data/lib/brakeman/report/report_sarif.rb +133 -0
  244. data/lib/brakeman/report/report_sonar.rb +38 -0
  245. data/lib/brakeman/report/report_tabs.rb +1 -1
  246. data/lib/brakeman/report/report_text.rb +38 -17
  247. data/lib/brakeman/report.rb +19 -1
  248. data/lib/brakeman/rescanner.rb +7 -5
  249. data/lib/brakeman/scanner.rb +65 -31
  250. data/lib/brakeman/tracker/collection.rb +57 -7
  251. data/lib/brakeman/tracker/config.rb +87 -5
  252. data/lib/brakeman/tracker/constants.rb +8 -7
  253. data/lib/brakeman/tracker/controller.rb +1 -1
  254. data/lib/brakeman/tracker/method_info.rb +70 -0
  255. data/lib/brakeman/tracker.rb +42 -5
  256. data/lib/brakeman/util.rb +58 -21
  257. data/lib/brakeman/version.rb +1 -1
  258. data/lib/brakeman/warning.rb +10 -2
  259. data/lib/brakeman/warning_codes.rb +13 -0
  260. data/lib/brakeman.rb +45 -6
  261. data/lib/ruby_parser/bm_sexp.rb +33 -9
  262. metadata +201 -123
  263. data/bundle/ruby/2.7.0/gems/haml-5.1.2/lib/haml/escapable.rb +0 -50
  264. data/bundle/ruby/2.7.0/gems/ruby_parser-3.14.2/debugging.md +0 -18
  265. data/bundle/ruby/2.7.0/gems/ruby_parser-3.14.2/lib/rp_stringscanner.rb +0 -64
  266. data/bundle/ruby/2.7.0/gems/ruby_parser-3.14.2/lib/ruby20_parser.rb +0 -7042
  267. data/bundle/ruby/2.7.0/gems/ruby_parser-3.14.2/lib/ruby21_parser.rb +0 -7113
  268. data/bundle/ruby/2.7.0/gems/ruby_parser-3.14.2/lib/ruby22_parser.rb +0 -7146
  269. data/bundle/ruby/2.7.0/gems/ruby_parser-3.14.2/lib/ruby23_parser.rb +0 -7163
  270. data/bundle/ruby/2.7.0/gems/ruby_parser-3.14.2/lib/ruby24_parser.rb +0 -7175
  271. data/bundle/ruby/2.7.0/gems/ruby_parser-3.14.2/lib/ruby25_parser.rb +0 -7175
  272. data/bundle/ruby/2.7.0/gems/ruby_parser-3.14.2/lib/ruby26_parser.rb +0 -7195
  273. data/bundle/ruby/2.7.0/gems/unicode-display_width-1.6.1/data/display_width.marshal.gz +0 -0
@@ -25,16 +25,15 @@ class RubyLexer
25
25
 
26
26
  HAS_ENC = "".respond_to? :encoding
27
27
 
28
- IDENT_CHAR = if HAS_ENC then
29
- /[\w\u0080-\u{10ffff}]/u
30
- else
31
- /[\w\x80-\xFF]/n
32
- end
28
+ BTOKENS = {
29
+ ".." => :tBDOT2,
30
+ "..." => :tBDOT3,
31
+ }
33
32
 
34
33
  TOKENS = {
35
34
  "!" => :tBANG,
36
35
  "!=" => :tNEQ,
37
- # "!@" => :tUBANG,
36
+ "!@" => :tBANG,
38
37
  "!~" => :tNMATCH,
39
38
  "," => :tCOMMA,
40
39
  ".." => :tDOT2,
@@ -47,17 +46,38 @@ class RubyLexer
47
46
  "->" => :tLAMBDA,
48
47
  }
49
48
 
49
+ PERCENT_END = {
50
+ "(" => ")",
51
+ "[" => "]",
52
+ "{" => "}",
53
+ "<" => ">",
54
+ }
55
+
56
+ SIMPLE_RE_META = /[\$\*\+\.\?\^\|\)\]\}\>]/
57
+
50
58
  @@regexp_cache = Hash.new { |h, k| h[k] = Regexp.new(Regexp.escape(k)) }
51
59
  @@regexp_cache[nil] = nil
52
60
 
61
+ def regexp_cache
62
+ @@regexp_cache
63
+ end
64
+
53
65
  if $DEBUG then
54
66
  attr_reader :lex_state
55
67
 
56
68
  def lex_state= o
57
69
  return if @lex_state == o
58
- raise ArgumentError, "bad state: %p" % [o] unless State === o
59
70
 
60
- warn "lex_state: %p -> %p" % [lex_state, o]
71
+ from = ""
72
+ if ENV["VERBOSE"]
73
+ path = caller[0]
74
+ path = caller[1] if path =~ /result/
75
+ path, line, *_ = path.split(/:/)
76
+ path.delete_prefix! File.dirname File.dirname __FILE__
77
+ from = " at .%s:%s" % [path, line]
78
+ end
79
+
80
+ warn "lex_state: %p -> %p%s" % [lex_state, o, from]
61
81
 
62
82
  @lex_state = o
63
83
  end
@@ -67,14 +87,16 @@ class RubyLexer
67
87
 
68
88
  attr_accessor :lex_state unless $DEBUG
69
89
 
70
- attr_accessor :lineno # we're bypassing oedipus' lineno handling.
71
90
  attr_accessor :brace_nest
72
91
  attr_accessor :cmdarg
73
92
  attr_accessor :command_start
74
93
  attr_accessor :cmd_state # temporary--ivar to avoid passing everywhere
75
94
  attr_accessor :last_state
76
95
  attr_accessor :cond
77
- attr_accessor :extra_lineno
96
+ attr_accessor :old_ss
97
+ attr_accessor :old_lineno
98
+
99
+ # these are generated via ruby_lexer.rex: ss, lineno
78
100
 
79
101
  ##
80
102
  # Additional context surrounding tokens that both the lexer and
@@ -99,6 +121,7 @@ class RubyLexer
99
121
 
100
122
  self.cond = RubyParserStuff::StackState.new(:cond, $DEBUG)
101
123
  self.cmdarg = RubyParserStuff::StackState.new(:cmdarg, $DEBUG)
124
+ self.ss = RPStringScanner.new ""
102
125
 
103
126
  reset
104
127
  end
@@ -111,14 +134,8 @@ class RubyLexer
111
134
  is_after_operator? ? EXPR_ARG : EXPR_BEG
112
135
  end
113
136
 
114
- def beginning_of_line?
115
- ss.bol?
116
- end
117
-
118
- alias bol? beginning_of_line? # to make .rex file more readable
119
-
120
- def check re
121
- ss.check re
137
+ def ignore_body_comments
138
+ @comments.clear
122
139
  end
123
140
 
124
141
  def comments # TODO: remove this... maybe comment_string + attr_accessor
@@ -127,14 +144,8 @@ class RubyLexer
127
144
  c
128
145
  end
129
146
 
130
- def eat_whitespace
131
- r = scan(/\s+/)
132
- self.extra_lineno += r.count("\n") if r
133
- r
134
- end
135
-
136
- def end_of_stream?
137
- ss.eos?
147
+ def debug n
148
+ raise "debug #{n}"
138
149
  end
139
150
 
140
151
  def expr_dot?
@@ -151,123 +162,6 @@ class RubyLexer
151
162
  result EXPR_BEG, token, text
152
163
  end
153
164
 
154
- def fixup_lineno extra = 0
155
- self.lineno += self.extra_lineno + extra
156
- self.extra_lineno = 0
157
- end
158
-
159
- def heredoc here # TODO: rewrite / remove
160
- _, eos, func, last_line = here
161
-
162
- indent = func =~ STR_FUNC_INDENT ? "[ \t]*" : nil
163
- expand = func =~ STR_FUNC_EXPAND
164
- eol = last_line && last_line.end_with?("\r\n") ? "\r\n" : "\n"
165
- eos_re = /#{indent}#{Regexp.escape eos}(#{eol}|\z)/
166
- err_msg = "can't match #{eos_re.inspect} anywhere in "
167
-
168
- rb_compile_error err_msg if end_of_stream?
169
-
170
- if beginning_of_line? && scan(eos_re) then
171
- self.lineno += 1
172
- ss.unread_many last_line # TODO: figure out how to remove this
173
- return :tSTRING_END, [eos, func] # TODO: calculate squiggle width at lex?
174
- end
175
-
176
- self.string_buffer = []
177
-
178
- if expand then
179
- case
180
- when scan(/#[$@]/) then
181
- ss.pos -= 1 # FIX omg stupid
182
- return :tSTRING_DVAR, matched
183
- when scan(/#[{]/) then
184
- return :tSTRING_DBEG, matched
185
- when scan(/#/) then
186
- string_buffer << "#"
187
- end
188
-
189
- begin
190
- c = tokadd_string func, eol, nil
191
-
192
- rb_compile_error err_msg if
193
- c == RubyLexer::EOF
194
-
195
- if c != eol then
196
- return :tSTRING_CONTENT, string_buffer.join
197
- else
198
- string_buffer << scan(/\n/)
199
- end
200
-
201
- rb_compile_error err_msg if end_of_stream?
202
- end until check(eos_re)
203
- else
204
- until check(eos_re) do
205
- string_buffer << scan(/.*(\n|\z)/)
206
- rb_compile_error err_msg if end_of_stream?
207
- end
208
- end
209
-
210
- self.lex_strterm = [:heredoc, eos, func, last_line]
211
-
212
- string_content = begin
213
- s = string_buffer.join
214
- s.b.force_encoding Encoding::UTF_8
215
- end
216
-
217
- return :tSTRING_CONTENT, string_content
218
- end
219
-
220
- def heredoc_identifier # TODO: remove / rewrite
221
- term, func = nil, STR_FUNC_BORING
222
- self.string_buffer = []
223
-
224
- heredoc_indent_mods = "-"
225
- heredoc_indent_mods += '\~' if ruby23plus?
226
-
227
- case
228
- when scan(/([#{heredoc_indent_mods}]?)([\'\"\`])(.*?)\2/) then
229
- term = ss[2]
230
- func |= STR_FUNC_INDENT unless ss[1].empty? # TODO: this seems wrong
231
- func |= STR_FUNC_ICNTNT if ss[1] == "~"
232
- func |= case term
233
- when "\'" then
234
- STR_SQUOTE
235
- when '"' then
236
- STR_DQUOTE
237
- else
238
- STR_XQUOTE
239
- end
240
- string_buffer << ss[3]
241
- when scan(/[#{heredoc_indent_mods}]?([\'\"\`])(?!\1*\Z)/) then
242
- rb_compile_error "unterminated here document identifier"
243
- when scan(/([#{heredoc_indent_mods}]?)(#{IDENT_CHAR}+)/) then
244
- term = '"'
245
- func |= STR_DQUOTE
246
- unless ss[1].empty? then
247
- func |= STR_FUNC_INDENT
248
- func |= STR_FUNC_ICNTNT if ss[1] == "~"
249
- end
250
- string_buffer << ss[2]
251
- else
252
- return nil
253
- end
254
-
255
- if scan(/.*\n/) then
256
- # TODO: think about storing off the char range instead
257
- line = matched
258
- else
259
- line = nil
260
- end
261
-
262
- self.lex_strterm = [:heredoc, string_buffer.join, func, line]
263
-
264
- if term == "`" then
265
- result nil, :tXSTRING_BEG, "`"
266
- else
267
- result nil, :tSTRING_BEG, "\""
268
- end
269
- end
270
-
271
165
  def in_fname? # REFACTOR
272
166
  lex_state =~ EXPR_FNAME
273
167
  end
@@ -278,13 +172,13 @@ class RubyLexer
278
172
  text = matched
279
173
  case
280
174
  when text.end_with?("ri")
281
- return result(EXPR_NUM, :tIMAGINARY, Complex(0, Rational(text.chop.chop.to_i(base))))
175
+ result EXPR_NUM, :tIMAGINARY, Complex(0, Rational(text.chop.chop.to_i(base)))
282
176
  when text.end_with?("r")
283
- return result(EXPR_NUM, :tRATIONAL, Rational(text.chop.to_i(base)))
177
+ result EXPR_NUM, :tRATIONAL, Rational(text.chop.to_i(base))
284
178
  when text.end_with?("i")
285
- return result(EXPR_NUM, :tIMAGINARY, Complex(0, text.chop.to_i(base)))
179
+ result EXPR_NUM, :tIMAGINARY, Complex(0, text.chop.to_i(base))
286
180
  else
287
- return result(EXPR_NUM, :tINTEGER, text.to_i(base))
181
+ result EXPR_NUM, :tINTEGER, text.to_i(base)
288
182
  end
289
183
  end
290
184
 
@@ -320,144 +214,27 @@ class RubyLexer
320
214
  lpar_beg && lpar_beg == paren_nest
321
215
  end
322
216
 
217
+ def is_local_id id
218
+ # maybe just make this false for now
219
+ self.parser.env[id.to_sym] == :lvar # HACK: this isn't remotely right
220
+ end
221
+
323
222
  def lvar_defined? id
324
223
  # TODO: (dyna_in_block? && dvar_defined?(id)) || local_id?(id)
325
224
  self.parser.env[id.to_sym] == :lvar
326
225
  end
327
226
 
328
- def matched
329
- ss.matched
330
- end
331
-
332
227
  def not_end?
333
228
  not is_end?
334
229
  end
335
230
 
336
- def parse_quote # TODO: remove / rewrite
337
- beg, nnd, short_hand, c = nil, nil, false, nil
338
-
339
- if scan(/[a-z0-9]{1,2}/i) then # Long-hand (e.g. %Q{}).
340
- rb_compile_error "unknown type of %string" if ss.matched_size == 2
341
- c, beg, short_hand = matched, ss.getch, false
342
- else # Short-hand (e.g. %{, %., %!, etc)
343
- c, beg, short_hand = "Q", ss.getch, true
344
- end
345
-
346
- if end_of_stream? or c == RubyLexer::EOF or beg == RubyLexer::EOF then
347
- rb_compile_error "unterminated quoted string meets end of file"
348
- end
349
-
350
- # Figure nnd-char. "\0" is special to indicate beg=nnd and that no nesting?
351
- nnd = { "(" => ")", "[" => "]", "{" => "}", "<" => ">" }[beg]
352
- nnd, beg = beg, "\0" if nnd.nil?
353
-
354
- token_type, text = nil, "%#{c}#{beg}"
355
- token_type, string_type = case c
356
- when "Q" then
357
- ch = short_hand ? nnd : c + beg
358
- text = "%#{ch}"
359
- [:tSTRING_BEG, STR_DQUOTE]
360
- when "q" then
361
- [:tSTRING_BEG, STR_SQUOTE]
362
- when "W" then
363
- eat_whitespace
364
- [:tWORDS_BEG, STR_DQUOTE | STR_FUNC_QWORDS]
365
- when "w" then
366
- eat_whitespace
367
- [:tQWORDS_BEG, STR_SQUOTE | STR_FUNC_QWORDS]
368
- when "x" then
369
- [:tXSTRING_BEG, STR_XQUOTE]
370
- when "r" then
371
- [:tREGEXP_BEG, STR_REGEXP]
372
- when "s" then
373
- self.lex_state = EXPR_FNAME
374
- [:tSYMBEG, STR_SSYM]
375
- when "I" then
376
- eat_whitespace
377
- [:tSYMBOLS_BEG, STR_DQUOTE | STR_FUNC_QWORDS]
378
- when "i" then
379
- eat_whitespace
380
- [:tQSYMBOLS_BEG, STR_SQUOTE | STR_FUNC_QWORDS]
381
- end
382
-
383
- rb_compile_error "Bad %string type. Expected [QqWwIixrs], found '#{c}'." if
384
- token_type.nil?
385
-
386
- raise "huh" unless string_type
387
-
388
- string string_type, nnd, beg
389
-
390
- return token_type, text
391
- end
392
-
393
- def parse_string quote # TODO: rewrite / remove
394
- _, string_type, term, open = quote
395
-
396
- space = false # FIX: remove these
397
- func = string_type
398
- paren = open
399
- term_re = @@regexp_cache[term]
400
-
401
- qwords = func =~ STR_FUNC_QWORDS
402
- regexp = func =~ STR_FUNC_REGEXP
403
- expand = func =~ STR_FUNC_EXPAND
404
-
405
- unless func then # nil'ed from qwords below. *sigh*
406
- return :tSTRING_END, nil
407
- end
408
-
409
- space = true if qwords and eat_whitespace
410
-
411
- if self.string_nest == 0 && scan(/#{term_re}/) then
412
- if qwords then
413
- quote[1] = nil
414
- return :tSPACE, nil
415
- elsif regexp then
416
- return :tREGEXP_END, self.regx_options
417
- else
418
- return :tSTRING_END, term
419
- end
420
- end
421
-
422
- return :tSPACE, nil if space
423
-
424
- self.string_buffer = []
425
-
426
- if expand
427
- case
428
- when scan(/#(?=\$(-.|[a-zA-Z_0-9~\*\$\?!@\/\\;,\.=:<>\"\&\`\'+]))/) then
429
- # TODO: !ISASCII
430
- # ?! see parser_peek_variable_name
431
- return :tSTRING_DVAR, nil
432
- when scan(/#(?=\@\@?[a-zA-Z_])/) then
433
- # TODO: !ISASCII
434
- return :tSTRING_DVAR, nil
435
- when scan(/#[{]/) then
436
- self.command_start = true
437
- return :tSTRING_DBEG, nil
438
- when scan(/#/) then
439
- string_buffer << "#"
440
- end
441
- end
442
-
443
- if tokadd_string(func, term, paren) == RubyLexer::EOF then
444
- if func =~ STR_FUNC_REGEXP then
445
- rb_compile_error "unterminated regexp meets end of file"
446
- else
447
- rb_compile_error "unterminated string meets end of file"
448
- end
449
- end
450
-
451
- return :tSTRING_CONTENT, string_buffer.join
452
- end
453
-
454
231
  def possibly_escape_string text, check
455
232
  content = match[1]
456
233
 
457
234
  if text =~ check then
458
235
  content.gsub(ESC) { unescape $1 }
459
236
  else
460
- content.gsub(/\\\\/, "\\").gsub(/\\'/, "'")
237
+ content.gsub(/\\\\/, "\\").gsub(/\\\'/, "'")
461
238
  end
462
239
  end
463
240
 
@@ -471,11 +248,11 @@ class RubyLexer
471
248
  :tAMPER2
472
249
  end
473
250
 
474
- return result(:arg_state, token, "&")
251
+ result :arg_state, token, "&"
475
252
  end
476
253
 
477
254
  def process_backref text
478
- token = ss[1].to_sym
255
+ token = match[1].to_sym
479
256
  # TODO: can't do lineno hack w/ symbol
480
257
  result EXPR_END, :tBACK_REF, token
481
258
  end
@@ -489,22 +266,25 @@ class RubyLexer
489
266
  end
490
267
 
491
268
  @comments << matched
492
- self.lineno += matched.count("\n")
269
+ self.lineno += matched.count("\n") # HACK?
493
270
 
494
271
  nil # TODO
495
272
  end
496
273
 
497
274
  def process_brace_close text
498
- # matching compare/parse23.y:8561
499
- cond.lexpop
500
- cmdarg.lexpop
501
-
502
275
  case matched
503
276
  when "}" then
504
277
  self.brace_nest -= 1
505
- self.lex_state = ruby24minus? ? EXPR_ENDARG : EXPR_END
506
-
507
278
  return :tSTRING_DEND, matched if brace_nest < 0
279
+ end
280
+
281
+ # matching compare/parse26.y:8099
282
+ cond.pop
283
+ cmdarg.pop
284
+
285
+ case matched
286
+ when "}" then
287
+ self.lex_state = ruby24minus? ? EXPR_ENDARG : EXPR_END
508
288
  return :tRCURLY, matched
509
289
  when "]" then
510
290
  self.paren_nest -= 1
@@ -557,9 +337,9 @@ class RubyLexer
557
337
 
558
338
  case
559
339
  when scan(/\'/) then
560
- string STR_SSYM
340
+ string STR_SSYM, matched
561
341
  when scan(/\"/) then
562
- string STR_DSYM
342
+ string STR_DSYM, matched
563
343
  end
564
344
 
565
345
  result EXPR_FNAME, :tSYMBEG, text
@@ -573,41 +353,48 @@ class RubyLexer
573
353
  end
574
354
  end
575
355
 
356
+ def process_dots text
357
+ tokens = ruby27plus? && is_beg? ? BTOKENS : TOKENS
358
+
359
+ result EXPR_BEG, tokens[text], text
360
+ end
361
+
576
362
  def process_float text
577
363
  rb_compile_error "Invalid numeric format" if text =~ /__/
578
364
 
579
365
  case
580
366
  when text.end_with?("ri")
581
- return result EXPR_NUM, :tIMAGINARY, Complex(0, Rational(text.chop.chop))
367
+ result EXPR_NUM, :tIMAGINARY, Complex(0, Rational(text.chop.chop))
582
368
  when text.end_with?("i")
583
- return result EXPR_NUM, :tIMAGINARY, Complex(0, text.chop.to_f)
369
+ result EXPR_NUM, :tIMAGINARY, Complex(0, text.chop.to_f)
584
370
  when text.end_with?("r")
585
- return result EXPR_NUM, :tRATIONAL, Rational(text.chop)
371
+ result EXPR_NUM, :tRATIONAL, Rational(text.chop)
586
372
  else
587
- return result EXPR_NUM, :tFLOAT, text.to_f
373
+ result EXPR_NUM, :tFLOAT, text.to_f
588
374
  end
589
375
  end
590
376
 
591
377
  def process_gvar text
592
- text.lineno = self.lineno
378
+ if parser.class.version > 20 && text == "$-" then
379
+ rb_compile_error "unexpected $undefined"
380
+ end
381
+
593
382
  result EXPR_END, :tGVAR, text
594
383
  end
595
384
 
596
385
  def process_gvar_oddity text
597
- return result EXPR_END, "$", "$" if text == "$" # TODO: wtf is this?
598
386
  rb_compile_error "#{text.inspect} is not allowed as a global variable name"
599
387
  end
600
388
 
601
389
  def process_ivar text
602
390
  tok_id = text =~ /^@@/ ? :tCVAR : :tIVAR
603
- text.lineno = self.lineno
604
391
  result EXPR_END, tok_id, text
605
392
  end
606
393
 
607
394
  def process_label text
608
- symbol = possibly_escape_string text, /^"/
395
+ symbol = possibly_escape_string text, /^\"/
609
396
 
610
- result EXPR_LAB, :tLABEL, [symbol, self.lineno]
397
+ result EXPR_LAB, :tLABEL, symbol
611
398
  end
612
399
 
613
400
  def process_label_or_string text
@@ -615,11 +402,15 @@ class RubyLexer
615
402
  @was_label = nil
616
403
  return process_label text
617
404
  elsif text =~ /:\Z/ then
618
- ss.pos -= 1 # put back ":"
405
+ self.pos -= 1 # put back ":"
619
406
  text = text[0..-2]
620
407
  end
621
408
 
622
- result EXPR_END, :tSTRING, text[1..-2].gsub(/\\\\/, "\\").gsub(/\\'/, "'")
409
+ orig_line = lineno
410
+ str = text[1..-2].gsub(/\\\\/, "\\").gsub(/\\\'/, "\'")
411
+ self.lineno += str.count("\n")
412
+
413
+ result EXPR_END, :tSTRING, str, orig_line
623
414
  end
624
415
 
625
416
  def process_lchevron text
@@ -637,34 +428,25 @@ class RubyLexer
637
428
  self.lex_state = EXPR_BEG
638
429
  end
639
430
 
640
- return result(lex_state, :tLSHFT, "\<\<")
431
+ result lex_state, :tLSHFT, "\<\<"
641
432
  end
642
433
 
643
- def process_newline_or_comment text
434
+ def process_newline_or_comment text # ../compare/parse30.y:9126 ish
644
435
  c = matched
645
- hit = false
646
436
 
647
437
  if c == "#" then
648
- ss.pos -= 1
438
+ self.pos -= 1
649
439
 
650
- # TODO: handle magic comments
651
440
  while scan(/\s*\#.*(\n+|\z)/) do
652
- hit = true
653
- self.lineno += matched.lines.to_a.size
441
+ self.lineno += matched.count "\n"
654
442
  @comments << matched.gsub(/^ +#/, "#").gsub(/^ +$/, "")
655
443
  end
656
444
 
657
445
  return nil if end_of_stream?
658
446
  end
659
447
 
660
- self.lineno += 1 unless hit
661
-
662
- # Replace a string of newlines with a single one
663
- self.lineno += matched.lines.to_a.size if scan(/\n+/)
664
-
665
448
  c = (lex_state =~ EXPR_BEG|EXPR_CLASS|EXPR_FNAME|EXPR_DOT &&
666
449
  lex_state !~ EXPR_LABELED)
667
- # TODO: figure out what token_seen is for
668
450
  if c || self.lex_state == EXPR_LAB then # yes, == EXPR_LAB
669
451
  # ignore if !fallthrough?
670
452
  if !c && parser.in_kwarg then
@@ -672,25 +454,29 @@ class RubyLexer
672
454
  self.command_start = true
673
455
  return result EXPR_BEG, :tNL, nil
674
456
  else
675
- return # skip
457
+ maybe_pop_stack
458
+ return # goto retry
676
459
  end
677
460
  end
678
461
 
679
- if scan(/([\ \t\r\f\v]*)(\.|&)/) then
680
- self.space_seen = true unless ss[1].empty?
462
+ if scan(/[\ \t\r\f\v]+/) then
463
+ self.space_seen = true
464
+ end
681
465
 
682
- ss.pos -= 1
683
- return unless check(/\.\./)
466
+ if check(/#/) then
467
+ return # goto retry
468
+ elsif check(/&\.|\.(?!\.)/) then # C version is a hellish obfuscated xnor
469
+ return # goto retry
684
470
  end
685
471
 
686
472
  self.command_start = true
687
473
 
688
- return result(EXPR_BEG, :tNL, nil)
474
+ result EXPR_BEG, :tNL, nil
689
475
  end
690
476
 
691
477
  def process_nthref text
692
478
  # TODO: can't do lineno hack w/ number
693
- result EXPR_END, :tNTH_REF, ss[1].to_i
479
+ result EXPR_END, :tNTH_REF, match[1].to_i
694
480
  end
695
481
 
696
482
  def process_paren text
@@ -718,13 +504,16 @@ class RubyLexer
718
504
  end
719
505
 
720
506
  def process_percent text
721
- return parse_quote if is_beg?
722
-
723
- return result EXPR_BEG, :tOP_ASGN, "%" if scan(/\=/)
724
-
725
- return parse_quote if is_space_arg?(check(/\s/)) || (lex_state =~ EXPR_FITEM && check(/s/))
726
-
727
- return result :arg_state, :tPERCENT, "%"
507
+ case
508
+ when is_beg? then
509
+ process_percent_quote
510
+ when scan(/\=/)
511
+ result EXPR_BEG, :tOP_ASGN, "%"
512
+ when is_space_arg?(check(/\s/)) || (lex_state =~ EXPR_FITEM && check(/s/))
513
+ process_percent_quote
514
+ else
515
+ result :arg_state, :tPERCENT, "%"
516
+ end
728
517
  end
729
518
 
730
519
  def process_plus_minus text
@@ -791,17 +580,28 @@ class RubyLexer
791
580
  c = if scan(/\\/) then
792
581
  self.read_escape
793
582
  else
794
- ss.getch
583
+ getch
795
584
  end
796
585
 
797
586
  result EXPR_END, :tSTRING, c
798
587
  end
799
588
 
589
+ def process_simple_string text
590
+ orig_line = lineno
591
+ self.lineno += text.count("\n")
592
+
593
+ str = text[1..-2]
594
+ .gsub(ESC) { unescape($1).b.force_encoding Encoding::UTF_8 }
595
+ str = str.b unless str.valid_encoding?
596
+
597
+ result EXPR_END, :tSTRING, str, orig_line
598
+ end
599
+
800
600
  def process_slash text
801
601
  if is_beg? then
802
- string STR_REGEXP
602
+ string STR_REGEXP, matched
803
603
 
804
- return result(nil, :tREGEXP_BEG, "/")
604
+ return result nil, :tREGEXP_BEG, "/"
805
605
  end
806
606
 
807
607
  if scan(/\=/) then
@@ -816,7 +616,7 @@ class RubyLexer
816
616
  end
817
617
  end
818
618
 
819
- return result(:arg_state, :tDIVIDE, "/")
619
+ result :arg_state, :tDIVIDE, "/"
820
620
  end
821
621
 
822
622
  def process_square_bracket text
@@ -848,43 +648,14 @@ class RubyLexer
848
648
  result EXPR_PAR, token, text
849
649
  end
850
650
 
851
- def process_string # TODO: rewrite / remove
852
- # matches top of parser_yylex in compare/parse23.y:8113
853
- token = if lex_strterm[0] == :heredoc then
854
- self.heredoc lex_strterm
855
- else
856
- self.parse_string lex_strterm
857
- end
858
-
859
- token_type, c = token
860
-
861
- # matches parser_string_term from 2.3, but way off from 2.5
862
- if ruby22plus? && token_type == :tSTRING_END && ["'", '"'].include?(c) then
863
- if ((lex_state =~ EXPR_BEG|EXPR_ENDFN &&
864
- !cond.is_in_state) || is_arg?) &&
865
- is_label_suffix? then
866
- scan(/:/)
867
- token_type = token[0] = :tLABEL_END
868
- end
869
- end
870
-
871
- if [:tSTRING_END, :tREGEXP_END, :tLABEL_END].include? token_type then
872
- self.lex_strterm = nil
873
- self.lex_state = (token_type == :tLABEL_END) ? EXPR_PAR : EXPR_END|EXPR_ENDARG
874
- end
875
-
876
- return token
877
- end
878
-
879
651
  def process_symbol text
880
- symbol = possibly_escape_string text, /^:"/
652
+ symbol = possibly_escape_string text, /^:\"/ # stupid emacs
881
653
 
882
- result EXPR_END|EXPR_ENDARG, :tSYMBOL, symbol
654
+ result EXPR_LIT, :tSYMBOL, symbol
883
655
  end
884
656
 
885
657
  def process_token text
886
658
  # matching: parse_ident in compare/parse23.y:7989
887
- # TODO: make this always return [token, lineno]
888
659
  # FIX: remove: self.last_state = lex_state
889
660
 
890
661
  token = self.token = text
@@ -907,8 +678,7 @@ class RubyLexer
907
678
 
908
679
  if is_label_possible? and is_label_suffix? then
909
680
  scan(/:/)
910
- # TODO: propagate the lineno to ALL results
911
- return result EXPR_LAB, :tLABEL, [token, self.lineno]
681
+ return result EXPR_LAB, :tLABEL, token
912
682
  end
913
683
 
914
684
  # TODO: mb == ENC_CODERANGE_7BIT && lex_state !~ EXPR_DOT
@@ -919,14 +689,17 @@ class RubyLexer
919
689
  return process_token_keyword keyword if keyword
920
690
  end
921
691
 
922
- # matching: compare/parse23.y:8079
923
- state = if is_beg? or is_arg? or lex_state =~ EXPR_DOT then
692
+ # matching: compare/parse30.y:9039
693
+ state = if lex_state =~ EXPR_BEG_ANY|EXPR_ARG_ANY|EXPR_DOT then
924
694
  cmd_state ? EXPR_CMDARG : EXPR_ARG
925
695
  elsif lex_state =~ EXPR_FNAME then
926
696
  EXPR_ENDFN
927
697
  else
928
698
  EXPR_END
929
699
  end
700
+ self.lex_state = state
701
+
702
+ tok_id = :tIDENTIFIER if tok_id == :tCONSTANT && is_local_id(token)
930
703
 
931
704
  if last_state !~ EXPR_DOT|EXPR_FNAME and
932
705
  (tok_id == :tIDENTIFIER) and # not EXPR_FNAME, not attrasgn
@@ -934,160 +707,82 @@ class RubyLexer
934
707
  state = EXPR_END|EXPR_LABEL
935
708
  end
936
709
 
937
- token.lineno = self.lineno # yes, on a string. I know... I know...
938
-
939
- return result(state, tok_id, token)
710
+ result state, tok_id, token
940
711
  end
941
712
 
942
713
  def process_token_keyword keyword
943
714
  # matching MIDDLE of parse_ident in compare/parse23.y:8046
944
715
  state = lex_state
945
- self.lex_state = keyword.state
946
-
947
- value = [token, self.lineno]
948
716
 
949
- return result(lex_state, keyword.id0, value) if state =~ EXPR_FNAME
717
+ return result(EXPR_ENDFN, keyword.id0, token) if lex_state =~ EXPR_FNAME
950
718
 
719
+ self.lex_state = keyword.state
951
720
  self.command_start = true if lex_state =~ EXPR_BEG
952
721
 
953
722
  case
954
- when keyword.id0 == :kDO then
723
+ when keyword.id0 == :kDO then # parse26.y line 7591
955
724
  case
956
725
  when lambda_beginning? then
957
726
  self.lpar_beg = nil # lambda_beginning? == FALSE in the body of "-> do ... end"
958
- self.paren_nest -= 1
959
- result lex_state, :kDO_LAMBDA, value
727
+ self.paren_nest -= 1 # TODO: question this?
728
+ result lex_state, :kDO_LAMBDA, token
960
729
  when cond.is_in_state then
961
- result lex_state, :kDO_COND, value
730
+ result lex_state, :kDO_COND, token
962
731
  when cmdarg.is_in_state && state != EXPR_CMDARG then
963
- result lex_state, :kDO_BLOCK, value
964
- when state =~ EXPR_BEG|EXPR_ENDARG then
965
- result lex_state, :kDO_BLOCK, value
732
+ result lex_state, :kDO_BLOCK, token
966
733
  else
967
- result lex_state, :kDO, value
734
+ result lex_state, :kDO, token
968
735
  end
969
736
  when state =~ EXPR_PAD then
970
- result lex_state, keyword.id0, value
737
+ result lex_state, keyword.id0, token
971
738
  when keyword.id0 != keyword.id1 then
972
- result EXPR_PAR, keyword.id1, value
739
+ result EXPR_PAR, keyword.id1, token
973
740
  else
974
- result lex_state, keyword.id1, value
741
+ result lex_state, keyword.id1, token
975
742
  end
976
743
  end
977
744
 
978
745
  def process_underscore text
979
- ss.unscan # put back "_"
746
+ self.unscan # put back "_"
980
747
 
981
748
  if beginning_of_line? && scan(/\__END__(\r?\n|\Z)/) then
982
- return [RubyLexer::EOF, RubyLexer::EOF]
983
- elsif scan(/\_\w*/) then
984
- return process_token matched
749
+ ss.terminate
750
+ [RubyLexer::EOF, RubyLexer::EOF]
751
+ elsif scan(/#{IDENT_CHAR}+/) then
752
+ process_token matched
985
753
  end
986
754
  end
987
755
 
988
756
  def rb_compile_error msg
989
- msg += ". near line #{self.lineno}: #{ss.rest[/^.*/].inspect}"
757
+ msg += ". near line #{self.lineno}: #{self.rest[/^.*/].inspect}"
990
758
  raise RubyParser::SyntaxError, msg
991
759
  end
992
760
 
993
- def read_escape # TODO: remove / rewrite
994
- case
995
- when scan(/\\/) then # Backslash
996
- '\\'
997
- when scan(/n/) then # newline
998
- self.extra_lineno -= 1
999
- "\n"
1000
- when scan(/t/) then # horizontal tab
1001
- "\t"
1002
- when scan(/r/) then # carriage-return
1003
- "\r"
1004
- when scan(/f/) then # form-feed
1005
- "\f"
1006
- when scan(/v/) then # vertical tab
1007
- "\13"
1008
- when scan(/a/) then # alarm(bell)
1009
- "\007"
1010
- when scan(/e/) then # escape
1011
- "\033"
1012
- when scan(/b/) then # backspace
1013
- "\010"
1014
- when scan(/s/) then # space
1015
- " "
1016
- when scan(/[0-7]{1,3}/) then # octal constant
1017
- (matched.to_i(8) & 0xFF).chr.force_encoding Encoding::UTF_8
1018
- when scan(/x([0-9a-fA-F]{1,2})/) then # hex constant
1019
- # TODO: force encode everything to UTF-8?
1020
- ss[1].to_i(16).chr.force_encoding Encoding::UTF_8
1021
- when check(/M-\\[\\MCc]/) then
1022
- scan(/M-\\/) # eat it
1023
- c = self.read_escape
1024
- c[0] = (c[0].ord | 0x80).chr
1025
- c
1026
- when scan(/M-(.)/) then
1027
- c = ss[1]
1028
- c[0] = (c[0].ord | 0x80).chr
1029
- c
1030
- when check(/(C-|c)\\[\\MCc]/) then
1031
- scan(/(C-|c)\\/) # eat it
1032
- c = self.read_escape
1033
- c[0] = (c[0].ord & 0x9f).chr
1034
- c
1035
- when scan(/C-\?|c\?/) then
1036
- 127.chr
1037
- when scan(/(C-|c)(.)/) then
1038
- c = ss[2]
1039
- c[0] = (c[0].ord & 0x9f).chr
1040
- c
1041
- when scan(/^[89]/i) then # bad octal or hex... MRI ignores them :(
1042
- matched
1043
- when scan(/u([0-9a-fA-F]{4}|\{[0-9a-fA-F]{2,6}\})/) then
1044
- [ss[1].delete("{}").to_i(16)].pack("U")
1045
- when scan(/u([0-9a-fA-F]{1,3})/) then
1046
- rb_compile_error "Invalid escape character syntax"
1047
- when scan(/[McCx0-9]/) || end_of_stream? then
1048
- rb_compile_error("Invalid escape character syntax")
1049
- else
1050
- ss.getch
1051
- end.dup
1052
- end
1053
-
1054
- def regx_options # TODO: rewrite / remove
1055
- good, bad = [], []
1056
-
1057
- if scan(/[a-z]+/) then
1058
- good, bad = matched.split(//).partition { |s| s =~ /^[ixmonesu]$/ }
1059
- end
1060
-
1061
- unless bad.empty? then
1062
- rb_compile_error("unknown regexp option%s - %s" %
1063
- [(bad.size > 1 ? "s" : ""), bad.join.inspect])
1064
- end
1065
-
1066
- return good.join
1067
- end
1068
-
1069
761
  def reset
762
+ self.lineno = 1
1070
763
  self.brace_nest = 0
1071
764
  self.command_start = true
1072
765
  self.comments = []
1073
766
  self.lex_state = EXPR_NONE
1074
767
  self.lex_strterm = nil
1075
- self.lineno = 1
1076
768
  self.lpar_beg = nil
1077
769
  self.paren_nest = 0
1078
770
  self.space_seen = false
1079
771
  self.string_nest = 0
1080
772
  self.token = nil
1081
- self.extra_lineno = 0
773
+ self.string_buffer = []
774
+ self.old_ss = nil
775
+ self.old_lineno = nil
1082
776
 
1083
777
  self.cond.reset
1084
778
  self.cmdarg.reset
1085
779
  end
1086
780
 
1087
- def result new_state, token, text # :nodoc:
781
+ def result new_state, token, text, line = self.lineno # :nodoc:
1088
782
  new_state = self.arg_state if new_state == :arg_state
1089
783
  self.lex_state = new_state if new_state
1090
- [token, text]
784
+
785
+ [token, [text, line]]
1091
786
  end
1092
787
 
1093
788
  def ruby22_label?
@@ -1106,12 +801,8 @@ class RubyLexer
1106
801
  parser.class.version <= 24
1107
802
  end
1108
803
 
1109
- def scan re
1110
- ss.scan re
1111
- end
1112
-
1113
- def scanner_class # TODO: design this out of oedipus_lex. or something.
1114
- RPStringScanner
804
+ def ruby27plus?
805
+ parser.class.version >= 27
1115
806
  end
1116
807
 
1117
808
  def space_vs_beginning space_type, beg_type, fallback
@@ -1126,139 +817,9 @@ class RubyLexer
1126
817
  end
1127
818
  end
1128
819
 
1129
- def string type, beg = matched, nnd = "\0"
1130
- self.lex_strterm = [:strterm, type, beg, nnd]
1131
- end
1132
-
1133
- def tokadd_escape term # TODO: rewrite / remove
1134
- case
1135
- when scan(/\\\n/) then
1136
- # just ignore
1137
- when scan(/\\([0-7]{1,3}|x[0-9a-fA-F]{1,2})/) then
1138
- self.string_buffer << matched
1139
- when scan(/\\([MC]-|c)(?=\\)/) then
1140
- self.string_buffer << matched
1141
- self.tokadd_escape term
1142
- when scan(/\\([MC]-|c)(.)/) then
1143
- self.string_buffer << matched
1144
- when scan(/\\[McCx]/) then
1145
- rb_compile_error "Invalid escape character syntax"
1146
- when scan(/\\(.)/m) then
1147
- chr = ss[1]
1148
- prev = self.string_buffer.last
1149
- if term == chr && prev && prev.end_with?("(?") then
1150
- self.string_buffer << chr
1151
- elsif term == chr || chr.ascii_only? then
1152
- self.string_buffer << matched # dunno why we keep them for ascii
1153
- else
1154
- self.string_buffer << chr # HACK? this is such a rat's nest
1155
- end
1156
- else
1157
- rb_compile_error "Invalid escape character syntax"
1158
- end
1159
- end
1160
-
1161
- def tokadd_string(func, term, paren) # TODO: rewrite / remove
1162
- qwords = func =~ STR_FUNC_QWORDS
1163
- escape = func =~ STR_FUNC_ESCAPE
1164
- expand = func =~ STR_FUNC_EXPAND
1165
- regexp = func =~ STR_FUNC_REGEXP
1166
- symbol = func =~ STR_FUNC_SYMBOL
1167
-
1168
- paren_re = @@regexp_cache[paren]
1169
- term_re = if term == "\n"
1170
- /#{Regexp.escape "\r"}?#{Regexp.escape "\n"}/
1171
- else
1172
- @@regexp_cache[term]
1173
- end
1174
-
1175
- until end_of_stream? do
1176
- c = nil
1177
- handled = true
1178
-
1179
- case
1180
- when scan(term_re) then
1181
- if self.string_nest == 0 then
1182
- ss.pos -= 1
1183
- break
1184
- else
1185
- self.string_nest -= 1
1186
- end
1187
- when paren_re && scan(paren_re) then
1188
- self.string_nest += 1
1189
- when expand && scan(/#(?=[\$\@\{])/) then # TODO: this seems wrong
1190
- ss.pos -= 1
1191
- break
1192
- when qwords && scan(/\s/) then
1193
- ss.pos -= 1
1194
- break
1195
- when expand && scan(/#(?!\n)/) then
1196
- # do nothing
1197
- when check(/\\/) then
1198
- case
1199
- when qwords && scan(/\\\n/) then
1200
- string_buffer << "\n"
1201
- next
1202
- when qwords && scan(/\\\s/) then
1203
- c = " "
1204
- when expand && scan(/\\\n/) then
1205
- next
1206
- when regexp && check(/\\/) then
1207
- self.tokadd_escape term
1208
- next
1209
- when expand && scan(/\\/) then
1210
- c = self.read_escape
1211
- when scan(/\\\n/) then
1212
- # do nothing
1213
- when scan(/\\\\/) then
1214
- string_buffer << '\\' if escape
1215
- c = '\\'
1216
- when scan(/\\/) then
1217
- unless scan(term_re) || paren.nil? || scan(paren_re) then
1218
- string_buffer << "\\"
1219
- end
1220
- else
1221
- handled = false
1222
- end # inner /\\/ case
1223
- else
1224
- handled = false
1225
- end # top case
1226
-
1227
- unless handled then
1228
- t = if term == "\n"
1229
- Regexp.escape "\r\n"
1230
- else
1231
- Regexp.escape term
1232
- end
1233
- x = Regexp.escape paren if paren && paren != "\000"
1234
- re = if qwords then
1235
- /[^#{t}#{x}\#\\\s]+|./ # |. to pick up whatever
1236
- else
1237
- /[^#{t}#{x}\#\\]+|./
1238
- end
1239
-
1240
- scan re
1241
- c = matched
1242
-
1243
- rb_compile_error "symbol cannot contain '\\0'" if symbol && c =~ /\0/
1244
- end # unless handled
1245
-
1246
- c ||= matched
1247
- string_buffer << c
1248
- end # until
1249
-
1250
- c ||= matched
1251
- c = RubyLexer::EOF if end_of_stream?
1252
-
1253
- return c
1254
- end
1255
-
1256
820
  def unescape s
1257
821
  r = ESCAPES[s]
1258
822
 
1259
- self.extra_lineno += 1 if s == "\n" # eg backslash newline strings
1260
- self.extra_lineno -= 1 if r && s == "n" # literal \n, not newline
1261
-
1262
823
  return r if r
1263
824
 
1264
825
  x = case s
@@ -1274,10 +835,12 @@ class RubyLexer
1274
835
  s
1275
836
  when /^[McCx0-9]/ then
1276
837
  rb_compile_error("Invalid escape character syntax")
1277
- when /u([0-9a-fA-F]{4}|\{[0-9a-fA-F]{2,6}\})/ then
838
+ when /u(\h{4})/ then
1278
839
  [$1.delete("{}").to_i(16)].pack("U")
1279
- when /u([0-9a-fA-F]{1,3})/ then
840
+ when /u(\h{1,3})/ then
1280
841
  rb_compile_error("Invalid escape character syntax")
842
+ when /u\{(\h+(?:\s+\h+)*)\}/ then
843
+ $1.split.map { |cp| cp.to_i(16) }.pack("U*")
1281
844
  else
1282
845
  s
1283
846
  end
@@ -1355,11 +918,11 @@ class RubyLexer
1355
918
  # extra fake lex_state names to make things a bit cleaner
1356
919
 
1357
920
  EXPR_LAB = EXPR_ARG|EXPR_LABELED
1358
- EXPR_NUM = EXPR_END|EXPR_ENDARG
921
+ EXPR_LIT = EXPR_END|EXPR_ENDARG
1359
922
  EXPR_PAR = EXPR_BEG|EXPR_LABEL
1360
923
  EXPR_PAD = EXPR_BEG|EXPR_LABELED
1361
924
 
1362
- EXPR_LIT = EXPR_NUM # TODO: migrate to EXPR_LIT
925
+ EXPR_NUM = EXPR_LIT
1363
926
 
1364
927
  expr_names.merge!(EXPR_NONE => "EXPR_NONE",
1365
928
  EXPR_BEG => "EXPR_BEG",
@@ -1390,7 +953,7 @@ class RubyLexer
1390
953
  STR_FUNC_LABEL = State.new 0x40, str_func_names
1391
954
  STR_FUNC_LIST = State.new 0x4000, str_func_names
1392
955
  STR_FUNC_TERM = State.new 0x8000, str_func_names
1393
- STR_FUNC_ICNTNT = State.new 0x10000, str_func_names # <<~HEREDOC -- TODO: remove?
956
+ STR_FUNC_DEDENT = State.new 0x10000, str_func_names # <<~HEREDOC
1394
957
 
1395
958
  # TODO: check parser25.y on how they do STR_FUNC_INDENT
1396
959
 
@@ -1402,6 +965,7 @@ class RubyLexer
1402
965
  STR_DWORD = STR_FUNC_QWORDS | STR_FUNC_EXPAND | STR_FUNC_LIST
1403
966
  STR_SSYM = STR_FUNC_SYMBOL
1404
967
  STR_DSYM = STR_FUNC_SYMBOL | STR_FUNC_EXPAND
968
+ STR_LABEL = STR_FUNC_LABEL
1405
969
 
1406
970
  str_func_names.merge!(STR_FUNC_ESCAPE => "STR_FUNC_ESCAPE",
1407
971
  STR_FUNC_EXPAND => "STR_FUNC_EXPAND",
@@ -1412,7 +976,7 @@ class RubyLexer
1412
976
  STR_FUNC_LABEL => "STR_FUNC_LABEL",
1413
977
  STR_FUNC_LIST => "STR_FUNC_LIST",
1414
978
  STR_FUNC_TERM => "STR_FUNC_TERM",
1415
- STR_FUNC_ICNTNT => "STR_FUNC_ICNTNT",
979
+ STR_FUNC_DEDENT => "STR_FUNC_DEDENT",
1416
980
  STR_SQUOTE => "STR_SQUOTE")
1417
981
  end
1418
982
 
@@ -1422,7 +986,145 @@ class RubyLexer
1422
986
  include State::Values
1423
987
  end
1424
988
 
1425
- require "ruby_lexer.rex"
989
+ class RubyLexer
990
+ module SSWrapper
991
+ def string= s
992
+ ss.string= s
993
+ end
994
+
995
+ def beginning_of_line?
996
+ ss.bol?
997
+ end
998
+
999
+ alias bol? beginning_of_line? # to make .rex file more readable
1000
+
1001
+ def check re
1002
+ maybe_pop_stack
1003
+
1004
+ ss.check re
1005
+ end
1006
+
1007
+ def end_of_stream?
1008
+ ss.eos?
1009
+ end
1010
+
1011
+ alias eos? end_of_stream?
1012
+
1013
+ def getch
1014
+ c = ss.getch
1015
+ c = ss.getch if c == "\r" && ss.peek(1) == "\n"
1016
+ c
1017
+ end
1018
+
1019
+ def match
1020
+ ss
1021
+ end
1022
+
1023
+ def matched
1024
+ ss.matched
1025
+ end
1026
+
1027
+ def in_heredoc?
1028
+ !!self.old_ss
1029
+ end
1030
+
1031
+ def maybe_pop_stack
1032
+ if ss.eos? && in_heredoc? then
1033
+ self.ss_pop
1034
+ self.lineno_pop
1035
+ end
1036
+ end
1037
+
1038
+ def pos
1039
+ ss.pos
1040
+ end
1041
+
1042
+ def pos= n
1043
+ ss.pos = n
1044
+ end
1045
+
1046
+ def rest
1047
+ ss.rest
1048
+ end
1049
+
1050
+ def scan re
1051
+ maybe_pop_stack
1052
+
1053
+ ss.scan re
1054
+ end
1055
+
1056
+ def scanner_class # TODO: design this out of oedipus_lex. or something.
1057
+ RPStringScanner
1058
+ end
1059
+
1060
+ def ss_string
1061
+ ss.string
1062
+ end
1063
+
1064
+ def ss_string= s
1065
+ raise "Probably not"
1066
+ ss.string = s
1067
+ end
1068
+
1069
+ def unscan
1070
+ ss.unscan
1071
+ end
1072
+ end
1073
+
1074
+ include SSWrapper
1075
+ end
1076
+
1077
+ class RubyLexer
1078
+ module SSStackish
1079
+ def lineno_push new_lineno
1080
+ self.old_lineno = self.lineno
1081
+ self.lineno = new_lineno
1082
+ end
1083
+
1084
+ def lineno_pop
1085
+ self.lineno = self.old_lineno
1086
+ self.old_lineno = nil
1087
+ end
1088
+
1089
+ def ss= o
1090
+ raise "Clearing ss while in heredoc!?!" if in_heredoc?
1091
+ @old_ss = nil
1092
+ super
1093
+ end
1094
+
1095
+ def ss_push new_ss
1096
+ @old_ss = self.ss
1097
+ @ss = new_ss
1098
+ end
1099
+
1100
+ def ss_pop
1101
+ @ss = self.old_ss
1102
+ @old_ss = nil
1103
+ end
1104
+ end
1105
+
1106
+ prepend SSStackish
1107
+ end
1108
+
1109
+ if ENV["RP_STRTERM_DEBUG"] then
1110
+ class RubyLexer
1111
+ def d o
1112
+ $stderr.puts o.inspect
1113
+ end
1114
+
1115
+ alias old_lex_strterm= lex_strterm=
1116
+
1117
+ def lex_strterm= o
1118
+ self.old_lex_strterm= o
1119
+ where = caller.first.split(/:/).first(2).join(":")
1120
+ $stderr.puts
1121
+ d :lex_strterm => [o, where]
1122
+ end
1123
+ end
1124
+ end
1125
+
1126
+ require_relative "./ruby_lexer.rex.rb"
1127
+ require_relative "./ruby_lexer_strings.rb"
1426
1128
 
1427
1129
  if ENV["RP_LINENO_DEBUG"] then
1428
1130
  class RubyLexer
@@ -1435,7 +1137,8 @@ if ENV["RP_LINENO_DEBUG"] then
1435
1137
  def lineno= n
1436
1138
  self.old_lineno= n
1437
1139
  where = caller.first.split(/:/).first(2).join(":")
1438
- d :lineno => [n, where, ss && ss.rest[0, 40]]
1140
+ $stderr.puts
1141
+ d :lineno => [n, where]
1439
1142
  end
1440
1143
  end
1441
1144
  end