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
data/fastcache/extconf.rb DELETED
@@ -1,2 +0,0 @@
1
- require 'mkmf'
2
- create_makefile 'corecache'
@@ -1,185 +0,0 @@
1
- /*
2
- $Id$
3
-
4
- Copyright (C) 2005 Minero Aoki
5
-
6
- This program is free software.
7
- You can distribute/modify this program under the terms of
8
- the GNU LGPL, Lesser General Public Licese version 2.1.
9
- */
10
-
11
- #include "ruby.h"
12
-
13
- static VALUE LALRcoreCache;
14
-
15
- struct item_holder {
16
- unsigned long hashval;
17
- VALUE core;
18
- VALUE state;
19
- struct item_holder *next;
20
- };
21
-
22
- struct lalr_state_cache {
23
- struct item_holder **bin;
24
- long size;
25
- long num;
26
- };
27
-
28
- static void
29
- lalrc_free(struct lalr_state_cache *p)
30
- {
31
- struct item_holder *tmp;
32
- long i;
33
-
34
- for (i = 0; i < p->size; i++) {
35
- while (tmp = p->bin[i]) {
36
- p->bin[i] = tmp->next;
37
- free(tmp);
38
- }
39
- }
40
- free(p->bin);
41
- free(p);
42
- }
43
-
44
- #define INIT_BIN 256
45
-
46
- static VALUE
47
- lalrc_s_new(VALUE self)
48
- {
49
- struct lalr_state_cache *cache;
50
-
51
- cache = ALLOC_N(struct lalr_state_cache, 1);
52
- cache->bin = ALLOC_N(struct item_holder*, INIT_BIN);
53
- cache->size = INIT_BIN;
54
- cache->num = 0;
55
- return Data_Wrap_Struct(LALRcoreCache, 0, lalrc_free, cache);
56
- }
57
-
58
- #define GET_LALRC(self, p) Data_Get_Struct(self, struct lalr_state_cache, p)
59
-
60
- static void
61
- lalrc_rehash(struct lalr_state_cache *p)
62
- {
63
- struct item_holder *top = 0, *tmp = 0;
64
- long i;
65
-
66
- for (i = p->size / 2; i < p->size; i++) {
67
- p->bin[i] = 0;
68
- }
69
- for (i = 0; i < p->size / 2; i++) {
70
- if (!p->bin[i])
71
- continue;
72
-
73
- tmp = p->bin[i];
74
- while (tmp->next)
75
- tmp = tmp->next;
76
- tmp->next = top;
77
- top = p->bin[i];
78
- p->bin[i] = 0;
79
- }
80
-
81
- while (top) {
82
- tmp = top;
83
- top = tmp->next;
84
- tmp->next = 0;
85
-
86
- i = tmp->hashval % p->size;
87
- if (p->bin[i]) {
88
- tmp->next = p->bin[i];
89
- p->bin[i] = tmp;
90
- }
91
- else {
92
- p->bin[i] = tmp;
93
- }
94
- }
95
- }
96
-
97
- static int
98
- coreeql(VALUE a, VALUE b)
99
- {
100
- long i;
101
-
102
- /* Check_Type(a, T_ARRAY);
103
- Check_Type(b, T_ARRAY); */
104
- if (RARRAY(a)->len != RARRAY(b)->len)
105
- return 0;
106
- for (i = 0; i < RARRAY(a)->len; i++)
107
- if (RARRAY(a)->ptr[i] != RARRAY(b)->ptr[i])
108
- return 0;
109
-
110
- return 1;
111
- }
112
-
113
- static unsigned long
114
- hashval(VALUE core)
115
- {
116
- unsigned long v = 0;
117
- long i, j;
118
-
119
- for (i = 0; i < RARRAY(core)->len; i++) {
120
- v *= RARRAY(core)->ptr[i];
121
- v ^= RARRAY(core)->ptr[i];
122
- }
123
- return v;
124
- }
125
-
126
- static VALUE
127
- lalrc_aref(VALUE self, VALUE core)
128
- {
129
- struct lalr_state_cache *p;
130
- unsigned long v;
131
- long i;
132
- struct item_holder *ad;
133
-
134
- /* Check_Type(core, T_ARRAY); */
135
- GET_LALRC(self, p);
136
- v = hashval(core);
137
- i = v % p->size;
138
- ad = p->bin[i];
139
- while (ad) {
140
- if (ad->hashval == v) {
141
- if (coreeql(core, ad->core)) {
142
- return ad->state;
143
- }
144
- else {
145
- printf(".");
146
- }
147
- }
148
- ad = ad->next;
149
- }
150
- return Qnil;
151
- }
152
-
153
- static VALUE
154
- lalrc_add_direct(VALUE self, VALUE core, VALUE state)
155
- {
156
- struct lalr_state_cache *p;
157
- struct item_holder *ad;
158
- long i;
159
-
160
- GET_LALRC(self, p);
161
- ad = ALLOC_N(struct item_holder, 1);
162
- ad->hashval = hashval(core);
163
- ad->core = core;
164
- ad->state = state;
165
-
166
- i = ad->hashval % p->size;
167
- ad->next = p->bin[i];
168
- p->bin[i] = ad;
169
- p->num++;
170
- if ((p->num / p->size) >= 1) {
171
- REALLOC_N(p->bin, struct item_holder*, p->size * 2);
172
- p->size *= 2;
173
- lalrc_rehash(p);
174
- }
175
- return Qnil;
176
- }
177
-
178
- void
179
- Init_corecache(void)
180
- {
181
- LALRcoreCache = rb_define_class("LALRcoreCache", rb_cObject);
182
- rb_define_singleton_method(LALRcoreCache, "new", lalrc_s_new, 0);
183
- rb_define_method(LALRcoreCache, "[]", lalrc_aref, 1);
184
- rb_define_method(LALRcoreCache, "[]=", lalrc_add_direct, 2);
185
- }
data/lib/racc/pre-setup DELETED
@@ -1,13 +0,0 @@
1
- def generate_parser_text_rb(target)
2
- return if File.exist?(srcfile(target))
3
- $stderr.puts "generating #{target}..."
4
- File.open(target, 'w') {|f|
5
- f.puts "module Racc"
6
- f.puts " PARSER_TEXT = <<'__end_of_file__'"
7
- f.puts File.read(srcfile('parser.rb'))
8
- f.puts "__end_of_file__"
9
- f.puts "end"
10
- }
11
- end
12
-
13
- generate_parser_text_rb 'parser-text.rb'
data/misc/dist.sh DELETED
@@ -1,31 +0,0 @@
1
- #!/bin/sh
2
-
3
- rm -rf tmp
4
- mkdir tmp
5
- cd tmp
6
-
7
- # racc, raccrt
8
- cvs -Q export -r`echo V$version | tr . -` -d racc-$version racc
9
- cd racc-$version
10
- make bootstrap lib/racc/parser-text.rb doc
11
- rm -r doc web bits fastcache
12
- cd ..
13
- mkdir -p raccrt-$version/lib/racc
14
- mv racc-$version/lib/racc/parser.rb raccrt-$version/lib/racc
15
- mv racc-$version/ext raccrt-$version
16
- cp racc-$version/setup.rb raccrt-$version
17
- cp racc-$version/README.* raccrt-$version
18
- cp racc-$version/COPYING raccrt-$version
19
- tar czf $ardir/racc/racc-$version.tar.gz racc-$version
20
- tar czf $ardir/raccrt/raccrt-$version.tar.gz raccrt-$version
21
-
22
- # -all
23
- mkdir -p racc-$version-all/packages
24
- cp racc-$version/setup.rb racc-$version-all
25
- cp racc-$version/README.* racc-$version-all
26
- mv racc-$version racc-$version-all/packages/racc
27
- mv raccrt-$version racc-$version-all/packages/raccrt
28
- tar czf $ardir/racc/racc-$version-all.tar.gz racc-$version-all
29
-
30
- cd ..
31
- rm -rf tmp
data/sample/array.y DELETED
@@ -1,67 +0,0 @@
1
- # $Id$
2
- #
3
- # convert Array-like string into Ruby's Array.
4
-
5
- class ArrayParser
6
-
7
- rule
8
-
9
- array : '[' contents ']'
10
- {
11
- result = val[1]
12
- }
13
- | '[' ']'
14
- {
15
- result = []
16
- }
17
-
18
- contents: ITEM
19
- {
20
- result = val
21
- }
22
- | contents ',' ITEM
23
- {
24
- result.push val[2]
25
- }
26
-
27
- ---- inner
28
-
29
- def parse(str)
30
- str = str.strip
31
- @q = []
32
- until str.empty?
33
- case str
34
- when /\A\s+/
35
- str = $'
36
- when /\A\w+/
37
- @q.push [:ITEM, $&]
38
- str = $'
39
- else
40
- c = str[0,1]
41
- @q.push [c, c]
42
- str = str[1..-1]
43
- end
44
- end
45
- @q.push [false, '$'] # is optional from Racc 1.3.7
46
- do_parse
47
- end
48
-
49
- def next_token
50
- @q.shift
51
- end
52
-
53
- ---- footer
54
-
55
- if $0 == __FILE__
56
- src = <<EOS
57
- [
58
- a, b, c,
59
- d,
60
- e ]
61
- EOS
62
- puts 'parsing:'
63
- print src
64
- puts
65
- puts 'result:'
66
- p ArrayParser.new.parse(src)
67
- end
data/sample/array2.y DELETED
@@ -1,59 +0,0 @@
1
- # $Id$
2
- #
3
- # Converting Array-like string into Ruby's Array, version 2.
4
- # This grammer uses no_result_var.
5
-
6
- class ArrayParser2
7
- options no_result_var
8
- rule
9
- array : '[' contents ']' { val[1] }
10
- | '[' ']' { [] }
11
-
12
- contents: ITEM { val }
13
- | contents ',' ITEM { val[0].push val[2]; val[0] }
14
- end
15
-
16
- ---- inner
17
-
18
- def parse(str)
19
- @str = str
20
- yyparse self, :scan
21
- end
22
-
23
- def scan
24
- str = @str.strip
25
- until str.empty?
26
- case str
27
- when /\A\s+/
28
- str = $'
29
- when /\A\w+/
30
- yield :ITEM, $&
31
- str = $'
32
- else
33
- c = str[0,1]
34
- yield c, c
35
- str = str[1..-1]
36
- end
37
- end
38
- yield false, '$' # is optional from Racc 1.3.7
39
- end
40
-
41
- def next_token
42
- @q.shift
43
- end
44
-
45
- ---- footer
46
-
47
- if $0 == __FILE__
48
- src = <<EOS
49
- [
50
- a, b, c,
51
- d,
52
- e ]
53
- EOS
54
- puts 'parsing:'
55
- print src
56
- puts
57
- puts 'result:'
58
- p ArrayParser2.new.parse(src)
59
- end
data/sample/calc-ja.y DELETED
@@ -1,66 +0,0 @@
1
- # $Id$
2
- #
3
- # A simple calculator, version 2.
4
- # This file contains Japanese characters (encoding=EUC-JP).
5
-
6
- class Calculator2
7
- prechigh
8
- nonassoc UMINUS
9
- left '*' '/'
10
- left '+' '-'
11
- preclow
12
- options no_result_var
13
- rule
14
- target : exp
15
- | /* none */ { 0 }
16
-
17
- exp : exp '+' exp { val[0] + val[2] }
18
- | exp '-' exp { val[0] - val[2] }
19
- | exp '*' exp { val[0] * val[2] }
20
- | exp '/' exp { val[0] / val[2] }
21
- | '(' exp ')' { val[1] }
22
- | '-' NUMBER =UMINUS { -(val[1]) }
23
- | NUMBER
24
- end
25
-
26
- ---- header
27
- # $Id$
28
- ---- inner
29
-
30
- def evaluate(str)
31
- @tokens = []
32
- until str.empty?
33
- case str
34
- when /\A\s+/
35
- ;
36
- when /\A\d+/
37
- @tokens.push [:NUMBER, $&.to_i]
38
- when /\A.|\n/
39
- s = $&
40
- @tokens.push [s, s]
41
- end
42
- str = $'
43
- end
44
- @tokens.push [false, '$']
45
- do_parse
46
- end
47
-
48
- def next_token
49
- @tokens.shift
50
- end
51
-
52
- ---- footer
53
-
54
- puts 'Ķ������� 2 �浡'
55
- puts 'Q �ǽ�λ���ޤ�'
56
- calc = Calculator2.new
57
- while true
58
- print '>>> '; $stdout.flush
59
- str = $stdin.gets.strip
60
- break if /q/i =~ str
61
- begin
62
- p calc.evaluate(str)
63
- rescue ParseError
64
- puts 'parse error'
65
- end
66
- end
data/sample/calc.y DELETED
@@ -1,65 +0,0 @@
1
- # $Id$
2
- #
3
- # Very simple calculater.
4
-
5
- class Calcp
6
- prechigh
7
- nonassoc UMINUS
8
- left '*' '/'
9
- left '+' '-'
10
- preclow
11
- rule
12
- target: exp
13
- | /* none */ { result = 0 }
14
-
15
- exp: exp '+' exp { result += val[2] }
16
- | exp '-' exp { result -= val[2] }
17
- | exp '*' exp { result *= val[2] }
18
- | exp '/' exp { result /= val[2] }
19
- | '(' exp ')' { result = val[1] }
20
- | '-' NUMBER =UMINUS { result = -val[1] }
21
- | NUMBER
22
- end
23
-
24
- ---- header
25
- # $Id$
26
- ---- inner
27
-
28
- def parse(str)
29
- @q = []
30
- until str.empty?
31
- case str
32
- when /\A\s+/
33
- when /\A\d+/
34
- @q.push [:NUMBER, $&.to_i]
35
- when /\A.|\n/o
36
- s = $&
37
- @q.push [s, s]
38
- end
39
- str = $'
40
- end
41
- @q.push [false, '$end']
42
- do_parse
43
- end
44
-
45
- def next_token
46
- @q.shift
47
- end
48
-
49
- ---- footer
50
-
51
- parser = Calcp.new
52
- puts
53
- puts 'type "Q" to quit.'
54
- puts
55
- while true
56
- puts
57
- print '? '
58
- str = gets.chop!
59
- break if /q/i =~ str
60
- begin
61
- puts "= #{parser.parse(str)}"
62
- rescue ParseError
63
- puts $!
64
- end
65
- end
data/sample/conflict.y DELETED
@@ -1,15 +0,0 @@
1
- # $Id$
2
- #
3
- # Example of conflicted grammer.
4
- # This grammer contains 1 Shift/Reduce conflict and 1 Reduce/Reduce conflict.
5
-
6
- class A
7
- rule
8
- target : outer
9
-
10
- outer :
11
- | outer inner
12
-
13
- inner :
14
- | inner ITEM
15
- end
data/sample/hash.y DELETED
@@ -1,60 +0,0 @@
1
- # $Id$
2
- #
3
- # Converting Hash-like string into Ruby's Hash.
4
-
5
- class HashParser
6
- options no_result_var
7
- rule
8
- hash : '{' contents '}' { val[1] }
9
- | '{' '}' { Hash.new }
10
-
11
- # Racc can handle string over 2 bytes.
12
- contents: IDENT '=>' IDENT { {val[0] => val[2]} }
13
- | contents ',' IDENT '=>' IDENT { val[0][val[2]] = val[4]; val[0] }
14
- end
15
-
16
- ---- inner
17
-
18
- def parse(str)
19
- @str = str
20
- yyparse self, :scan
21
- end
22
-
23
- private
24
-
25
- def scan
26
- str = @str
27
- until str.empty?
28
- case str
29
- when /\A\s+/
30
- str = $'
31
- when /\A\w+/
32
- yield :IDENT, $&
33
- str = $'
34
- when /\A=>/
35
- yield '=>', '=>'
36
- str = $'
37
- else
38
- c = str[0,1]
39
- yield c, c
40
- str = str[1..-1]
41
- end
42
- end
43
- yield false, '$' # is optional from Racc 1.3.7
44
- end
45
-
46
- ---- footer
47
-
48
- if $0 == __FILE__
49
- src = <<EOS
50
- {
51
- name => MyName,
52
- id => MyIdent
53
- }
54
- EOS
55
- puts 'Parsing (String):'
56
- print src
57
- puts
58
- puts 'Result (Ruby Object):'
59
- p HashParser.new.parse(src)
60
- end
data/sample/lalr.y DELETED
@@ -1,17 +0,0 @@
1
- # $Id$
2
- #
3
- # This is LALR grammer, and not LL/SLR.
4
-
5
- class A
6
- rule
7
- A : L '=' E
8
-
9
- L : i
10
- | R '^' i
11
-
12
- E : E '+' R
13
- | R
14
- | '@' L
15
-
16
- R : i
17
- end
data/sample/lists.y DELETED
@@ -1,57 +0,0 @@
1
- # $Id$
2
- #
3
- # Rules for verious lists.
4
- # This file is just an example, you cannot compile this file.
5
-
6
- class ExampleOnly
7
- rule
8
-
9
- # a list, which minimum number of items is 0
10
- list0 :
11
- {
12
- result = []
13
- }
14
- | list0 item
15
- {
16
- result.push val[1]
17
- }
18
-
19
- # a list, which minimum number of items is 1
20
- list1 : item
21
- {
22
- result = val
23
- }
24
- | list1 item
25
- {
26
- result.push val[1]
27
- }
28
-
29
- # a list, separated by comma
30
- clist : item
31
- {
32
- result = val
33
- }
34
- | clist ',' item
35
- {
36
- result.push val[2]
37
- }
38
-
39
- # a hash. see also "hash.y".
40
- hash : '{' hash_contents '}'
41
- {
42
- result = val[1]
43
- }
44
- | '{' '}'
45
- {
46
- result = {}
47
- }
48
-
49
- hash_contents
50
- : item "=>" item
51
- {
52
- result = { val[0] => val[2] }
53
- }
54
- | hash_contents ',' item "=>" item
55
- {
56
- result[val[2]] = val[4]
57
- }
data/sample/syntax.y DELETED
@@ -1,46 +0,0 @@
1
- # $Id$
2
- #
3
- # Racc syntax checker. This grammer file generates
4
- # invalid ruby program, you cannot run this parser.
5
-
6
- class P
7
- token A B C
8
-
9
- convert
10
- A '5'
11
- end
12
-
13
- prechigh
14
- left B
15
- preclow
16
-
17
- options omit_action_call
18
-
19
- start target
20
- rule
21
- target: A B C
22
- {
23
- print 'abc'
24
- }
25
- | B C A
26
- | C B A
27
- {
28
- print 'cba'
29
- }
30
- | cont
31
-
32
- cont : A c2 B c2 C
33
-
34
- c2 : C C C C C
35
- end
36
-
37
- ---- inner
38
-
39
- junk code !!!!
40
-
41
- kjaljlajrlaolanbla /// %%% (*((( token rule
42
- akiurtlajluealjflaj @@@@ end end end end __END__
43
- laieu2o879urkq96ga(Q#*&%Q#
44
- #&lkji END
45
-
46
- q395q?/// liutjqlkr7