racc 1.4.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitattributes +2 -0
- data/.gitignore +7 -0
- data/COPYING +515 -0
- data/ChangeLog +846 -0
- data/DEPENDS +4 -0
- data/README.en.rdoc +86 -0
- data/README.ja.rdoc +96 -0
- data/Rakefile +15 -0
- data/TODO +5 -0
- data/bin/racc +308 -0
- data/bin/racc2y +195 -0
- data/bin/y2racc +339 -0
- data/doc/en/NEWS.en.rdoc +282 -0
- data/doc/en/command.en.html +78 -0
- data/doc/en/debug.en.rdoc +20 -0
- data/doc/en/grammar.en.rdoc +230 -0
- data/doc/en/index.en.html +10 -0
- data/doc/en/parser.en.rdoc +74 -0
- data/doc/en/usage.en.html +92 -0
- data/doc/ja/NEWS.ja.rdoc +307 -0
- data/doc/ja/command.ja.html +94 -0
- data/doc/ja/debug.ja.rdoc +36 -0
- data/doc/ja/grammar.ja.rdoc +348 -0
- data/doc/ja/index.ja.html +10 -0
- data/doc/ja/parser.ja.rdoc +125 -0
- data/doc/ja/usage.ja.html +414 -0
- data/ext/racc/cparse/MANIFEST +4 -0
- data/ext/racc/cparse/cparse.c +824 -0
- data/ext/racc/cparse/depend +1 -0
- data/ext/racc/cparse/extconf.rb +7 -0
- data/fastcache/extconf.rb +2 -0
- data/fastcache/fastcache.c +185 -0
- data/lib/racc.rb +6 -0
- data/lib/racc/compat.rb +40 -0
- data/lib/racc/debugflags.rb +59 -0
- data/lib/racc/exception.rb +15 -0
- data/lib/racc/grammar.rb +1115 -0
- data/lib/racc/grammarfileparser.rb +559 -0
- data/lib/racc/info.rb +16 -0
- data/lib/racc/iset.rb +91 -0
- data/lib/racc/logfilegenerator.rb +214 -0
- data/lib/racc/parser.rb +439 -0
- data/lib/racc/parserfilegenerator.rb +511 -0
- data/lib/racc/pre-setup +13 -0
- data/lib/racc/sourcetext.rb +34 -0
- data/lib/racc/state.rb +971 -0
- data/lib/racc/statetransitiontable.rb +316 -0
- data/lib/racc/static.rb +5 -0
- data/misc/dist.sh +31 -0
- data/sample/array.y +67 -0
- data/sample/array2.y +59 -0
- data/sample/calc-ja.y +66 -0
- data/sample/calc.y +65 -0
- data/sample/conflict.y +15 -0
- data/sample/hash.y +60 -0
- data/sample/lalr.y +17 -0
- data/sample/lists.y +57 -0
- data/sample/syntax.y +46 -0
- data/sample/yyerr.y +46 -0
- data/setup.rb +1587 -0
- data/tasks/doc.rb +12 -0
- data/tasks/email.rb +55 -0
- data/tasks/file.rb +37 -0
- data/tasks/gem.rb +37 -0
- data/tasks/test.rb +16 -0
- data/test/assets/chk.y +126 -0
- data/test/assets/conf.y +16 -0
- data/test/assets/digraph.y +29 -0
- data/test/assets/echk.y +118 -0
- data/test/assets/err.y +60 -0
- data/test/assets/expect.y +7 -0
- data/test/assets/firstline.y +4 -0
- data/test/assets/ichk.y +102 -0
- data/test/assets/intp.y +546 -0
- data/test/assets/mailp.y +437 -0
- data/test/assets/newsyn.y +25 -0
- data/test/assets/noend.y +4 -0
- data/test/assets/nonass.y +41 -0
- data/test/assets/normal.y +27 -0
- data/test/assets/norule.y +4 -0
- data/test/assets/nullbug1.y +25 -0
- data/test/assets/nullbug2.y +15 -0
- data/test/assets/opt.y +123 -0
- data/test/assets/percent.y +35 -0
- data/test/assets/recv.y +97 -0
- data/test/assets/rrconf.y +14 -0
- data/test/assets/scan.y +72 -0
- data/test/assets/syntax.y +50 -0
- data/test/assets/unterm.y +5 -0
- data/test/assets/useless.y +12 -0
- data/test/assets/yyerr.y +46 -0
- data/test/bench.y +36 -0
- data/test/helper.rb +88 -0
- data/test/infini.y +8 -0
- data/test/scandata/brace +7 -0
- data/test/scandata/gvar +1 -0
- data/test/scandata/normal +4 -0
- data/test/scandata/percent +18 -0
- data/test/scandata/slash +10 -0
- data/test/src.intp +34 -0
- data/test/start.y +20 -0
- data/test/test_chk_y.rb +51 -0
- data/test/test_grammar_file_parser.rb +15 -0
- data/test/test_racc_command.rb +155 -0
- data/test/test_scan_y.rb +51 -0
- data/test/testscanner.rb +51 -0
- data/web/racc.en.rhtml +42 -0
- data/web/racc.ja.rhtml +51 -0
- metadata +166 -0
data/test/test_scan_y.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
|
2
|
+
|
3
|
+
module Racc
|
4
|
+
class TestScanY < TestCase
|
5
|
+
def setup
|
6
|
+
file = File.join(ASSET_DIR, 'scan.y')
|
7
|
+
@debug_flags = Racc::DebugFlags.parse_option_string('o')
|
8
|
+
parser = Racc::GrammarFileParser.new(@debug_flags)
|
9
|
+
@result = parser.parse(File.read(file), File.basename(file))
|
10
|
+
@states = Racc::States.new(@result.grammar).nfa
|
11
|
+
@states.dfa
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_compile
|
15
|
+
generator = Racc::ParserFileGenerator.new(@states, @result.params.dup)
|
16
|
+
|
17
|
+
fork {
|
18
|
+
eval(generator.generate_parser)
|
19
|
+
}
|
20
|
+
Process.wait
|
21
|
+
assert_equal 0, $?.exitstatus
|
22
|
+
|
23
|
+
grammar = @states.grammar
|
24
|
+
|
25
|
+
assert_equal 0, @states.n_srconflicts
|
26
|
+
assert_equal 0, @states.n_rrconflicts
|
27
|
+
assert_equal 0, grammar.n_useless_nonterminals
|
28
|
+
assert_equal 0, grammar.n_useless_rules
|
29
|
+
assert_nil grammar.n_expected_srconflicts
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_compile_line_convert
|
33
|
+
params = @result.params.dup
|
34
|
+
params.convert_line_all = true
|
35
|
+
|
36
|
+
generator = Racc::ParserFileGenerator.new(@states, @result.params.dup)
|
37
|
+
|
38
|
+
fork { eval(generator.generate_parser) }
|
39
|
+
assert_equal 0, $?.exitstatus
|
40
|
+
Process.wait
|
41
|
+
|
42
|
+
grammar = @states.grammar
|
43
|
+
|
44
|
+
assert_equal 0, @states.n_srconflicts
|
45
|
+
assert_equal 0, @states.n_rrconflicts
|
46
|
+
assert_equal 0, grammar.n_useless_nonterminals
|
47
|
+
assert_equal 0, grammar.n_useless_rules
|
48
|
+
assert_nil grammar.n_expected_srconflicts
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/test/testscanner.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
#
|
2
|
+
# racc scanner tester
|
3
|
+
#
|
4
|
+
|
5
|
+
require 'racc/raccs'
|
6
|
+
|
7
|
+
|
8
|
+
class ScanError < StandardError; end
|
9
|
+
|
10
|
+
def testdata( dir, argv )
|
11
|
+
if argv.empty? then
|
12
|
+
Dir.glob( dir + '/*' ) -
|
13
|
+
Dir.glob( dir + '/*.swp' ) -
|
14
|
+
[ dir + '/CVS' ]
|
15
|
+
else
|
16
|
+
argv.collect {|i| dir + '/' + i }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
if ARGV.delete '--print' then
|
22
|
+
$raccs_print_type = true
|
23
|
+
printonly = true
|
24
|
+
else
|
25
|
+
printonly = false
|
26
|
+
end
|
27
|
+
|
28
|
+
testdata( File.dirname($0) + '/scandata', ARGV ).each do |file|
|
29
|
+
$stderr.print File.basename(file) + ': '
|
30
|
+
begin
|
31
|
+
ok = File.read(file)
|
32
|
+
s = Racc::GrammarFileScanner.new( ok )
|
33
|
+
sym, (val, lineno) = s.scan
|
34
|
+
if printonly then
|
35
|
+
$stderr.puts
|
36
|
+
$stderr.puts val
|
37
|
+
next
|
38
|
+
end
|
39
|
+
|
40
|
+
val = '{' + val + "}\n"
|
41
|
+
sym == :ACTION or raise ScanError, 'is not action!'
|
42
|
+
val == ok or raise ScanError, "\n>>>\n#{ok}----\n#{val}<<<"
|
43
|
+
|
44
|
+
$stderr.puts 'ok'
|
45
|
+
rescue => err
|
46
|
+
$stderr.puts 'fail (' + err.type.to_s + ')'
|
47
|
+
$stderr.puts err.message
|
48
|
+
$stderr.puts err.backtrace
|
49
|
+
$stderr.puts
|
50
|
+
end
|
51
|
+
end
|
data/web/racc.en.rhtml
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
% require 'makefile'
|
2
|
+
% version = Makefile.get_parameter('Makefile', 'version')
|
3
|
+
<h1>Racc</h1>
|
4
|
+
<p>
|
5
|
+
$Id$
|
6
|
+
</p>
|
7
|
+
|
8
|
+
<table summary="package descriptor">
|
9
|
+
<tr><th>Version</th><td><%= version %></td></tr>
|
10
|
+
<tr><th>Type</th><td>Parser Generator</td></tr>
|
11
|
+
<tr><th>Format</th><td>Ruby script + Ruby extention</td></tr>
|
12
|
+
<tr><th>Requirement</th><td>ruby (>=1.6)</td></tr>
|
13
|
+
<tr><th>License</th><td>LGPL</td></tr>
|
14
|
+
</table>
|
15
|
+
<p>
|
16
|
+
-- <a href="/archive/racc/racc-<%= version %>-all.tar.gz">Download (.tar.gz)</a>
|
17
|
+
-- <a href="/archive/racc/">Old Versions</a>
|
18
|
+
-- <a href="doc/">Online Manual</a>
|
19
|
+
--
|
20
|
+
</p>
|
21
|
+
|
22
|
+
<p>
|
23
|
+
Racc (Ruby yACC) is a LALR(1) parser generator for Ruby.
|
24
|
+
Version 1.4.x is stable release.
|
25
|
+
</p>
|
26
|
+
<p>
|
27
|
+
Parsers generated by Racc requires "Racc Runtime Module".
|
28
|
+
Ruby 1.8.x comes with this runtime.
|
29
|
+
If you want to run your parsers with ruby 1.6.x,
|
30
|
+
use "racc -E" command. For details, see <a href="doc/">online manual</a>.
|
31
|
+
</p>
|
32
|
+
|
33
|
+
<h2>Anonymous CVS</h2>
|
34
|
+
<p>
|
35
|
+
You can true latest version of Racc via anonymous CVS.
|
36
|
+
To check out working copy, type:
|
37
|
+
</p>
|
38
|
+
<pre>
|
39
|
+
$ cvs -d :pserver:anonymous@cvs.loveruby.net:/src login
|
40
|
+
Password: (Just hit [Enter])
|
41
|
+
$ cvs -d :pserver:anonymous@cvs.loveruby.net:/src co racc
|
42
|
+
</pre>
|
data/web/racc.ja.rhtml
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
% require 'makefile'
|
2
|
+
% version = Makefile.get_parameter('Makefile', 'version')
|
3
|
+
<h1>Racc</h1>
|
4
|
+
<p>
|
5
|
+
$Id$
|
6
|
+
</p>
|
7
|
+
<table summary="package descriptor">
|
8
|
+
<tr><th>�ǿ���</th><td><%= version %></td></tr>
|
9
|
+
<tr><th>����</th><td>parser generator</td></tr>
|
10
|
+
<tr><th>����</th><td>ruby script, ruby extention</td></tr>
|
11
|
+
<tr><th>ɬ�״Ķ�</th><td>ruby (>=1.6)</td></tr>
|
12
|
+
<tr><th>���۾��</th><td>LGPL</td></tr>
|
13
|
+
</table>
|
14
|
+
<ul>
|
15
|
+
<li><a href="/archive/racc/racc-<%= version %>-all.tar.gz">�����������</a></li>
|
16
|
+
<li><a href="/archive/racc/">��С������ꥹ��</a></li>
|
17
|
+
<li><a href="doc/">����饤��ޥ˥奢��</a></li>
|
18
|
+
</ul>
|
19
|
+
</p>
|
20
|
+
<p>
|
21
|
+
Ruby �Ѥ� LALR(1) �ѡ��������ͥ졼���Ǥ���
|
22
|
+
���������ѡ����Ϥ���ʤ�˹�®��ư��ޤ���
|
23
|
+
</p>
|
24
|
+
<p>
|
25
|
+
Racc �����������ѡ�����ư����˥����⥸�塼�뤬ɬ�פǤ���
|
26
|
+
Ruby 1.8 �ˤϤ��Υ���ब�ǽ餫��ź�դ���Ƥ���Τ�
|
27
|
+
����ͤ��ʤ�������פǤ�����Ruby 1.6 �������оݤˤ���Ȥ���
|
28
|
+
racc -E �ǥѡ�������������ɬ�פ�����ޤ���
|
29
|
+
</p>
|
30
|
+
<p>
|
31
|
+
�ʤ���Racc 1.4.x �Υ����� Ruby 1.8 ź�դ� Racc �����ϡ�
|
32
|
+
�����������ɾ�Ǥ���̯�˰㤤������ޤ����������˸ߴ���������ޤ���
|
33
|
+
</p>
|
34
|
+
|
35
|
+
<h2>����</h2>
|
36
|
+
<p>
|
37
|
+
�⤦����Ū����ʬ�ϸϤ�Ƥ���Ϥ��Ǥ���
|
38
|
+
TODO �Ϥޤ������Ĥ�����ޤ�������������¾�ˤ��äƤ�Τ�
|
39
|
+
��ʬ���礭���ѹ�����Ĥ��Ϥ���ޤ���
|
40
|
+
</p>
|
41
|
+
|
42
|
+
<h2>CVS ��ݥ��ȥ�</h2>
|
43
|
+
<p>
|
44
|
+
CVS ��Ȥ��� Racc �ο��κǿ��Ǥ�����Ǥ��ޤ���
|
45
|
+
���ޥ�ɥ饤��Ǽ��Τ褦���ǤäƤ���������
|
46
|
+
</p>
|
47
|
+
<pre>
|
48
|
+
$ cvs -d :pserver:anonymous@cvs.loveruby.net:/src login
|
49
|
+
Password: (������Enter���Ǥ�)
|
50
|
+
$ cvs -d :pserver:anonymous@cvs.loveruby.net:/src co racc
|
51
|
+
</pre>
|
metadata
ADDED
@@ -0,0 +1,166 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: racc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.4.6
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Aoki Minero
|
8
|
+
- Aaron Patterson
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2009-01-02 00:00:00 -08:00
|
14
|
+
default_executable:
|
15
|
+
dependencies: []
|
16
|
+
|
17
|
+
description: Racc is a LALR(1) parser generator. It is written in Ruby itself, and generates Ruby program.
|
18
|
+
email: aaronp@rubyforge.org
|
19
|
+
executables:
|
20
|
+
- racc
|
21
|
+
- racc2y
|
22
|
+
- y2racc
|
23
|
+
extensions:
|
24
|
+
- ext/racc/cparse/extconf.rb
|
25
|
+
extra_rdoc_files: []
|
26
|
+
|
27
|
+
files:
|
28
|
+
- .gitattributes
|
29
|
+
- .gitignore
|
30
|
+
- COPYING
|
31
|
+
- ChangeLog
|
32
|
+
- DEPENDS
|
33
|
+
- README.en.rdoc
|
34
|
+
- README.ja.rdoc
|
35
|
+
- Rakefile
|
36
|
+
- TODO
|
37
|
+
- bin/racc
|
38
|
+
- bin/racc2y
|
39
|
+
- bin/y2racc
|
40
|
+
- doc/en/NEWS.en.rdoc
|
41
|
+
- doc/en/command.en.html
|
42
|
+
- doc/en/debug.en.rdoc
|
43
|
+
- doc/en/grammar.en.rdoc
|
44
|
+
- doc/en/index.en.html
|
45
|
+
- doc/en/parser.en.rdoc
|
46
|
+
- doc/en/usage.en.html
|
47
|
+
- doc/ja/NEWS.ja.rdoc
|
48
|
+
- doc/ja/command.ja.html
|
49
|
+
- doc/ja/debug.ja.rdoc
|
50
|
+
- doc/ja/grammar.ja.rdoc
|
51
|
+
- doc/ja/index.ja.html
|
52
|
+
- doc/ja/parser.ja.rdoc
|
53
|
+
- doc/ja/usage.ja.html
|
54
|
+
- ext/racc/cparse/MANIFEST
|
55
|
+
- ext/racc/cparse/cparse.c
|
56
|
+
- ext/racc/cparse/depend
|
57
|
+
- ext/racc/cparse/extconf.rb
|
58
|
+
- fastcache/extconf.rb
|
59
|
+
- fastcache/fastcache.c
|
60
|
+
- lib/racc.rb
|
61
|
+
- lib/racc/compat.rb
|
62
|
+
- lib/racc/debugflags.rb
|
63
|
+
- lib/racc/exception.rb
|
64
|
+
- lib/racc/grammar.rb
|
65
|
+
- lib/racc/grammarfileparser.rb
|
66
|
+
- lib/racc/info.rb
|
67
|
+
- lib/racc/iset.rb
|
68
|
+
- lib/racc/logfilegenerator.rb
|
69
|
+
- lib/racc/parser.rb
|
70
|
+
- lib/racc/parserfilegenerator.rb
|
71
|
+
- lib/racc/pre-setup
|
72
|
+
- lib/racc/sourcetext.rb
|
73
|
+
- lib/racc/state.rb
|
74
|
+
- lib/racc/statetransitiontable.rb
|
75
|
+
- lib/racc/static.rb
|
76
|
+
- misc/dist.sh
|
77
|
+
- sample/array.y
|
78
|
+
- sample/array2.y
|
79
|
+
- sample/calc-ja.y
|
80
|
+
- sample/calc.y
|
81
|
+
- sample/conflict.y
|
82
|
+
- sample/hash.y
|
83
|
+
- sample/lalr.y
|
84
|
+
- sample/lists.y
|
85
|
+
- sample/syntax.y
|
86
|
+
- sample/yyerr.y
|
87
|
+
- setup.rb
|
88
|
+
- tasks/doc.rb
|
89
|
+
- tasks/email.rb
|
90
|
+
- tasks/file.rb
|
91
|
+
- tasks/gem.rb
|
92
|
+
- tasks/test.rb
|
93
|
+
- test/assets/chk.y
|
94
|
+
- test/assets/conf.y
|
95
|
+
- test/assets/digraph.y
|
96
|
+
- test/assets/echk.y
|
97
|
+
- test/assets/err.y
|
98
|
+
- test/assets/expect.y
|
99
|
+
- test/assets/firstline.y
|
100
|
+
- test/assets/ichk.y
|
101
|
+
- test/assets/intp.y
|
102
|
+
- test/assets/mailp.y
|
103
|
+
- test/assets/newsyn.y
|
104
|
+
- test/assets/noend.y
|
105
|
+
- test/assets/nonass.y
|
106
|
+
- test/assets/normal.y
|
107
|
+
- test/assets/norule.y
|
108
|
+
- test/assets/nullbug1.y
|
109
|
+
- test/assets/nullbug2.y
|
110
|
+
- test/assets/opt.y
|
111
|
+
- test/assets/percent.y
|
112
|
+
- test/assets/recv.y
|
113
|
+
- test/assets/rrconf.y
|
114
|
+
- test/assets/scan.y
|
115
|
+
- test/assets/syntax.y
|
116
|
+
- test/assets/unterm.y
|
117
|
+
- test/assets/useless.y
|
118
|
+
- test/assets/yyerr.y
|
119
|
+
- test/bench.y
|
120
|
+
- test/helper.rb
|
121
|
+
- test/infini.y
|
122
|
+
- test/scandata/brace
|
123
|
+
- test/scandata/gvar
|
124
|
+
- test/scandata/normal
|
125
|
+
- test/scandata/percent
|
126
|
+
- test/scandata/slash
|
127
|
+
- test/src.intp
|
128
|
+
- test/start.y
|
129
|
+
- test/test_chk_y.rb
|
130
|
+
- test/test_grammar_file_parser.rb
|
131
|
+
- test/test_racc_command.rb
|
132
|
+
- test/test_scan_y.rb
|
133
|
+
- test/testscanner.rb
|
134
|
+
- web/racc.en.rhtml
|
135
|
+
- web/racc.ja.rhtml
|
136
|
+
- lib/racc/parser-text.rb
|
137
|
+
has_rdoc: true
|
138
|
+
homepage: http://racc.rubyforge.org/
|
139
|
+
post_install_message:
|
140
|
+
rdoc_options:
|
141
|
+
- --main
|
142
|
+
- README.en.rdoc
|
143
|
+
require_paths:
|
144
|
+
- lib
|
145
|
+
- ext
|
146
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - ">="
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: "0"
|
151
|
+
version:
|
152
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
|
+
requirements:
|
154
|
+
- - ">="
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: "0"
|
157
|
+
version:
|
158
|
+
requirements: []
|
159
|
+
|
160
|
+
rubyforge_project: racc
|
161
|
+
rubygems_version: 1.3.1
|
162
|
+
signing_key:
|
163
|
+
specification_version: 2
|
164
|
+
summary: Racc is a LALR(1) parser generator.
|
165
|
+
test_files: []
|
166
|
+
|