racc 1.4.16-java → 1.6.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. checksums.yaml +4 -4
  2. data/README.ja.rdoc +0 -1
  3. data/README.rdoc +8 -11
  4. data/bin/racc +37 -23
  5. data/{rdoc → doc}/en/NEWS.en.rdoc +0 -0
  6. data/{rdoc → doc}/en/grammar.en.rdoc +27 -31
  7. data/doc/en/grammar2.en.rdoc +219 -0
  8. data/{rdoc → doc}/ja/NEWS.ja.rdoc +0 -0
  9. data/{rdoc → doc}/ja/command.ja.html +1 -1
  10. data/{rdoc → doc}/ja/debug.ja.rdoc +0 -0
  11. data/{rdoc → doc}/ja/grammar.ja.rdoc +0 -0
  12. data/{rdoc → doc}/ja/index.ja.html +0 -0
  13. data/{rdoc → doc}/ja/parser.ja.rdoc +0 -0
  14. data/{rdoc → doc}/ja/usage.ja.html +0 -0
  15. data/ext/racc/cparse/cparse.c +19 -17
  16. data/ext/racc/cparse/extconf.rb +2 -1
  17. data/lib/racc/compat.rb +5 -4
  18. data/lib/racc/cparse-jruby.jar +0 -0
  19. data/lib/racc/debugflags.rb +5 -4
  20. data/lib/racc/exception.rb +4 -1
  21. data/lib/racc/grammar.rb +22 -17
  22. data/lib/racc/grammarfileparser.rb +7 -6
  23. data/lib/racc/info.rb +5 -2
  24. data/lib/racc/iset.rb +5 -4
  25. data/lib/racc/logfilegenerator.rb +5 -4
  26. data/lib/racc/parser-text.rb +10 -16
  27. data/lib/racc/parser.rb +10 -16
  28. data/lib/racc/parserfilegenerator.rb +5 -47
  29. data/lib/racc/sourcetext.rb +5 -4
  30. data/lib/racc/state.rb +4 -1
  31. data/lib/racc/statetransitiontable.rb +9 -14
  32. metadata +18 -137
  33. data/DEPENDS +0 -4
  34. data/Manifest.txt +0 -146
  35. data/Rakefile +0 -58
  36. data/bin/racc2y +0 -195
  37. data/bin/y2racc +0 -339
  38. data/ext/racc/com/headius/racc/Cparse.java +0 -849
  39. data/fastcache/extconf.rb +0 -2
  40. data/fastcache/fastcache.c +0 -185
  41. data/lib/racc/pre-setup +0 -13
  42. data/misc/dist.sh +0 -31
  43. data/sample/array.y +0 -67
  44. data/sample/array2.y +0 -59
  45. data/sample/calc-ja.y +0 -66
  46. data/sample/calc.y +0 -65
  47. data/sample/conflict.y +0 -15
  48. data/sample/hash.y +0 -60
  49. data/sample/lalr.y +0 -17
  50. data/sample/lists.y +0 -57
  51. data/sample/syntax.y +0 -46
  52. data/sample/yyerr.y +0 -46
  53. data/setup.rb +0 -1587
  54. data/tasks/doc.rb +0 -12
  55. data/tasks/email.rb +0 -55
  56. data/test/assets/cadenza.y +0 -170
  57. data/test/assets/cast.y +0 -926
  58. data/test/assets/chk.y +0 -126
  59. data/test/assets/conf.y +0 -16
  60. data/test/assets/csspool.y +0 -729
  61. data/test/assets/digraph.y +0 -29
  62. data/test/assets/echk.y +0 -118
  63. data/test/assets/edtf.y +0 -583
  64. data/test/assets/err.y +0 -60
  65. data/test/assets/error_recovery.y +0 -35
  66. data/test/assets/expect.y +0 -7
  67. data/test/assets/firstline.y +0 -4
  68. data/test/assets/huia.y +0 -318
  69. data/test/assets/ichk.y +0 -102
  70. data/test/assets/intp.y +0 -546
  71. data/test/assets/journey.y +0 -47
  72. data/test/assets/liquor.y +0 -313
  73. data/test/assets/machete.y +0 -423
  74. data/test/assets/macruby.y +0 -2197
  75. data/test/assets/mailp.y +0 -437
  76. data/test/assets/mediacloth.y +0 -599
  77. data/test/assets/mof.y +0 -649
  78. data/test/assets/namae.y +0 -302
  79. data/test/assets/nasl.y +0 -626
  80. data/test/assets/newsyn.y +0 -25
  81. data/test/assets/noend.y +0 -4
  82. data/test/assets/nokogiri-css.y +0 -255
  83. data/test/assets/nonass.y +0 -41
  84. data/test/assets/normal.y +0 -27
  85. data/test/assets/norule.y +0 -4
  86. data/test/assets/nullbug1.y +0 -25
  87. data/test/assets/nullbug2.y +0 -15
  88. data/test/assets/opal.y +0 -1807
  89. data/test/assets/opt.y +0 -123
  90. data/test/assets/percent.y +0 -35
  91. data/test/assets/php_serialization.y +0 -98
  92. data/test/assets/recv.y +0 -97
  93. data/test/assets/riml.y +0 -665
  94. data/test/assets/rrconf.y +0 -14
  95. data/test/assets/ruby18.y +0 -1943
  96. data/test/assets/ruby19.y +0 -2174
  97. data/test/assets/ruby20.y +0 -2350
  98. data/test/assets/ruby21.y +0 -2359
  99. data/test/assets/ruby22.y +0 -2381
  100. data/test/assets/scan.y +0 -72
  101. data/test/assets/syntax.y +0 -50
  102. data/test/assets/tp_plus.y +0 -622
  103. data/test/assets/twowaysql.y +0 -278
  104. data/test/assets/unterm.y +0 -5
  105. data/test/assets/useless.y +0 -12
  106. data/test/assets/yyerr.y +0 -46
  107. data/test/bench.y +0 -36
  108. data/test/helper.rb +0 -115
  109. data/test/infini.y +0 -8
  110. data/test/regress/cadenza +0 -796
  111. data/test/regress/cast +0 -3425
  112. data/test/regress/csspool +0 -2318
  113. data/test/regress/edtf +0 -1794
  114. data/test/regress/huia +0 -1392
  115. data/test/regress/journey +0 -222
  116. data/test/regress/liquor +0 -885
  117. data/test/regress/machete +0 -833
  118. data/test/regress/mediacloth +0 -1463
  119. data/test/regress/mof +0 -1368
  120. data/test/regress/namae +0 -634
  121. data/test/regress/nasl +0 -2058
  122. data/test/regress/nokogiri-css +0 -836
  123. data/test/regress/opal +0 -6429
  124. data/test/regress/php_serialization +0 -336
  125. data/test/regress/riml +0 -3297
  126. data/test/regress/ruby18 +0 -6351
  127. data/test/regress/ruby22 +0 -7456
  128. data/test/regress/tp_plus +0 -1933
  129. data/test/regress/twowaysql +0 -556
  130. data/test/scandata/brace +0 -7
  131. data/test/scandata/gvar +0 -1
  132. data/test/scandata/normal +0 -4
  133. data/test/scandata/percent +0 -18
  134. data/test/scandata/slash +0 -10
  135. data/test/src.intp +0 -34
  136. data/test/start.y +0 -20
  137. data/test/test_chk_y.rb +0 -52
  138. data/test/test_grammar_file_parser.rb +0 -15
  139. data/test/test_racc_command.rb +0 -322
  140. data/test/test_scan_y.rb +0 -52
  141. data/test/testscanner.rb +0 -51
  142. data/web/racc.en.rhtml +0 -42
  143. data/web/racc.ja.rhtml +0 -51
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: racc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.16
4
+ version: 1.6.0
5
5
  platform: java
6
6
  authors:
7
7
  - Minero Aoki
@@ -9,9 +9,9 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-01-11 00:00:00.000000000 Z
12
+ date: 2021-10-19 00:00:00.000000000 Z
13
13
  dependencies: []
14
- description: |-
14
+ description: |
15
15
  Racc is a LALR(1) parser generator.
16
16
  It is written in Ruby itself, and generates Ruby program.
17
17
 
@@ -23,37 +23,30 @@ email:
23
23
  - aaron@tenderlovemaking.com
24
24
  executables:
25
25
  - racc
26
- - racc2y
27
- - y2racc
28
26
  extensions: []
29
27
  extra_rdoc_files:
30
- - Manifest.txt
31
28
  - README.ja.rdoc
32
29
  - README.rdoc
33
- - rdoc/en/NEWS.en.rdoc
34
- - rdoc/en/grammar.en.rdoc
35
- - rdoc/ja/NEWS.ja.rdoc
36
- - rdoc/ja/debug.ja.rdoc
37
- - rdoc/ja/grammar.ja.rdoc
38
- - rdoc/ja/parser.ja.rdoc
39
30
  files:
40
31
  - COPYING
41
32
  - ChangeLog
42
- - DEPENDS
43
- - Manifest.txt
44
33
  - README.ja.rdoc
45
34
  - README.rdoc
46
- - Rakefile
47
35
  - TODO
48
36
  - bin/racc
49
- - bin/racc2y
50
- - bin/y2racc
37
+ - doc/en/NEWS.en.rdoc
38
+ - doc/en/grammar.en.rdoc
39
+ - doc/en/grammar2.en.rdoc
40
+ - doc/ja/NEWS.ja.rdoc
41
+ - doc/ja/command.ja.html
42
+ - doc/ja/debug.ja.rdoc
43
+ - doc/ja/grammar.ja.rdoc
44
+ - doc/ja/index.ja.html
45
+ - doc/ja/parser.ja.rdoc
46
+ - doc/ja/usage.ja.html
51
47
  - ext/racc/MANIFEST
52
- - ext/racc/com/headius/racc/Cparse.java
53
48
  - ext/racc/cparse/cparse.c
54
49
  - ext/racc/cparse/extconf.rb
55
- - fastcache/extconf.rb
56
- - fastcache/fastcache.c
57
50
  - lib/racc.rb
58
51
  - lib/racc/compat.rb
59
52
  - lib/racc/cparse-jruby.jar
@@ -67,125 +60,14 @@ files:
67
60
  - lib/racc/parser-text.rb
68
61
  - lib/racc/parser.rb
69
62
  - lib/racc/parserfilegenerator.rb
70
- - lib/racc/pre-setup
71
63
  - lib/racc/sourcetext.rb
72
64
  - lib/racc/state.rb
73
65
  - lib/racc/statetransitiontable.rb
74
66
  - lib/racc/static.rb
75
- - misc/dist.sh
76
- - rdoc/en/NEWS.en.rdoc
77
- - rdoc/en/grammar.en.rdoc
78
- - rdoc/ja/NEWS.ja.rdoc
79
- - rdoc/ja/command.ja.html
80
- - rdoc/ja/debug.ja.rdoc
81
- - rdoc/ja/grammar.ja.rdoc
82
- - rdoc/ja/index.ja.html
83
- - rdoc/ja/parser.ja.rdoc
84
- - rdoc/ja/usage.ja.html
85
- - sample/array.y
86
- - sample/array2.y
87
- - sample/calc-ja.y
88
- - sample/calc.y
89
- - sample/conflict.y
90
- - sample/hash.y
91
- - sample/lalr.y
92
- - sample/lists.y
93
- - sample/syntax.y
94
- - sample/yyerr.y
95
- - setup.rb
96
- - tasks/doc.rb
97
- - tasks/email.rb
98
- - test/assets/cadenza.y
99
- - test/assets/cast.y
100
- - test/assets/chk.y
101
- - test/assets/conf.y
102
- - test/assets/csspool.y
103
- - test/assets/digraph.y
104
- - test/assets/echk.y
105
- - test/assets/edtf.y
106
- - test/assets/err.y
107
- - test/assets/error_recovery.y
108
- - test/assets/expect.y
109
- - test/assets/firstline.y
110
- - test/assets/huia.y
111
- - test/assets/ichk.y
112
- - test/assets/intp.y
113
- - test/assets/journey.y
114
- - test/assets/liquor.y
115
- - test/assets/machete.y
116
- - test/assets/macruby.y
117
- - test/assets/mailp.y
118
- - test/assets/mediacloth.y
119
- - test/assets/mof.y
120
- - test/assets/namae.y
121
- - test/assets/nasl.y
122
- - test/assets/newsyn.y
123
- - test/assets/noend.y
124
- - test/assets/nokogiri-css.y
125
- - test/assets/nonass.y
126
- - test/assets/normal.y
127
- - test/assets/norule.y
128
- - test/assets/nullbug1.y
129
- - test/assets/nullbug2.y
130
- - test/assets/opal.y
131
- - test/assets/opt.y
132
- - test/assets/percent.y
133
- - test/assets/php_serialization.y
134
- - test/assets/recv.y
135
- - test/assets/riml.y
136
- - test/assets/rrconf.y
137
- - test/assets/ruby18.y
138
- - test/assets/ruby19.y
139
- - test/assets/ruby20.y
140
- - test/assets/ruby21.y
141
- - test/assets/ruby22.y
142
- - test/assets/scan.y
143
- - test/assets/syntax.y
144
- - test/assets/tp_plus.y
145
- - test/assets/twowaysql.y
146
- - test/assets/unterm.y
147
- - test/assets/useless.y
148
- - test/assets/yyerr.y
149
- - test/bench.y
150
- - test/helper.rb
151
- - test/infini.y
152
- - test/regress/cadenza
153
- - test/regress/cast
154
- - test/regress/csspool
155
- - test/regress/edtf
156
- - test/regress/huia
157
- - test/regress/journey
158
- - test/regress/liquor
159
- - test/regress/machete
160
- - test/regress/mediacloth
161
- - test/regress/mof
162
- - test/regress/namae
163
- - test/regress/nasl
164
- - test/regress/nokogiri-css
165
- - test/regress/opal
166
- - test/regress/php_serialization
167
- - test/regress/riml
168
- - test/regress/ruby18
169
- - test/regress/ruby22
170
- - test/regress/tp_plus
171
- - test/regress/twowaysql
172
- - test/scandata/brace
173
- - test/scandata/gvar
174
- - test/scandata/normal
175
- - test/scandata/percent
176
- - test/scandata/slash
177
- - test/src.intp
178
- - test/start.y
179
- - test/test_chk_y.rb
180
- - test/test_grammar_file_parser.rb
181
- - test/test_racc_command.rb
182
- - test/test_scan_y.rb
183
- - test/testscanner.rb
184
- - web/racc.en.rhtml
185
- - web/racc.ja.rhtml
186
- homepage: http://i.loveruby.net/en/projects/racc/
67
+ homepage: https://i.loveruby.net/en/projects/racc/
187
68
  licenses:
188
- - MIT
69
+ - Ruby
70
+ - BSD-2-Clause
189
71
  metadata: {}
190
72
  post_install_message:
191
73
  rdoc_options:
@@ -197,15 +79,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
197
79
  requirements:
198
80
  - - ">="
199
81
  - !ruby/object:Gem::Version
200
- version: '0'
82
+ version: '2.5'
201
83
  required_rubygems_version: !ruby/object:Gem::Requirement
202
84
  requirements:
203
85
  - - ">="
204
86
  - !ruby/object:Gem::Version
205
87
  version: '0'
206
88
  requirements: []
207
- rubyforge_project:
208
- rubygems_version: 2.7.10
89
+ rubygems_version: 3.2.29
209
90
  signing_key:
210
91
  specification_version: 4
211
92
  summary: Racc is a LALR(1) parser generator
data/DEPENDS DELETED
@@ -1,4 +0,0 @@
1
- racc: raccruntime
2
- raccruntime:
3
- y2racc: strscan
4
- racc2y: racc
data/Manifest.txt DELETED
@@ -1,146 +0,0 @@
1
- COPYING
2
- ChangeLog
3
- DEPENDS
4
- Manifest.txt
5
- README.ja.rdoc
6
- README.rdoc
7
- Rakefile
8
- TODO
9
- bin/racc
10
- bin/racc2y
11
- bin/y2racc
12
- ext/racc/MANIFEST
13
- ext/racc/cparse/cparse.c
14
- ext/racc/cparse/depend
15
- ext/racc/cparse/extconf.rb
16
- ext/racc/com/headius/racc/Cparse.java
17
- fastcache/extconf.rb
18
- fastcache/fastcache.c
19
- lib/racc.rb
20
- lib/racc/compat.rb
21
- lib/racc/debugflags.rb
22
- lib/racc/exception.rb
23
- lib/racc/grammar.rb
24
- lib/racc/grammarfileparser.rb
25
- lib/racc/info.rb
26
- lib/racc/iset.rb
27
- lib/racc/logfilegenerator.rb
28
- lib/racc/parser-text.rb
29
- lib/racc/parser.rb
30
- lib/racc/parserfilegenerator.rb
31
- lib/racc/pre-setup
32
- lib/racc/sourcetext.rb
33
- lib/racc/state.rb
34
- lib/racc/statetransitiontable.rb
35
- lib/racc/static.rb
36
- misc/dist.sh
37
- rdoc/en/NEWS.en.rdoc
38
- rdoc/en/grammar.en.rdoc
39
- rdoc/ja/NEWS.ja.rdoc
40
- rdoc/ja/command.ja.html
41
- rdoc/ja/debug.ja.rdoc
42
- rdoc/ja/grammar.ja.rdoc
43
- rdoc/ja/index.ja.html
44
- rdoc/ja/parser.ja.rdoc
45
- rdoc/ja/usage.ja.html
46
- sample/array.y
47
- sample/array2.y
48
- sample/calc-ja.y
49
- sample/calc.y
50
- sample/conflict.y
51
- sample/hash.y
52
- sample/lalr.y
53
- sample/lists.y
54
- sample/syntax.y
55
- sample/yyerr.y
56
- setup.rb
57
- tasks/doc.rb
58
- tasks/email.rb
59
- test/assets/cadenza.y
60
- test/assets/cast.y
61
- test/assets/chk.y
62
- test/assets/conf.y
63
- test/assets/csspool.y
64
- test/assets/digraph.y
65
- test/assets/echk.y
66
- test/assets/edtf.y
67
- test/assets/err.y
68
- test/assets/error_recovery.y
69
- test/assets/expect.y
70
- test/assets/firstline.y
71
- test/assets/huia.y
72
- test/assets/ichk.y
73
- test/assets/intp.y
74
- test/assets/journey.y
75
- test/assets/liquor.y
76
- test/assets/machete.y
77
- test/assets/macruby.y
78
- test/assets/mediacloth.y
79
- test/assets/mailp.y
80
- test/assets/mof.y
81
- test/assets/namae.y
82
- test/assets/nasl.y
83
- test/assets/newsyn.y
84
- test/assets/noend.y
85
- test/assets/nokogiri-css.y
86
- test/assets/nonass.y
87
- test/assets/normal.y
88
- test/assets/norule.y
89
- test/assets/nullbug1.y
90
- test/assets/nullbug2.y
91
- test/assets/opal.y
92
- test/assets/opt.y
93
- test/assets/percent.y
94
- test/assets/php_serialization.y
95
- test/assets/recv.y
96
- test/assets/riml.y
97
- test/assets/rrconf.y
98
- test/assets/ruby18.y
99
- test/assets/ruby19.y
100
- test/assets/ruby20.y
101
- test/assets/ruby21.y
102
- test/assets/ruby22.y
103
- test/assets/scan.y
104
- test/assets/syntax.y
105
- test/assets/tp_plus.y
106
- test/assets/twowaysql.y
107
- test/assets/unterm.y
108
- test/assets/useless.y
109
- test/assets/yyerr.y
110
- test/bench.y
111
- test/helper.rb
112
- test/infini.y
113
- test/regress/cadenza
114
- test/regress/cast
115
- test/regress/csspool
116
- test/regress/edtf
117
- test/regress/journey
118
- test/regress/huia
119
- test/regress/liquor
120
- test/regress/machete
121
- test/regress/mediacloth
122
- test/regress/mof
123
- test/regress/namae
124
- test/regress/nasl
125
- test/regress/nokogiri-css
126
- test/regress/opal
127
- test/regress/php_serialization
128
- test/regress/riml
129
- test/regress/ruby18
130
- test/regress/ruby22
131
- test/regress/tp_plus
132
- test/regress/twowaysql
133
- test/scandata/brace
134
- test/scandata/gvar
135
- test/scandata/normal
136
- test/scandata/percent
137
- test/scandata/slash
138
- test/src.intp
139
- test/start.y
140
- test/test_chk_y.rb
141
- test/test_grammar_file_parser.rb
142
- test/test_racc_command.rb
143
- test/test_scan_y.rb
144
- test/testscanner.rb
145
- web/racc.en.rhtml
146
- web/racc.ja.rhtml
data/Rakefile DELETED
@@ -1,58 +0,0 @@
1
- # -*- ruby -*-
2
-
3
- require 'rake/testtask'
4
-
5
- Rake::TestTask.new(:test) do |t|
6
- t.test_files = FileList["test/**/test_*.rb"]
7
- end
8
- gem 'rake-compiler', '>= 0.4.1'
9
-
10
- def java?
11
- /java/ === RUBY_PLATFORM
12
- end
13
- def jruby?
14
- Object.const_defined?(:RUBY_ENGINE) and 'jruby' == RUBY_ENGINE
15
- end
16
-
17
- file 'lib/racc/parser-text.rb' => ['lib/racc/parser.rb'] do |t|
18
- source = 'lib/racc/parser.rb'
19
-
20
- open(t.name, 'wb') { |io|
21
- io.write(<<-eorb)
22
- module Racc
23
- PARSER_TEXT = <<'__end_of_file__'
24
- #{File.read(source)}
25
- __end_of_file__
26
- end
27
- eorb
28
- }
29
- end
30
-
31
- if jruby?
32
- # JRUBY
33
- require "rake/javaextensiontask"
34
- Rake::JavaExtensionTask.new("cparse") do |ext|
35
- jruby_home = RbConfig::CONFIG['prefix']
36
- ext.lib_dir = File.join 'lib', 'racc'
37
- ext.ext_dir = File.join 'ext', 'racc'
38
- # source/target jvm
39
- ext.source_version = '1.6'
40
- ext.target_version = '1.6'
41
- jars = ["#{jruby_home}/lib/jruby.jar"] + FileList['lib/*.jar']
42
- ext.classpath = jars.map { |x| File.expand_path x }.join( ':' )
43
- ext.name = 'cparse-jruby'
44
- end
45
-
46
- task :compile => ['lib/racc/parser-text.rb']
47
- else
48
- # MRI
49
- require "rake/extensiontask"
50
- Rake::ExtensionTask.new "cparse" do |ext|
51
- ext.lib_dir = File.join 'lib', 'racc'
52
- ext.ext_dir = File.join 'ext', 'racc', 'cparse'
53
- end
54
-
55
- task :compile => 'lib/racc/parser-text.rb'
56
- end
57
-
58
- task :test => :compile
data/bin/racc2y DELETED
@@ -1,195 +0,0 @@
1
- #!/usr/local/bin/ruby
2
- #
3
- # $Id$
4
- #
5
- # Copyright (c) 1999-2006 Minero Aoki
6
- #
7
- # This program is feee software.
8
- # You can distribute/modify this program under the terms of
9
- # the GNU LGPL, Lesser General Public License version 2.1.
10
- # For details of the LGPL, see the file "COPYING".
11
- #
12
-
13
- require 'racc/grammarfileparser'
14
- require 'racc/info'
15
- require 'optparse'
16
-
17
- def main
18
- @with_action = true
19
- with_header = false
20
- with_inner = false
21
- with_footer = false
22
- output = nil
23
- parser = OptionParser.new
24
- parser.banner = "Usage: #{File.basename($0)} [-AHIF] [-oFILENAME] GRAMMARFILE"
25
- parser.on('-o', '--output=FILENAME', 'output file name [<input>.yacc]') {|name|
26
- output = name
27
- }
28
- parser.on('-A', '--without-action', 'Does not include actions.') {
29
- @with_action = false
30
- }
31
- parser.on('-H', '--with-header', 'Includes header part.') {
32
- with_header = true
33
- }
34
- parser.on('-I', '--with-inner', 'Includes inner part.') {
35
- with_inner = true
36
- }
37
- parser.on('-F', '--with-footer', 'Includes footer part.') {
38
- with_footer = true
39
- }
40
- parser.on('--version', 'Prints version and quit.') {
41
- puts "racc2y version #{Racc::Version}"
42
- exit 0
43
- }
44
- parser.on('--copyright', 'Prints copyright and quit.') {
45
- puts Racc::Copyright
46
- exit 0
47
- }
48
- parser.on('--help', 'Prints this message and quit.') {
49
- puts parser.help
50
- exit 1
51
- }
52
- begin
53
- parser.parse!
54
- rescue OptionParser::ParseError => err
55
- $stderr.puts err.message
56
- $stderr.puts parser.help
57
- exit 1
58
- end
59
- if ARGV.empty?
60
- $stderr.puts "no input file"
61
- exit 1
62
- end
63
- unless ARGV.size == 1
64
- $stderr.puts "too many inputs"
65
- exit 1
66
- end
67
- input = ARGV[0]
68
-
69
- begin
70
- result = Racc::GrammarFileParser.parse_file(input)
71
- result.grammar.init
72
- File.open(output || "#{input}.yacc", 'w') {|f|
73
- f.puts "/* generated from #{input} */"
74
- if with_header
75
- f.puts
76
- f.puts '%{'
77
- print_user_codes f, result.params.header
78
- f.puts '%}'
79
- end
80
- f.puts
81
- print_terminals f, result.grammar
82
- f.puts
83
- print_precedence_table f, precedence_table(result.grammar)
84
- f.puts
85
- f.puts '%%'
86
- print_grammar f, result.grammar
87
- f.puts '%%'
88
- if with_inner
89
- f.puts '/*---- inner ----*/'
90
- print_user_codes f, result.params.inner
91
- end
92
- if with_footer
93
- f.puts '/*---- footer ----*/'
94
- print_user_codes f, result.params.footer
95
- end
96
- }
97
- rescue SystemCallError => err
98
- $stderr.puts err.message
99
- exit 1
100
- end
101
- end
102
-
103
- def print_terminals(f, grammar)
104
- init_indent = '%token'.size
105
- f.print '%token'
106
- columns = init_indent
107
- grammar.symboltable.each_terminal do |t|
108
- next unless t.terminal?
109
- next if t.dummy?
110
- next if t == grammar.symboltable.anchor
111
- next if t == grammar.symboltable.error
112
- unless t.value.kind_of?(String)
113
- if columns > 60
114
- f.puts
115
- f.print ' ' * init_indent
116
- columns = init_indent
117
- end
118
- columns += f.write(" #{yacc_symbol(t)}")
119
- end
120
- end
121
- f.puts
122
- end
123
-
124
- def precedence_table(grammar)
125
- table = []
126
- grammar.symboltable.select {|sym| sym.precedence }.each do |sym|
127
- (table[sym.prec] ||= [sym.assoc]).push sym
128
- end
129
- table.compact
130
- end
131
-
132
- def print_precedence_table(f, table)
133
- return if table.empty?
134
- f.puts '/* precedance table */'
135
- table.each do |syms|
136
- assoc = syms.shift
137
- f.printf '%%%-8s ', assoc.to_s.downcase
138
- f.puts syms.map {|s| yacc_symbol(s) }.join(' ')
139
- end
140
- f.puts
141
- end
142
-
143
- def print_grammar(f, grammar)
144
- prev_target = nil
145
- indent = 10
146
- embactions = []
147
- grammar.each do |rule|
148
- if rule.target.dummy?
149
- embactions.push rule.action unless rule.action.empty?
150
- next
151
- end
152
- if rule.target == prev_target
153
- f.print ' ' * indent, '|'
154
- else
155
- prev_target = rule.target
156
- f.printf "\n%-10s:", yacc_symbol(prev_target)
157
- end
158
- rule.symbols.each do |s|
159
- if s.dummy? # target of dummy rule for embedded action
160
- f.puts
161
- print_action f, embactions.shift, indent
162
- f.print ' ' * (indent + 1)
163
- else
164
- f.print ' ', yacc_symbol(s)
165
- end
166
- end
167
- if rule.specified_prec
168
- f.print ' %prec ', yacc_symbol(rule.specified_prec)
169
- end
170
- f.puts
171
- unless rule.action.empty?
172
- print_action f, rule.action, indent
173
- end
174
- end
175
- end
176
-
177
- def print_action(f, action, indent)
178
- return unless @with_action
179
- f.print ' ' * (indent + 4), "{\n"
180
- f.print ' ' * (indent + 6), action.source.text.strip, "\n"
181
- f.print ' ' * (indent + 4) , "}\n"
182
- end
183
-
184
- def print_user_codes(f, srcs)
185
- return if srcs.empty?
186
- srcs.each do |src|
187
- f.puts src.text
188
- end
189
- end
190
-
191
- def yacc_symbol(s)
192
- s.to_s.gsub('"', "'")
193
- end
194
-
195
- main