racc 1.5.2 → 1.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.ja.rdoc +0 -1
- data/README.rdoc +9 -14
- data/{rdoc → doc}/en/NEWS.en.rdoc +0 -0
- data/{rdoc → doc}/en/grammar.en.rdoc +27 -31
- data/doc/en/grammar2.en.rdoc +219 -0
- data/{rdoc → doc}/ja/NEWS.ja.rdoc +0 -0
- data/{rdoc → doc}/ja/command.ja.html +0 -0
- data/{rdoc → doc}/ja/debug.ja.rdoc +0 -0
- data/{rdoc → doc}/ja/grammar.ja.rdoc +0 -0
- data/{rdoc → doc}/ja/index.ja.html +0 -0
- data/{rdoc → doc}/ja/parser.ja.rdoc +0 -0
- data/{rdoc → doc}/ja/usage.ja.html +0 -0
- data/ext/racc/cparse/cparse.c +1 -1
- data/ext/racc/cparse/extconf.rb +1 -0
- data/lib/racc/grammar.rb +3 -3
- data/lib/racc/grammarfileparser.rb +2 -2
- data/lib/racc/info.rb +1 -1
- data/lib/racc/parser-text.rb +2 -2
- data/lib/racc/parser.rb +2 -2
- data/lib/racc/parserfilegenerator.rb +0 -44
- data/lib/racc/statetransitiontable.rb +3 -9
- metadata +15 -121
- data/Rakefile +0 -79
- data/ext/racc/com/headius/racc/Cparse.java +0 -849
- data/lib/racc/pre-setup +0 -13
- data/sample/array.y +0 -67
- data/sample/array2.y +0 -59
- data/sample/calc-ja.y +0 -66
- data/sample/calc.y +0 -65
- data/sample/conflict.y +0 -15
- data/sample/hash.y +0 -60
- data/sample/lalr.y +0 -17
- data/sample/lists.y +0 -57
- data/sample/syntax.y +0 -46
- data/sample/yyerr.y +0 -46
- data/test/assets/cadenza.y +0 -170
- data/test/assets/cast.y +0 -926
- data/test/assets/chk.y +0 -126
- data/test/assets/conf.y +0 -16
- data/test/assets/csspool.y +0 -729
- data/test/assets/digraph.y +0 -29
- data/test/assets/echk.y +0 -118
- data/test/assets/edtf.y +0 -583
- data/test/assets/err.y +0 -60
- data/test/assets/error_recovery.y +0 -35
- data/test/assets/expect.y +0 -7
- data/test/assets/firstline.y +0 -4
- data/test/assets/huia.y +0 -318
- data/test/assets/ichk.y +0 -102
- data/test/assets/intp.y +0 -546
- data/test/assets/journey.y +0 -47
- data/test/assets/liquor.y +0 -313
- data/test/assets/machete.y +0 -423
- data/test/assets/macruby.y +0 -2197
- data/test/assets/mailp.y +0 -437
- data/test/assets/mediacloth.y +0 -599
- data/test/assets/mof.y +0 -649
- data/test/assets/namae.y +0 -302
- data/test/assets/nasl.y +0 -626
- data/test/assets/newsyn.y +0 -25
- data/test/assets/noend.y +0 -4
- data/test/assets/nokogiri-css.y +0 -255
- data/test/assets/nonass.y +0 -41
- data/test/assets/normal.y +0 -27
- data/test/assets/norule.y +0 -4
- data/test/assets/nullbug1.y +0 -25
- data/test/assets/nullbug2.y +0 -15
- data/test/assets/opal.y +0 -1807
- data/test/assets/opt.y +0 -123
- data/test/assets/percent.y +0 -35
- data/test/assets/php_serialization.y +0 -98
- data/test/assets/recv.y +0 -97
- data/test/assets/riml.y +0 -665
- data/test/assets/rrconf.y +0 -14
- data/test/assets/ruby18.y +0 -1943
- data/test/assets/ruby19.y +0 -2174
- data/test/assets/ruby20.y +0 -2350
- data/test/assets/ruby21.y +0 -2359
- data/test/assets/ruby22.y +0 -2381
- data/test/assets/scan.y +0 -72
- data/test/assets/syntax.y +0 -50
- data/test/assets/tp_plus.y +0 -622
- data/test/assets/twowaysql.y +0 -278
- data/test/assets/unterm.y +0 -5
- data/test/assets/useless.y +0 -12
- data/test/assets/yyerr.y +0 -46
- data/test/bench.y +0 -36
- data/test/helper.rb +0 -115
- data/test/infini.y +0 -8
- data/test/regress/cadenza +0 -796
- data/test/regress/cast +0 -3428
- data/test/regress/csspool +0 -2314
- data/test/regress/edtf +0 -1794
- data/test/regress/huia +0 -1392
- data/test/regress/journey +0 -222
- data/test/regress/liquor +0 -885
- data/test/regress/machete +0 -833
- data/test/regress/mediacloth +0 -1463
- data/test/regress/mof +0 -1368
- data/test/regress/namae +0 -634
- data/test/regress/nasl +0 -2058
- data/test/regress/nokogiri-css +0 -836
- data/test/regress/opal +0 -6431
- data/test/regress/php_serialization +0 -336
- data/test/regress/riml +0 -3283
- data/test/regress/ruby18 +0 -6344
- data/test/regress/ruby22 +0 -7460
- data/test/regress/tp_plus +0 -1933
- data/test/regress/twowaysql +0 -556
- data/test/scandata/brace +0 -7
- data/test/scandata/gvar +0 -1
- data/test/scandata/normal +0 -4
- data/test/scandata/percent +0 -18
- data/test/scandata/slash +0 -10
- data/test/src.intp +0 -34
- data/test/start.y +0 -20
- data/test/test_chk_y.rb +0 -52
- data/test/test_grammar_file_parser.rb +0 -15
- data/test/test_racc_command.rb +0 -339
- data/test/test_scan_y.rb +0 -52
- data/test/testscanner.rb +0 -51
- data/web/racc.en.rhtml +0 -42
- data/web/racc.ja.rhtml +0 -51
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3140410adc1a0eea76ac4c19b3b03b9de9a4dd4c271971fef8675c3bec43260
|
4
|
+
data.tar.gz: 3bbbb46621a165b7f68dfbdb3cfebb508078db7984eb443b0acaebf5b98642b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62602fcf78f448a79c997e09084a7577257eb895b8ecae5880086b54fb05105b4140618f72c237e31d89d09347b420105a9e964068308404a30e01385a12ba15
|
7
|
+
data.tar.gz: 6f206c5cc183b836b50cfd84e71fe0b1b28dc2666e6d41c11055280a68a5497f3567f21931666e2c59495682bd310ec52e1704c4cb3fe5a434fa5e09da985d85
|
data/README.ja.rdoc
CHANGED
data/README.rdoc
CHANGED
@@ -1,21 +1,15 @@
|
|
1
1
|
= Racc
|
2
2
|
|
3
|
-
*
|
4
|
-
* http://racc.rubyforge.org/
|
3
|
+
* https://github.com/ruby/racc
|
5
4
|
|
6
5
|
== DESCRIPTION:
|
7
6
|
|
8
7
|
Racc is a LALR(1) parser generator.
|
9
8
|
It is written in Ruby itself, and generates Ruby program.
|
10
9
|
|
11
|
-
NOTE: Ruby 1.8.x comes with Racc runtime module. You
|
12
|
-
can run your parsers generated by racc 1.4.x out of the
|
13
|
-
box.
|
14
|
-
|
15
|
-
|
16
10
|
== Requirement
|
17
11
|
|
18
|
-
* Ruby
|
12
|
+
* Ruby 2.5 or later.
|
19
13
|
|
20
14
|
== Installation
|
21
15
|
|
@@ -59,9 +53,9 @@
|
|
59
53
|
|
60
54
|
$ ruby calc
|
61
55
|
|
62
|
-
... Does it
|
63
|
-
For details of Racc, see HTML documents placed under 'doc
|
64
|
-
and sample
|
56
|
+
... Does it work?
|
57
|
+
For details of Racc, see HTML documents placed under 'doc/en/'
|
58
|
+
and sample grammar files under 'sample/'.
|
65
59
|
|
66
60
|
|
67
61
|
== License
|
@@ -74,9 +68,10 @@
|
|
74
68
|
|
75
69
|
== Bug Reports
|
76
70
|
|
77
|
-
Any kind of bug
|
78
|
-
If you find a bug of Racc, please
|
79
|
-
|
71
|
+
Any kind of bug report is welcome.
|
72
|
+
If you find a bug of Racc, please report an issue at
|
73
|
+
https://github.com/ruby/racc/issues. Your grammar file,
|
74
|
+
debug output generated by "racc -g", are helpful.
|
80
75
|
|
81
76
|
|
82
77
|
Minero Aoki
|
File without changes
|
@@ -4,25 +4,24 @@
|
|
4
4
|
|
5
5
|
== Class Block and User Code Block
|
6
6
|
|
7
|
-
There
|
8
|
-
|
9
|
-
places after 'class' block.
|
7
|
+
There are two top-level blocks: the 'class' block, and the 'user code'
|
8
|
+
block. The 'user code' block MUST be after the 'class' block.
|
10
9
|
|
11
10
|
== Comment
|
12
11
|
|
13
|
-
|
14
|
-
Ruby style (
|
12
|
+
Comments can be added about everywhere. Two comment styles are
|
13
|
+
supported: Ruby style (`# ...`) and C style (`/* ... */`).
|
15
14
|
|
16
15
|
== Class Block
|
17
16
|
|
18
17
|
The class block is formed like this:
|
19
18
|
--
|
20
19
|
class CLASS_NAME
|
21
|
-
[
|
22
|
-
[token
|
20
|
+
[precedence table]
|
21
|
+
[token declarations]
|
23
22
|
[expected number of S/R conflict]
|
24
23
|
[options]
|
25
|
-
[semantic value
|
24
|
+
[semantic value conversion]
|
26
25
|
[start rule]
|
27
26
|
rule
|
28
27
|
GRAMMARS
|
@@ -43,7 +42,7 @@ end
|
|
43
42
|
|
44
43
|
== Grammar Block
|
45
44
|
|
46
|
-
The grammar block
|
45
|
+
The grammar block describes the grammar
|
47
46
|
to be understood by parser. Syntax is:
|
48
47
|
--
|
49
48
|
(token): (token) (token) (token).... (action)
|
@@ -69,7 +68,7 @@ It is value of result, or returned value by "return" statement.
|
|
69
68
|
Here is an example of whole grammar block.
|
70
69
|
--
|
71
70
|
rule
|
72
|
-
goal: definition
|
71
|
+
goal: definition rules source { result = val }
|
73
72
|
|
74
73
|
definition: /* none */ { result = [] }
|
75
74
|
| definition startdesig { result[0] = val[1] }
|
@@ -96,7 +95,7 @@ An array of value of right-hand side (rhs).
|
|
96
95
|
A stack of values.
|
97
96
|
DO NOT MODIFY this stack unless you know what you are doing.
|
98
97
|
|
99
|
-
== Operator
|
98
|
+
== Operator Precedence
|
100
99
|
|
101
100
|
This function is equal to '%prec' in yacc.
|
102
101
|
To designate this block:
|
@@ -128,25 +127,24 @@ rule
|
|
128
127
|
|
129
128
|
== expect
|
130
129
|
|
131
|
-
Racc
|
130
|
+
Racc supports Bison's "expect" directive to declare the expected
|
131
|
+
number of shift/reduce conflicts.
|
132
132
|
--
|
133
|
-
# Example
|
134
|
-
|
135
133
|
class MyParser
|
136
134
|
rule
|
137
135
|
expect 3
|
138
136
|
:
|
139
137
|
:
|
140
138
|
--
|
141
|
-
|
142
|
-
|
143
|
-
racc does not print confliction warning message.
|
139
|
+
Then warnings are issued only when the effective number of conflicts differs.
|
140
|
+
|
144
141
|
|
145
142
|
== Declaring Tokens
|
146
143
|
|
147
|
-
|
148
|
-
|
149
|
-
Racc
|
144
|
+
Declaring tokens avoids many bugs.
|
145
|
+
|
146
|
+
Racc outputs warnings for declared tokens that do not exist, or existing tokens not declared.
|
147
|
+
The syntax is:
|
150
148
|
--
|
151
149
|
token TOKEN_NAME AND_IS_THIS
|
152
150
|
ALSO_THIS_IS AGAIN_AND_AGAIN THIS_IS_LAST
|
@@ -174,12 +172,12 @@ You can use 'no_' prefix to invert its meanings.
|
|
174
172
|
|
175
173
|
Token symbols are, as default,
|
176
174
|
|
177
|
-
* naked token
|
175
|
+
* naked token strings in racc file (TOK, XFILE, this_is_token, ...)
|
178
176
|
--> symbol (:TOK, :XFILE, :this_is_token, ...)
|
179
|
-
* quoted
|
177
|
+
* quoted strings (':', '.', '(', ...)
|
180
178
|
--> same string (':', '.', '(', ...)
|
181
179
|
|
182
|
-
You can change this default
|
180
|
+
You can change this default using a "convert" block.
|
183
181
|
Here is an example:
|
184
182
|
--
|
185
183
|
convert
|
@@ -202,18 +200,19 @@ end
|
|
202
200
|
|
203
201
|
== Start Rule
|
204
202
|
|
205
|
-
'%start' in yacc. This changes start
|
203
|
+
'%start' in yacc. This changes the start symbol.
|
206
204
|
--
|
207
205
|
start real_target
|
208
206
|
--
|
209
|
-
|
207
|
+
|
210
208
|
|
211
209
|
== User Code Block
|
212
210
|
|
213
|
-
"User Code Block" is a Ruby source code
|
214
|
-
There are three user code
|
211
|
+
A "User Code Block" is a piece of Ruby source code copied in the output.
|
212
|
+
There are three user code blocks, "header" "inner" and "footer".
|
215
213
|
|
216
|
-
|
214
|
+
User code blocks are introduced by four '-' at the beginning of a line,
|
215
|
+
followed by a single-word name:
|
217
216
|
--
|
218
217
|
---- header
|
219
218
|
ruby statement
|
@@ -225,6 +224,3 @@ Format of user code is like this:
|
|
225
224
|
:
|
226
225
|
:
|
227
226
|
--
|
228
|
-
If four '-' exist on line head,
|
229
|
-
racc treat it as beginning of user code block.
|
230
|
-
A name of user code must be one word.
|
@@ -0,0 +1,219 @@
|
|
1
|
+
= Racc Grammar File Reference
|
2
|
+
|
3
|
+
== Global Structure
|
4
|
+
|
5
|
+
== Class Block and User Code Block
|
6
|
+
|
7
|
+
There are two blocks on the toplevel. One is the 'class' block, the other is the 'user code'
|
8
|
+
block. The 'user code' block MUST be placed after the 'class' block.
|
9
|
+
|
10
|
+
== Comments
|
11
|
+
|
12
|
+
You can insert comments about all places. Two styles of comments can be used, Ruby style '#.....' and C style '/\*......*\/'.
|
13
|
+
|
14
|
+
== Class Block
|
15
|
+
|
16
|
+
The class block is formed like this:
|
17
|
+
|
18
|
+
class CLASS_NAME
|
19
|
+
[precedence table]
|
20
|
+
[token declarations]
|
21
|
+
[expected number of S/R conflicts]
|
22
|
+
[options]
|
23
|
+
[semantic value conversion]
|
24
|
+
[start rule]
|
25
|
+
rule
|
26
|
+
GRAMMARS
|
27
|
+
|
28
|
+
CLASS_NAME is a name of the parser class. This is the name of the generating parser
|
29
|
+
class.
|
30
|
+
|
31
|
+
If CLASS_NAME includes '::', Racc outputs the module clause. For example, writing
|
32
|
+
"class M::C" causes the code below to be created:
|
33
|
+
|
34
|
+
module M
|
35
|
+
class C
|
36
|
+
:
|
37
|
+
:
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
== Grammar Block
|
42
|
+
|
43
|
+
The grammar block describes grammar which is able to be understood by the parser.
|
44
|
+
Syntax is:
|
45
|
+
|
46
|
+
(token): (token) (token) (token).... (action)
|
47
|
+
|
48
|
+
(token): (token) (token) (token).... (action)
|
49
|
+
| (token) (token) (token).... (action)
|
50
|
+
| (token) (token) (token).... (action)
|
51
|
+
|
52
|
+
(action) is an action which is executed when its (token)s are found.
|
53
|
+
(action) is a ruby code block, which is surrounded by braces:
|
54
|
+
|
55
|
+
{ print val[0]
|
56
|
+
puts val[1] }
|
57
|
+
|
58
|
+
Note that you cannot use '%' string, here document, '%r' regexp in action.
|
59
|
+
|
60
|
+
Actions can be omitted. When it is omitted, '' (empty string) is used.
|
61
|
+
|
62
|
+
A return value of action is a value of the left side value ($$). It is the value of the
|
63
|
+
result, or the returned value by `return` statement.
|
64
|
+
|
65
|
+
Here is an example of the whole grammar block.
|
66
|
+
|
67
|
+
rule
|
68
|
+
goal: definition rules source { result = val }
|
69
|
+
|
70
|
+
definition: /* none */ { result = [] }
|
71
|
+
| definition startdesig { result[0] = val[1] }
|
72
|
+
| definition
|
73
|
+
precrule # this line continues from upper line
|
74
|
+
{
|
75
|
+
result[1] = val[1]
|
76
|
+
}
|
77
|
+
|
78
|
+
startdesig: START TOKEN
|
79
|
+
|
80
|
+
You can use the following special local variables in action:
|
81
|
+
|
82
|
+
* result ($$)
|
83
|
+
|
84
|
+
The value of the left-hand side (lhs). A default value is val[0].
|
85
|
+
|
86
|
+
* val ($1,$2,$3...)
|
87
|
+
|
88
|
+
An array of value of the right-hand side (rhs).
|
89
|
+
|
90
|
+
* _values (...$-2,$-1,$0)
|
91
|
+
|
92
|
+
A stack of values. DO NOT MODIFY this stack unless you know what you are doing.
|
93
|
+
|
94
|
+
== Operator Precedence
|
95
|
+
|
96
|
+
This function is equal to '%prec' in yacc.
|
97
|
+
To designate this block:
|
98
|
+
|
99
|
+
prechigh
|
100
|
+
nonassoc '++'
|
101
|
+
left '*' '/'
|
102
|
+
left '+' '-'
|
103
|
+
right '='
|
104
|
+
preclow
|
105
|
+
|
106
|
+
`right` is yacc's %right, `left` is yacc's %left.
|
107
|
+
|
108
|
+
`=` + (symbol) means yacc's %prec:
|
109
|
+
|
110
|
+
prechigh
|
111
|
+
nonassoc UMINUS
|
112
|
+
left '*' '/'
|
113
|
+
left '+' '-'
|
114
|
+
preclow
|
115
|
+
|
116
|
+
rule
|
117
|
+
exp: exp '*' exp
|
118
|
+
| exp '-' exp
|
119
|
+
| '-' exp =UMINUS # equals to "%prec UMINUS"
|
120
|
+
:
|
121
|
+
:
|
122
|
+
|
123
|
+
== expect
|
124
|
+
|
125
|
+
Racc has bison's "expect" directive.
|
126
|
+
|
127
|
+
# Example
|
128
|
+
|
129
|
+
class MyParser
|
130
|
+
rule
|
131
|
+
expect 3
|
132
|
+
:
|
133
|
+
:
|
134
|
+
|
135
|
+
This directive declares "expected" number of shift/reduce conflicts. If
|
136
|
+
"expected" number is equal to real number of conflicts, Racc does not print
|
137
|
+
conflict warning message.
|
138
|
+
|
139
|
+
== Declaring Tokens
|
140
|
+
|
141
|
+
By declaring tokens, you can avoid many meaningless bugs. If declared token
|
142
|
+
does not exist or existing token does not decleared, Racc output warnings.
|
143
|
+
Declaration syntax is:
|
144
|
+
|
145
|
+
token TOKEN_NAME AND_IS_THIS
|
146
|
+
ALSO_THIS_IS AGAIN_AND_AGAIN THIS_IS_LAST
|
147
|
+
|
148
|
+
== Options
|
149
|
+
|
150
|
+
You can write options for Racc command in your Racc file.
|
151
|
+
|
152
|
+
options OPTION OPTION ...
|
153
|
+
|
154
|
+
Options are:
|
155
|
+
|
156
|
+
* omit_action_call
|
157
|
+
|
158
|
+
omits empty action call or not.
|
159
|
+
|
160
|
+
* result_var
|
161
|
+
|
162
|
+
uses local variable "result" or not.
|
163
|
+
|
164
|
+
You can use 'no_' prefix to invert their meanings.
|
165
|
+
|
166
|
+
== Converting Token Symbol
|
167
|
+
|
168
|
+
Token symbols are, as default,
|
169
|
+
|
170
|
+
* naked token string in Racc file (TOK, XFILE, this_is_token, ...)
|
171
|
+
--> symbol (:TOK, :XFILE, :this_is_token, ...)
|
172
|
+
* quoted string (':', '.', '(', ...)
|
173
|
+
--> same string (':', '.', '(', ...)
|
174
|
+
|
175
|
+
You can change this default by "convert" block.
|
176
|
+
Here is an example:
|
177
|
+
|
178
|
+
convert
|
179
|
+
PLUS 'PlusClass' # We use PlusClass for symbol of `PLUS'
|
180
|
+
MIN 'MinusClass' # We use MinusClass for symbol of `MIN'
|
181
|
+
end
|
182
|
+
|
183
|
+
We can use almost all ruby value can be used by token symbol,
|
184
|
+
except 'false' and 'nil'. These cause unexpected parse error.
|
185
|
+
|
186
|
+
If you want to use String as token symbol, special care is required.
|
187
|
+
For example:
|
188
|
+
|
189
|
+
convert
|
190
|
+
class '"cls"' # in code, "cls"
|
191
|
+
PLUS '"plus\n"' # in code, "plus\n"
|
192
|
+
MIN "\"minus#{val}\"" # in code, \"minus#{val}\"
|
193
|
+
end
|
194
|
+
|
195
|
+
== Start Rule
|
196
|
+
|
197
|
+
'%start' in yacc. This changes start rule.
|
198
|
+
|
199
|
+
start real_target
|
200
|
+
|
201
|
+
== User Code Block
|
202
|
+
|
203
|
+
"User Code Block" is a Ruby source code which is copied to output. There are
|
204
|
+
three user code blocks, "header" "inner" and "footer".
|
205
|
+
|
206
|
+
Format of user code is like this:
|
207
|
+
|
208
|
+
---- header
|
209
|
+
ruby statement
|
210
|
+
ruby statement
|
211
|
+
ruby statement
|
212
|
+
|
213
|
+
---- inner
|
214
|
+
ruby statement
|
215
|
+
:
|
216
|
+
:
|
217
|
+
|
218
|
+
If four '-' exist on the line head, Racc treats it as the beginning of the
|
219
|
+
user code block. The name of the user code block must be one word.
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/ext/racc/cparse/cparse.c
CHANGED
data/ext/racc/cparse/extconf.rb
CHANGED
data/lib/racc/grammar.rb
CHANGED
@@ -335,14 +335,14 @@ module Racc
|
|
335
335
|
if action
|
336
336
|
idbase = "#{type}@#{id}-#{@seqs[type] += 1}"
|
337
337
|
target = _wrap(idbase, "#{idbase}-core", action)
|
338
|
-
|
338
|
+
_register("#{idbase}-core", &block)
|
339
339
|
else
|
340
|
-
target =
|
340
|
+
target = _register("#{type}@#{id}", &block)
|
341
341
|
end
|
342
342
|
@grammar.intern(target)
|
343
343
|
end
|
344
344
|
|
345
|
-
def
|
345
|
+
def _register(target_name)
|
346
346
|
target = target_name.intern
|
347
347
|
unless _added?(@grammar.intern(target))
|
348
348
|
yield(target).each_rule do |rule|
|
@@ -260,9 +260,9 @@ module Racc
|
|
260
260
|
_, *blocks = *@scanner.epilogue.split(/^----/)
|
261
261
|
blocks.each do |block|
|
262
262
|
header, *body = block.lines.to_a
|
263
|
-
label0,
|
263
|
+
label0, paths = *header.sub(/\A-+/, '').split('=', 2)
|
264
264
|
label = canonical_label(label0)
|
265
|
-
(
|
265
|
+
(paths ? paths.strip.split(' ') : []).each do |path|
|
266
266
|
add_user_code label, SourceText.new(File.read(path), path, 1)
|
267
267
|
end
|
268
268
|
add_user_code label, SourceText.new(body.join(''), @filename, line + 1)
|
data/lib/racc/info.rb
CHANGED
data/lib/racc/parser-text.rb
CHANGED
@@ -22,7 +22,7 @@ module Racc
|
|
22
22
|
class ParseError < StandardError; end
|
23
23
|
end
|
24
24
|
unless defined?(::ParseError)
|
25
|
-
ParseError = Racc::ParseError
|
25
|
+
ParseError = Racc::ParseError # :nodoc:
|
26
26
|
end
|
27
27
|
|
28
28
|
# Racc is a LALR(1) parser generator.
|
@@ -548,7 +548,7 @@ module Racc
|
|
548
548
|
end
|
549
549
|
|
550
550
|
# Exit parser.
|
551
|
-
# Return value is Symbol_Value_Stack[0]
|
551
|
+
# Return value is +Symbol_Value_Stack[0]+.
|
552
552
|
def yyaccept
|
553
553
|
throw :racc_jump, 2
|
554
554
|
end
|
data/lib/racc/parser.rb
CHANGED
@@ -20,7 +20,7 @@ module Racc
|
|
20
20
|
class ParseError < StandardError; end
|
21
21
|
end
|
22
22
|
unless defined?(::ParseError)
|
23
|
-
ParseError = Racc::ParseError
|
23
|
+
ParseError = Racc::ParseError # :nodoc:
|
24
24
|
end
|
25
25
|
|
26
26
|
# Racc is a LALR(1) parser generator.
|
@@ -546,7 +546,7 @@ module Racc
|
|
546
546
|
end
|
547
547
|
|
548
548
|
# Exit parser.
|
549
|
-
# Return value is Symbol_Value_Stack[0]
|
549
|
+
# Return value is +Symbol_Value_Stack[0]+.
|
550
550
|
def yyaccept
|
551
551
|
throw :racc_jump, 2
|
552
552
|
end
|
@@ -320,50 +320,6 @@ module Racc
|
|
320
320
|
end
|
321
321
|
|
322
322
|
def integer_list(name, table)
|
323
|
-
if table.size > 2000
|
324
|
-
serialize_integer_list_compressed name, table
|
325
|
-
else
|
326
|
-
serialize_integer_list_std name, table
|
327
|
-
end
|
328
|
-
end
|
329
|
-
|
330
|
-
def serialize_integer_list_compressed(name, table)
|
331
|
-
# TODO: this can be made a LOT more clean with a simple split/map
|
332
|
-
sep = "\n"
|
333
|
-
nsep = ",\n"
|
334
|
-
buf = String.new
|
335
|
-
com = ''
|
336
|
-
ncom = ','
|
337
|
-
co = com
|
338
|
-
@f.print 'clist = ['
|
339
|
-
table.each do |i|
|
340
|
-
buf << co << i.to_s; co = ncom
|
341
|
-
if buf.size > 66
|
342
|
-
@f.print sep; sep = nsep
|
343
|
-
@f.print "'", buf, "'"
|
344
|
-
buf = String.new
|
345
|
-
co = com
|
346
|
-
end
|
347
|
-
end
|
348
|
-
unless buf.empty?
|
349
|
-
@f.print sep
|
350
|
-
@f.print "'", buf, "'"
|
351
|
-
end
|
352
|
-
line ' ]'
|
353
|
-
|
354
|
-
@f.print(<<-End)
|
355
|
-
#{name} = arr = ::Array.new(#{table.size}, nil)
|
356
|
-
idx = 0
|
357
|
-
clist.each do |str|
|
358
|
-
str.split(',', -1).each do |i|
|
359
|
-
arr[idx] = i.to_i unless i.empty?
|
360
|
-
idx += 1
|
361
|
-
end
|
362
|
-
end
|
363
|
-
End
|
364
|
-
end
|
365
|
-
|
366
|
-
def serialize_integer_list_std(name, table)
|
367
323
|
sep = ''
|
368
324
|
line "#{name} = ["
|
369
325
|
table.each_slice(10) do |ns|
|
@@ -12,12 +12,6 @@
|
|
12
12
|
|
13
13
|
require 'racc/parser'
|
14
14
|
|
15
|
-
unless Object.method_defined?(:funcall)
|
16
|
-
class Object
|
17
|
-
alias funcall __send__
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
15
|
module Racc
|
22
16
|
|
23
17
|
StateTransitionTable = Struct.new(:action_table,
|
@@ -222,7 +216,7 @@ module Racc
|
|
222
216
|
end
|
223
217
|
i = ii
|
224
218
|
end
|
225
|
-
Regexp.compile(map, 'n')
|
219
|
+
Regexp.compile(map, nil, 'n')
|
226
220
|
end
|
227
221
|
|
228
222
|
def set_table(entries, dummy, tbl, chk, ptr)
|
@@ -300,9 +294,9 @@ module Racc
|
|
300
294
|
c.module_eval "def _reduce_none(vals, vstack) vals[0] end"
|
301
295
|
@grammar.each do |rule|
|
302
296
|
if rule.action.empty?
|
303
|
-
c.
|
297
|
+
c.alias_method("_reduce_#{rule.ident}", :_reduce_none)
|
304
298
|
else
|
305
|
-
c.
|
299
|
+
c.define_method("_racc_action_#{rule.ident}", &rule.action.proc)
|
306
300
|
c.module_eval(<<-End, __FILE__, __LINE__ + 1)
|
307
301
|
def _reduce_#{rule.ident}(vals, vstack)
|
308
302
|
_racc_action_#{rule.ident}(*vals)
|