redparse 0.8.4 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -0
  2. data/COPYING.LGPL +503 -158
  3. data/History.txt +192 -0
  4. data/Makefile +9 -0
  5. data/README.txt +72 -39
  6. data/bin/redparse +108 -14
  7. data/lib/miniredparse.rb +1543 -0
  8. data/lib/redparse.rb +971 -105
  9. data/lib/redparse/ReduceWithsFor_RedParse_1_8.rb +17412 -0
  10. data/lib/redparse/ReduceWithsFor_RedParse_1_9.rb +17633 -0
  11. data/lib/redparse/babynodes.rb +17 -0
  12. data/lib/redparse/babyparser.rb +17 -0
  13. data/lib/redparse/cache.rb +290 -6
  14. data/lib/redparse/compile.rb +6 -97
  15. data/lib/redparse/decisiontree.rb +1 -1
  16. data/lib/redparse/float_accurate_to_s.rb +30 -6
  17. data/lib/redparse/generate.rb +18 -0
  18. data/lib/redparse/node.rb +415 -124
  19. data/lib/redparse/parse_tree_server.rb +20 -2
  20. data/lib/redparse/problemfiles.rb +1 -1
  21. data/lib/redparse/pthelper.rb +17 -31
  22. data/lib/redparse/reg_more_sugar.rb +1 -1
  23. data/lib/redparse/replacing/parse_tree.rb +30 -0
  24. data/lib/redparse/replacing/ripper.rb +20 -0
  25. data/lib/redparse/replacing/ruby_parser.rb +28 -0
  26. data/lib/redparse/ripper.rb +393 -0
  27. data/lib/redparse/ripper_sexp.rb +153 -0
  28. data/lib/redparse/stackableclasses.rb +113 -0
  29. data/lib/redparse/version.rb +18 -1
  30. data/redparse.gemspec +29 -9
  31. data/rplt.txt +31 -0
  32. data/test/data/hd_with_blank_string.rb +3 -0
  33. data/test/data/pt_known_output.rb +13273 -0
  34. data/test/data/wp.pp +0 -0
  35. data/test/generate_parse_tree_server_rc.rb +17 -0
  36. data/test/rp-locatetest.rb +2 -2
  37. data/test/test_1.9.rb +338 -35
  38. data/test/test_all.rb +22 -3
  39. data/test/test_part.rb +32 -0
  40. data/test/test_redparse.rb +396 -74
  41. data/test/test_xform_tree.rb +18 -0
  42. data/test/unparse_1.9_exceptions.txt +85 -0
  43. data/test/unparse_1.9_exceptions.txt.old +81 -0
  44. metadata +71 -46
  45. data/Rakefile +0 -35
@@ -1,3 +1,21 @@
1
+ =begin copyright
2
+ redparse - a ruby parser written in ruby
3
+ Copyright (C) 2008,2009, 2012, 2016 Caleb Clausen
4
+
5
+ This program is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU Lesser General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU Lesser General Public License for more details.
14
+
15
+ You should have received a copy of the GNU Lesser General Public License
16
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ =end
18
+
1
19
  require 'test/unit'
2
20
  require 'regxform'
3
21
  require "redparse"
@@ -0,0 +1,85 @@
1
+ :!~ ====> :"!~"\\\///
2
+ :!= ====> :"!="\\\///
3
+ :!@ ====> :!\\\///
4
+ :!@ ====> :"!"\\\///
5
+ {a: 1,b: 2,c=>3} ====> {:a => 1, :b => 2, c => 3}\\\///
6
+ {a: b} ====> {:a => b}\\\///
7
+ [*a,b,c] ====> [*a, b, c]\\\///
8
+ [a,*b,*c] ====> [a, *b, *c]\\\///
9
+ [a,*b,c] ====> [a, *b, c]\\\///
10
+ [*a,*b,*c,*d] ====> [*a, *b, *c, *d]\\\///
11
+ [a,*b,c,*d] ====> [a, *b, c, *d]\\\///
12
+ {a: b, c: d} ====> {:a => b, :c => d}\\\///
13
+ [*a,*b,*c,*d,e] ====> [*a, *b, *c, *d, e]\\\///
14
+ alias !~ != ====> alias :!~ :!=\\\///
15
+ alias !~ != ====> alias :"!~" :"!="\\\///
16
+ alias != ` ====> alias :!= :`\\\///
17
+ alias != ` ====> alias :"!=" :`\\\///
18
+ alias != !~ ====> alias :!= :!~\\\///
19
+ alias != !~ ====> alias :"!=" :"!~"\\\///
20
+ alias !@ ` ====> alias :"!" :`\\\///
21
+ alias !@ ` ====> alias :"!@" :`\\\///
22
+ alias !~ x ====> alias :!~ :x\\\///
23
+ alias !~ x ====> alias :"!~" :x\\\///
24
+ alias != x ====> alias :!= :x\\\///
25
+ alias != x ====> alias :"!=" :x\\\///
26
+ alias !@ x ====> alias :"!" :x\\\///
27
+ alias !@ x ====> alias :"!@" :x\\\///
28
+ alias x !~ ====> alias :x :!~\\\///
29
+ alias x !~ ====> alias :x :"!~"\\\///
30
+ alias x != ====> alias :x :!=\\\///
31
+ alias x != ====> alias :x :"!="\\\///
32
+ alias x !@ ====> alias :x :"!"\\\///
33
+ alias x !@ ====> alias :x :"!@"\\\///
34
+ def !@; end ====> def !@; ;;end\\\///
35
+ def !~(x); end ====> def !~(x); ;;end\\\///
36
+ def !=(x); end ====> def !=(x); ;;end\\\///
37
+ f.(a=1,2,3) ====> f.(a=1, 2, 3)\\\///
38
+ not +1 ====> not 1\\\///
39
+ not(+1) ====> not(1)\\\///
40
+ proc{|a=10,b| x} ====> proc{|a=10, b| x;}\\\///
41
+ proc{|a=10,b| x} ====> proc{|a=10,b| x;}\\\///
42
+ proc{|a,b=10| x} ====> proc{|a, b=10| x;}\\\///
43
+ proc{|a,*b,(c1,*c2,c3)|d} ====> proc{|a, *b, (c1, *c2, c3)| d;}\\\///
44
+ proc{|*a,b,c|d} ====> proc{|*a, b, c| d;}\\\///
45
+ proc{|a,*b,c|d} ====> proc{|a, *b, c| d;}\\\///
46
+ proc{|a,&b| x} ====> proc{|a, &b| x;}\\\///
47
+ proc{|&a| x} ====> proc{|&a| x;}\\\///
48
+ ?\u{10fffd} ====> ?􏿽\\\///
49
+ ?\u2665 ====> ?♥\\\///
50
+ ?\u2666 ====> ?♦\\\///
51
+ undef !~ ====> undef :!~\\\///
52
+ undef !~ ====> undef :"!~"\\\///
53
+ undef != ====> undef :!=\\\///
54
+ undef != ====> undef :"!="\\\///
55
+ undef !@ ====> undef :"!"\\\///
56
+ undef !@ ====> undef :"!@"\\\///
57
+ z(*a,*b,*c,*d,e) ====> z(*a, *b, *c, *d, e)\\\///
58
+ z(*a,*b,*c,*d) ====> z(*a, *b, *c, *d)\\\///
59
+ z(a,*b,c,*d) ====> z(a, *b, c, *d)\\\///
60
+ z(*a,b,c) ====> z(*a, b, c)\\\///
61
+ z(a,*b,*c) ====> z(a, *b, *c)\\\///
62
+ z(a,*b,c) ====> z(a, *b, c)\\\///
63
+ a ? b
64
+ : c ====> a ? b : c\\\///
65
+ a
66
+ .b ====> a.b\\\///
67
+
68
+ a
69
+ .b ====> a.b\\\///
70
+ proc{|a,b=10| x} ====> proc{|a, b = 10| x;}\\\///
71
+ proc{|a=10,b| x} ====> proc{|a = 10, b| x;}\\\///
72
+ z=*a,*b,*c,*d ====> z = *a,*b,*c,*d\\\///
73
+ z=*a,*b,*c,*d,e ====> z = *a,*b,*c,*d,e\\\///
74
+ z=*a,b,c ====> z = *a,b,c\\\///
75
+ z=a,*b,*c ====> z = a,*b,*c\\\///
76
+ z=a,*b,c ====> z = a,*b,c\\\///
77
+ z=a,*b,c,*d ====> z = a,*b,c,*d\\\///
78
+ z[*a,*b,*c,*d,e]=1 ====> z[*a,*b,*c,*d,e] = 1\\\///
79
+ z[*a,*b,*c,*d]=1 ====> z[*a,*b,*c,*d] = 1\\\///
80
+ z[*a,b,c]=1 ====> z[*a,b,c] = 1\\\///
81
+ z[a,*b,*c]=1 ====> z[a,*b,*c] = 1\\\///
82
+ z[a,*b,c,*d]=1 ====> z[a,*b,c,*d] = 1\\\///
83
+ z[a,*b,c]=1 ====> z[a,*b,c] = 1\\\///
84
+ f.(a=1,2,3) ====> f.(a = 1, 2, 3)\\\///
85
+ def !@; end ====> def !@ ; ;;end\\\///
@@ -0,0 +1,81 @@
1
+ {a: b} ====> {:a => b}\\\///
2
+ {a: b, c: d} ====> {:a => b, :c => d}\\\///
3
+ :!= ====> :"!="\\\///
4
+ :!@ ====> :"!"\\\///
5
+ :!~ ====> :"!~"\\\///
6
+ [*a,*b,*c,*d,e] ====> [*a, *b, *c, *d, e]\\\///
7
+ [*a,*b,*c,*d] ====> [*a, *b, *c, *d]\\\///
8
+ [*a,b,c] ====> [*a, b, c]\\\///
9
+ [a,*b,*c] ====> [a, *b, *c]\\\///
10
+ [a,*b,c,*d] ====> [a, *b, c, *d]\\\///
11
+ [a,*b,c] ====> [a, *b, c]\\\///
12
+ alias != !~ ====> alias :"!=" :"!~"\\\///
13
+ alias != ` ====> alias :"!=" :`\\\///
14
+ alias != x ====> alias :"!=" :x\\\///
15
+ alias !@ ` ====> alias :"!" :`\\\///
16
+ alias !@ x ====> alias :"!" :x\\\///
17
+ alias !~ != ====> alias :"!~" :"!="\\\///
18
+ alias !~ x ====> alias :"!~" :x\\\///
19
+ alias x != ====> alias :x :"!="\\\///
20
+ alias x !@ ====> alias :x :"!"\\\///
21
+ alias x !~ ====> alias :x :"!~"\\\///
22
+ def !=(x); end ====> def !=(x); ;;end\\\///
23
+ def !@; end ====> def !@; ;;end\\\///
24
+ def !~(x); end ====> def !~(x); ;;end\\\///
25
+ not +1 ====> not 1\\\///
26
+ not(+1) ====> not(1)\\\///
27
+ proc{|&a| x} ====> proc{|&a| x;}\\\///
28
+ proc{|*a,b,c|d} ====> proc{|*a, b, c| d;}\\\///
29
+ proc{|a,&b| x} ====> proc{|a, &b| x;}\\\///
30
+ proc{|a,*b,(c1,*c2,c3)|d} ====> proc{|a, *b, (c1, *c2, c3)| d;}\\\///
31
+ proc{|a,*b,c|d} ====> proc{|a, *b, c| d;}\\\///
32
+ proc{|a,b=10| x} ====> proc{|a, b=10| x;}\\\///
33
+ proc{|a=10,b| x} ====> proc{|a=10,b| x;}\\\///
34
+ undef != ====> undef :"!="\\\///
35
+ undef !@ ====> undef :"!"\\\///
36
+ undef !~ ====> undef :"!~"\\\///
37
+ z(*a,*b,*c,*d) ====> z(*a, *b, *c, *d)\\\///
38
+ z(*a,*b,*c,*d,e) ====> z(*a, *b, *c, *d, e)\\\///
39
+ z(*a,b,c) ====> z(*a, b, c)\\\///
40
+ z(a,*b,*c) ====> z(a, *b, *c)\\\///
41
+ z(a,*b,c) ====> z(a, *b, c)\\\///
42
+ z(a,*b,c,*d) ====> z(a, *b, c, *d)\\\///
43
+ a ? b
44
+ : c ====> a ? b : c\\\///
45
+ {a: 1,b: 2,c=>3} ====> {:a => 1, :b => 2, c => 3}\\\///
46
+
47
+ a
48
+ .b ====> a.b\\\///
49
+ ?\u2665 ====> ?♥\\\///
50
+ ?\u{10fffd} ====> ?􏿽\\\///
51
+ ?\u2666 ====> ?♦\\\///
52
+ f.(a=1,2,3) ====> f.(a=1, 2, 3)\\\///
53
+ :!@ ====> :!\\\///
54
+ alias != !~ ====> alias :!= :!~\\\///
55
+ alias != ` ====> alias :!= :`\\\///
56
+ alias != x ====> alias :!= :x\\\///
57
+ alias !@ ` ====> alias :"!@" :`\\\///
58
+ alias !@ x ====> alias :"!@" :x\\\///
59
+ alias !~ != ====> alias :!~ :!=\\\///
60
+ alias !~ x ====> alias :!~ :x\\\///
61
+ alias x != ====> alias :x :!=\\\///
62
+ alias x !@ ====> alias :x :"!@"\\\///
63
+ alias x !~ ====> alias :x :!~\\\///
64
+ undef != ====> undef :!=\\\///
65
+ undef !@ ====> undef :"!@"\\\///
66
+ undef !~ ====> undef :!~\\\///
67
+ :!@ ====> :"!"\\\///
68
+ alias != !~ ====> alias :"!=" :"!~"\\\///
69
+ alias != ` ====> alias :"!=" :`\\\///
70
+ alias != x ====> alias :"!=" :x\\\///
71
+ alias !@ ` ====> alias :"!" :`\\\///
72
+ alias !@ x ====> alias :"!" :x\\\///
73
+ alias !~ != ====> alias :"!~" :"!="\\\///
74
+ alias !~ x ====> alias :"!~" :x\\\///
75
+ alias x != ====> alias :x :"!="\\\///
76
+ alias x !@ ====> alias :x :"!"\\\///
77
+ alias x !~ ====> alias :x :"!~"\\\///
78
+ undef != ====> undef :"!="\\\///
79
+ undef !@ ====> undef :"!"\\\///
80
+ undef !~ ====> undef :"!~"\\\///
81
+ proc{|a=10,b| x} ====> proc{|a=10, b| x;}\\\///
metadata CHANGED
@@ -1,55 +1,68 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: redparse
3
- version: !ruby/object:Gem::Version
4
- version: 0.8.4
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
5
  platform: ruby
6
- authors:
6
+ authors:
7
7
  - Caleb Clausen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
-
12
- date: 2010-01-03 00:00:00 -08:00
13
- default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
11
+ date: 2016-07-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
16
14
  name: rubylexer
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.8.0
17
20
  type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - "="
22
- - !ruby/object:Gem::Version
23
- version: 0.7.7
24
- version:
25
- - !ruby/object:Gem::Dependency
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.8.0
27
+ - !ruby/object:Gem::Dependency
26
28
  name: reg
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.5.0a0
27
34
  type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
30
- requirements:
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
31
38
  - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 0.4.8
34
- version:
35
- description: RedParse is a ruby parser written in pure ruby. Instead of YACC or ANTLR, it's parse tool is a home-brewed "compiler-interpreter". (The tool is LALR(1)-equivalent and the 'parse language' is pretty nice, even in it's current crude form.) My intent is to have a completely correct parser for ruby, in 100% ruby. Currently, RedParse can parse all known ruby 1.8 constructions correctly. There might be some problems with unparsing or otherwise working with texts in a character set other than ascii. Some of the new ruby 1.9 constructions are supported in 1.9 mode. For more details on known problems, see below.
39
+ - !ruby/object:Gem::Version
40
+ version: 0.5.0a0
41
+ description: "RedParse is a ruby parser (and parser-compiler) written in pure ruby.
42
+ \nInstead of YACC or ANTLR, it's parse tool is a home-brewed language. (The\ntool
43
+ is (at least) LALR(1)-equivalent and the 'parse language' is \npretty nice, even
44
+ in it's current form.)\n\nMy intent is to have a completely correct parser for ruby,
45
+ in 100% \nruby. And I think I've more or less succeeded. Aside from some fairly\nminor
46
+ quibbles (see below), RedParse can parse all known ruby 1.8 and 1.9 \nconstructions
47
+ correctly. Input text may be encoded in ascii, binary, \nutf-8, iso-8859-1, and
48
+ the euc-* family of encodings. Sjis is not yet \nsupported."
36
49
  email: caleb (at) inforadical (dot) net
37
50
  executables: []
38
-
39
51
  extensions: []
40
-
41
- extra_rdoc_files:
52
+ extra_rdoc_files:
42
53
  - README.txt
43
54
  - COPYING.LGPL
44
- files:
55
+ files:
45
56
  - COPYING.LGPL
46
57
  - History.txt
47
58
  - Makefile
48
59
  - Manifest.txt
49
60
  - README.txt
50
- - Rakefile
51
61
  - bin/redparse
62
+ - lib/miniredparse.rb
52
63
  - lib/redparse.rb
64
+ - lib/redparse/ReduceWithsFor_RedParse_1_8.rb
65
+ - lib/redparse/ReduceWithsFor_RedParse_1_9.rb
53
66
  - lib/redparse/babynodes.rb
54
67
  - lib/redparse/babyparser.rb
55
68
  - lib/redparse/cache.rb
@@ -62,8 +75,15 @@ files:
62
75
  - lib/redparse/problemfiles.rb
63
76
  - lib/redparse/pthelper.rb
64
77
  - lib/redparse/reg_more_sugar.rb
78
+ - lib/redparse/replacing/parse_tree.rb
79
+ - lib/redparse/replacing/ripper.rb
80
+ - lib/redparse/replacing/ruby_parser.rb
81
+ - lib/redparse/ripper.rb
82
+ - lib/redparse/ripper_sexp.rb
83
+ - lib/redparse/stackableclasses.rb
65
84
  - lib/redparse/version.rb
66
85
  - redparse.gemspec
86
+ - rplt.txt
67
87
  - test/data/__end.rb
68
88
  - test/data/__f.rb
69
89
  - test/data/be.rb
@@ -80,6 +100,7 @@ files:
80
100
  - test/data/hd3.rb
81
101
  - test/data/hd4.rb
82
102
  - test/data/hd5.rb
103
+ - test/data/hd_with_blank_string.rb
83
104
  - test/data/hdcat.rb
84
105
  - test/data/hdx.rb
85
106
  - test/data/heredoc.rb
@@ -87,41 +108,45 @@ files:
87
108
  - test/data/jbridge.rb
88
109
  - test/data/mod.rb
89
110
  - test/data/nl_as_strdelim.rb
111
+ - test/data/pt_known_output.rb
90
112
  - test/data/pw.rb
91
113
  - test/data/skkdictools.rb
114
+ - test/data/wp.pp
92
115
  - test/data/wvt.rb
93
116
  - test/generate_parse_tree_server_rc.rb
94
117
  - test/rp-locatetest.rb
95
118
  - test/test_1.9.rb
96
119
  - test/test_all.rb
120
+ - test/test_part.rb
97
121
  - test/test_redparse.rb
98
122
  - test/test_xform_tree.rb
99
- has_rdoc: true
123
+ - test/unparse_1.9_exceptions.txt
124
+ - test/unparse_1.9_exceptions.txt.old
100
125
  homepage: http://github.com/coatl/redparse
126
+ licenses:
127
+ - LGPL-2.1
128
+ metadata: {}
101
129
  post_install_message:
102
- rdoc_options:
103
- - --main
130
+ rdoc_options:
131
+ - "--main"
104
132
  - README.txt
105
- require_paths:
133
+ require_paths:
106
134
  - lib
107
- required_ruby_version: !ruby/object:Gem::Requirement
108
- requirements:
135
+ required_ruby_version: !ruby/object:Gem::Requirement
136
+ requirements:
109
137
  - - ">="
110
- - !ruby/object:Gem::Version
111
- version: "0"
112
- version:
113
- required_rubygems_version: !ruby/object:Gem::Requirement
114
- requirements:
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ required_rubygems_version: !ruby/object:Gem::Requirement
141
+ requirements:
115
142
  - - ">="
116
- - !ruby/object:Gem::Version
117
- version: "0"
118
- version:
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
119
145
  requirements: []
120
-
121
146
  rubyforge_project: redparse
122
- rubygems_version: 1.3.1
147
+ rubygems_version: 2.5.1
123
148
  signing_key:
124
149
  specification_version: 2
125
150
  summary: RedParse is a ruby parser written in pure ruby.
126
- test_files:
151
+ test_files:
127
152
  - test/test_all.rb
data/Rakefile DELETED
@@ -1,35 +0,0 @@
1
- # Copyright (C) 2008 Caleb Clausen
2
- # Distributed under the terms of Ruby's license.
3
- require 'rubygems'
4
- require 'hoe'
5
- require './lib/redparse/version.rb'
6
-
7
- if $*==["test"]
8
- #hack to get 'rake test' to stay in one process
9
- #which keeps netbeans happy
10
- $:<<"lib"
11
- require "test/test_redparse.rb"
12
- Test::Unit::AutoRunner.run
13
- exit
14
- end
15
-
16
- readme=open("README.txt")
17
- readme.readline("\n== DESCRIPTION:")
18
- readme.readline("\n\n")
19
- desc=readme.readline("\n\n")
20
-
21
- hoe=Hoe.new("redparse", RedParse::VERSION) do |_|
22
- _.author = "Caleb Clausen"
23
- _.email = "redparse-owner @at@ inforadical .dot. net"
24
- _.url = ["http://github.com/coatl/redparse/", "http://rubyforge.org/projects/redparse/"]
25
- _.extra_deps << ['rubylexer', '>= 0.7.4']
26
- _.extra_deps << ['reg', '>= 0.4.7']
27
- # _.test_globs=["test/*"]
28
- _.description=desc
29
- _.summary=desc[/\A[^.]+\./]
30
- _.spec_extras={:bindir=>'bin/'}
31
- # _.rdoc_pattern=/\A(README\.txt|lib\/.*\.rb)\Z/
32
- # _.remote_rdoc_dir="/"
33
- end
34
-
35
-