ruby_parser 3.12.0 → 3.18.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/.autotest +18 -29
  4. data/History.rdoc +283 -0
  5. data/Manifest.txt +12 -4
  6. data/README.rdoc +4 -3
  7. data/Rakefile +189 -51
  8. data/bin/ruby_parse +3 -1
  9. data/bin/ruby_parse_extract_error +19 -36
  10. data/compare/normalize.rb +76 -4
  11. data/debugging.md +190 -0
  12. data/gauntlet.md +106 -0
  13. data/lib/rp_extensions.rb +14 -42
  14. data/lib/rp_stringscanner.rb +20 -51
  15. data/lib/ruby20_parser.rb +4659 -4218
  16. data/lib/ruby20_parser.y +953 -602
  17. data/lib/ruby21_parser.rb +4723 -4308
  18. data/lib/ruby21_parser.y +956 -605
  19. data/lib/ruby22_parser.rb +4762 -4337
  20. data/lib/ruby22_parser.y +960 -612
  21. data/lib/ruby23_parser.rb +4761 -4342
  22. data/lib/ruby23_parser.y +961 -613
  23. data/lib/ruby24_parser.rb +4791 -4341
  24. data/lib/ruby24_parser.y +968 -612
  25. data/lib/ruby25_parser.rb +4791 -4341
  26. data/lib/ruby25_parser.y +968 -612
  27. data/lib/ruby26_parser.rb +7287 -0
  28. data/lib/ruby26_parser.y +2749 -0
  29. data/lib/ruby27_parser.rb +8517 -0
  30. data/lib/ruby27_parser.y +3346 -0
  31. data/lib/ruby30_parser.rb +8751 -0
  32. data/lib/ruby30_parser.y +3472 -0
  33. data/lib/ruby3_parser.yy +3476 -0
  34. data/lib/ruby_lexer.rb +611 -826
  35. data/lib/ruby_lexer.rex +48 -40
  36. data/lib/ruby_lexer.rex.rb +122 -46
  37. data/lib/ruby_lexer_strings.rb +638 -0
  38. data/lib/ruby_parser.rb +38 -34
  39. data/lib/ruby_parser.yy +1710 -704
  40. data/lib/ruby_parser_extras.rb +987 -553
  41. data/test/test_ruby_lexer.rb +1718 -1539
  42. data/test/test_ruby_parser.rb +3957 -2164
  43. data/test/test_ruby_parser_extras.rb +39 -4
  44. data/tools/munge.rb +250 -0
  45. data/tools/ripper.rb +44 -0
  46. data.tar.gz.sig +0 -0
  47. metadata +68 -47
  48. metadata.gz.sig +0 -0
  49. data/lib/ruby18_parser.rb +0 -5793
  50. data/lib/ruby18_parser.y +0 -1908
  51. data/lib/ruby19_parser.rb +0 -6185
  52. data/lib/ruby19_parser.y +0 -2116
data/lib/ruby_parser.rb CHANGED
@@ -9,32 +9,33 @@ class RubyParser
9
9
 
10
10
  VERSIONS = []
11
11
 
12
- class Parser < Racc::Parser
13
- include RubyParserStuff
12
+ attr_accessor :current
14
13
 
15
- def self.inherited x
16
- RubyParser::VERSIONS << x
17
- end
18
-
19
- def self.version= v
20
- @version = v
21
- end
14
+ def self.for_current_ruby
15
+ name = "V#{RUBY_VERSION[/^\d+\.\d+/].delete "."}"
16
+ klass = if const_defined? name then
17
+ const_get name
18
+ else
19
+ latest = VERSIONS.first
20
+ warn "NOTE: RubyParser::#{name} undefined, using #{latest}."
21
+ latest
22
+ end
22
23
 
23
- def self.version
24
- @version ||= Parser > self && self.name[/(?:V|Ruby)(\d+)/, 1].to_i
25
- end
24
+ klass.new
26
25
  end
27
26
 
28
- class SyntaxError < RuntimeError; end
27
+ def self.latest
28
+ VERSIONS.first.new
29
+ end
29
30
 
30
31
  def process s, f = "(string)", t = 10
31
32
  e = nil
32
33
  VERSIONS.each do |klass|
33
- parser = klass.new
34
+ self.current = parser = klass.new
34
35
  begin
35
36
  return parser.process s, f, t
36
37
  rescue Racc::ParseError, RubyParser::SyntaxError => exc
37
- e = exc
38
+ e ||= exc
38
39
  end
39
40
  end
40
41
  raise e
@@ -46,47 +47,50 @@ class RubyParser
46
47
  # do nothing
47
48
  end
48
49
 
49
- def self.latest
50
- VERSIONS.first.new
51
- end
50
+ class Parser < Racc::Parser
51
+ include RubyParserStuff
52
52
 
53
- def self.for_current_ruby
54
- name = "V#{RUBY_VERSION[/^\d+\.\d+/].delete "."}"
55
- klass = if const_defined? name then
56
- const_get name
57
- else
58
- latest = VERSIONS.first
59
- warn "NOTE: RubyParser::#{name} undefined, using #{latest}."
60
- latest
61
- end
53
+ def self.inherited x
54
+ RubyParser::VERSIONS << x
55
+ end
62
56
 
63
- klass.new
57
+ def self.version= v
58
+ @version = v
59
+ end
60
+
61
+ def self.version
62
+ @version ||= Parser > self && self.name[/(?:V|Ruby)(\d+)/, 1].to_i
63
+ end
64
64
  end
65
+
66
+ class SyntaxError < RuntimeError; end
65
67
  end
66
68
 
67
69
  ##
68
70
  # Unfortunately a problem with racc is that it won't let me namespace
69
- # properly, so instead of RubyParser::V18, I still have to generate
70
- # the old Ruby23Parser and shove it in as V23.
71
+ # properly, so instead of RubyParser::V25, I still have to generate
72
+ # the old Ruby25Parser and shove it in as V25.
71
73
 
72
- require "ruby18_parser"
73
- require "ruby19_parser"
74
74
  require "ruby20_parser"
75
75
  require "ruby21_parser"
76
76
  require "ruby22_parser"
77
77
  require "ruby23_parser"
78
78
  require "ruby24_parser"
79
79
  require "ruby25_parser"
80
+ require "ruby26_parser"
81
+ require "ruby27_parser"
82
+ require "ruby30_parser"
80
83
 
81
84
  class RubyParser # HACK
82
85
  VERSIONS.clear # also a HACK caused by racc namespace issues
83
86
 
87
+ class V30 < ::Ruby30Parser; end
88
+ class V27 < ::Ruby27Parser; end
89
+ class V26 < ::Ruby26Parser; end
84
90
  class V25 < ::Ruby25Parser; end
85
91
  class V24 < ::Ruby24Parser; end
86
92
  class V23 < ::Ruby23Parser; end
87
93
  class V22 < ::Ruby22Parser; end
88
94
  class V21 < ::Ruby21Parser; end
89
95
  class V20 < ::Ruby20Parser; end
90
- class V19 < ::Ruby19Parser; end
91
- class V18 < ::Ruby18Parser; end
92
96
  end