racc 1.5.2 → 1.6.0
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 +6 -7
- 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/info.rb +1 -1
- data/lib/racc/parser-text.rb +1 -1
- data/lib/racc/parser.rb +1 -1
- data/lib/racc/parserfilegenerator.rb +0 -44
- data/lib/racc/statetransitiontable.rb +2 -8
- 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
data/test/assets/nokogiri-css.y
DELETED
@@ -1,255 +0,0 @@
|
|
1
|
-
class Nokogiri::CSS::Parser
|
2
|
-
|
3
|
-
token FUNCTION INCLUDES DASHMATCH LBRACE HASH PLUS GREATER S STRING IDENT
|
4
|
-
token COMMA NUMBER PREFIXMATCH SUFFIXMATCH SUBSTRINGMATCH TILDE NOT_EQUAL
|
5
|
-
token SLASH DOUBLESLASH NOT EQUAL RPAREN LSQUARE RSQUARE HAS
|
6
|
-
|
7
|
-
rule
|
8
|
-
selector
|
9
|
-
: selector COMMA simple_selector_1toN {
|
10
|
-
result = [val.first, val.last].flatten
|
11
|
-
}
|
12
|
-
| prefixless_combinator_selector { result = val.flatten }
|
13
|
-
| optional_S simple_selector_1toN { result = [val.last].flatten }
|
14
|
-
;
|
15
|
-
combinator
|
16
|
-
: PLUS { result = :DIRECT_ADJACENT_SELECTOR }
|
17
|
-
| GREATER { result = :CHILD_SELECTOR }
|
18
|
-
| TILDE { result = :FOLLOWING_SELECTOR }
|
19
|
-
| DOUBLESLASH { result = :DESCENDANT_SELECTOR }
|
20
|
-
| SLASH { result = :CHILD_SELECTOR }
|
21
|
-
;
|
22
|
-
simple_selector
|
23
|
-
: element_name hcap_0toN {
|
24
|
-
result = if val[1].nil?
|
25
|
-
val.first
|
26
|
-
else
|
27
|
-
Node.new(:CONDITIONAL_SELECTOR, [val.first, val[1]])
|
28
|
-
end
|
29
|
-
}
|
30
|
-
| function
|
31
|
-
| function pseudo {
|
32
|
-
result = Node.new(:CONDITIONAL_SELECTOR, val)
|
33
|
-
}
|
34
|
-
| function attrib {
|
35
|
-
result = Node.new(:CONDITIONAL_SELECTOR, val)
|
36
|
-
}
|
37
|
-
| hcap_1toN {
|
38
|
-
result = Node.new(:CONDITIONAL_SELECTOR,
|
39
|
-
[Node.new(:ELEMENT_NAME, ['*']), val.first]
|
40
|
-
)
|
41
|
-
}
|
42
|
-
;
|
43
|
-
prefixless_combinator_selector
|
44
|
-
: combinator simple_selector_1toN {
|
45
|
-
result = Node.new(val.first, [nil, val.last])
|
46
|
-
}
|
47
|
-
;
|
48
|
-
simple_selector_1toN
|
49
|
-
: simple_selector combinator simple_selector_1toN {
|
50
|
-
result = Node.new(val[1], [val.first, val.last])
|
51
|
-
}
|
52
|
-
| simple_selector S simple_selector_1toN {
|
53
|
-
result = Node.new(:DESCENDANT_SELECTOR, [val.first, val.last])
|
54
|
-
}
|
55
|
-
| simple_selector
|
56
|
-
;
|
57
|
-
class
|
58
|
-
: '.' IDENT { result = Node.new(:CLASS_CONDITION, [val[1]]) }
|
59
|
-
;
|
60
|
-
element_name
|
61
|
-
: namespaced_ident
|
62
|
-
| '*' { result = Node.new(:ELEMENT_NAME, val) }
|
63
|
-
;
|
64
|
-
namespaced_ident
|
65
|
-
: namespace '|' IDENT {
|
66
|
-
result = Node.new(:ELEMENT_NAME,
|
67
|
-
[[val.first, val.last].compact.join(':')]
|
68
|
-
)
|
69
|
-
}
|
70
|
-
| IDENT {
|
71
|
-
name = @namespaces.key?('xmlns') ? "xmlns:#{val.first}" : val.first
|
72
|
-
result = Node.new(:ELEMENT_NAME, [name])
|
73
|
-
}
|
74
|
-
;
|
75
|
-
namespace
|
76
|
-
: IDENT { result = val[0] }
|
77
|
-
|
|
78
|
-
;
|
79
|
-
attrib
|
80
|
-
: LSQUARE attrib_name attrib_val_0or1 RSQUARE {
|
81
|
-
result = Node.new(:ATTRIBUTE_CONDITION,
|
82
|
-
[val[1]] + (val[2] || [])
|
83
|
-
)
|
84
|
-
}
|
85
|
-
| LSQUARE function attrib_val_0or1 RSQUARE {
|
86
|
-
result = Node.new(:ATTRIBUTE_CONDITION,
|
87
|
-
[val[1]] + (val[2] || [])
|
88
|
-
)
|
89
|
-
}
|
90
|
-
| LSQUARE NUMBER RSQUARE {
|
91
|
-
# Non standard, but hpricot supports it.
|
92
|
-
result = Node.new(:PSEUDO_CLASS,
|
93
|
-
[Node.new(:FUNCTION, ['nth-child(', val[1]])]
|
94
|
-
)
|
95
|
-
}
|
96
|
-
;
|
97
|
-
attrib_name
|
98
|
-
: namespace '|' IDENT {
|
99
|
-
result = Node.new(:ELEMENT_NAME,
|
100
|
-
[[val.first, val.last].compact.join(':')]
|
101
|
-
)
|
102
|
-
}
|
103
|
-
| IDENT {
|
104
|
-
# Default namespace is not applied to attributes.
|
105
|
-
# So we don't add prefix "xmlns:" as in namespaced_ident.
|
106
|
-
result = Node.new(:ELEMENT_NAME, [val.first])
|
107
|
-
}
|
108
|
-
;
|
109
|
-
function
|
110
|
-
: FUNCTION RPAREN {
|
111
|
-
result = Node.new(:FUNCTION, [val.first.strip])
|
112
|
-
}
|
113
|
-
| FUNCTION expr RPAREN {
|
114
|
-
result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
|
115
|
-
}
|
116
|
-
| FUNCTION nth RPAREN {
|
117
|
-
result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
|
118
|
-
}
|
119
|
-
| NOT expr RPAREN {
|
120
|
-
result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
|
121
|
-
}
|
122
|
-
| HAS selector RPAREN {
|
123
|
-
result = Node.new(:FUNCTION, [val.first.strip, val[1]].flatten)
|
124
|
-
}
|
125
|
-
;
|
126
|
-
expr
|
127
|
-
: NUMBER COMMA expr { result = [val.first, val.last] }
|
128
|
-
| STRING COMMA expr { result = [val.first, val.last] }
|
129
|
-
| IDENT COMMA expr { result = [val.first, val.last] }
|
130
|
-
| NUMBER
|
131
|
-
| STRING
|
132
|
-
| IDENT # even, odd
|
133
|
-
{
|
134
|
-
case val[0]
|
135
|
-
when 'even'
|
136
|
-
result = Node.new(:NTH, ['2','n','+','0'])
|
137
|
-
when 'odd'
|
138
|
-
result = Node.new(:NTH, ['2','n','+','1'])
|
139
|
-
when 'n'
|
140
|
-
result = Node.new(:NTH, ['1','n','+','0'])
|
141
|
-
else
|
142
|
-
# This is not CSS standard. It allows us to support this:
|
143
|
-
# assert_xpath("//a[foo(., @href)]", @parser.parse('a:foo(@href)'))
|
144
|
-
# assert_xpath("//a[foo(., @a, b)]", @parser.parse('a:foo(@a, b)'))
|
145
|
-
# assert_xpath("//a[foo(., a, 10)]", @parser.parse('a:foo(a, 10)'))
|
146
|
-
result = val
|
147
|
-
end
|
148
|
-
}
|
149
|
-
;
|
150
|
-
nth
|
151
|
-
: NUMBER IDENT PLUS NUMBER # 5n+3 -5n+3
|
152
|
-
{
|
153
|
-
if val[1] == 'n'
|
154
|
-
result = Node.new(:NTH, val)
|
155
|
-
else
|
156
|
-
raise Racc::ParseError, "parse error on IDENT '#{val[1]}'"
|
157
|
-
end
|
158
|
-
}
|
159
|
-
| IDENT PLUS NUMBER { # n+3, -n+3
|
160
|
-
if val[0] == 'n'
|
161
|
-
val.unshift("1")
|
162
|
-
result = Node.new(:NTH, val)
|
163
|
-
elsif val[0] == '-n'
|
164
|
-
val[0] = 'n'
|
165
|
-
val.unshift("-1")
|
166
|
-
result = Node.new(:NTH, val)
|
167
|
-
else
|
168
|
-
raise Racc::ParseError, "parse error on IDENT '#{val[1]}'"
|
169
|
-
end
|
170
|
-
}
|
171
|
-
| NUMBER IDENT { # 5n, -5n, 10n-1
|
172
|
-
n = val[1]
|
173
|
-
if n[0, 2] == 'n-'
|
174
|
-
val[1] = 'n'
|
175
|
-
val << "-"
|
176
|
-
# b is contained in n as n is the string "n-b"
|
177
|
-
val << n[2, n.size]
|
178
|
-
result = Node.new(:NTH, val)
|
179
|
-
elsif n == 'n'
|
180
|
-
val << "+"
|
181
|
-
val << "0"
|
182
|
-
result = Node.new(:NTH, val)
|
183
|
-
else
|
184
|
-
raise Racc::ParseError, "parse error on IDENT '#{val[1]}'"
|
185
|
-
end
|
186
|
-
}
|
187
|
-
;
|
188
|
-
pseudo
|
189
|
-
: ':' function {
|
190
|
-
result = Node.new(:PSEUDO_CLASS, [val[1]])
|
191
|
-
}
|
192
|
-
| ':' IDENT { result = Node.new(:PSEUDO_CLASS, [val[1]]) }
|
193
|
-
;
|
194
|
-
hcap_0toN
|
195
|
-
: hcap_1toN
|
196
|
-
|
|
197
|
-
;
|
198
|
-
hcap_1toN
|
199
|
-
: attribute_id hcap_1toN {
|
200
|
-
result = Node.new(:COMBINATOR, val)
|
201
|
-
}
|
202
|
-
| class hcap_1toN {
|
203
|
-
result = Node.new(:COMBINATOR, val)
|
204
|
-
}
|
205
|
-
| attrib hcap_1toN {
|
206
|
-
result = Node.new(:COMBINATOR, val)
|
207
|
-
}
|
208
|
-
| pseudo hcap_1toN {
|
209
|
-
result = Node.new(:COMBINATOR, val)
|
210
|
-
}
|
211
|
-
| negation hcap_1toN {
|
212
|
-
result = Node.new(:COMBINATOR, val)
|
213
|
-
}
|
214
|
-
| attribute_id
|
215
|
-
| class
|
216
|
-
| attrib
|
217
|
-
| pseudo
|
218
|
-
| negation
|
219
|
-
;
|
220
|
-
attribute_id
|
221
|
-
: HASH { result = Node.new(:ID, val) }
|
222
|
-
;
|
223
|
-
attrib_val_0or1
|
224
|
-
: eql_incl_dash IDENT { result = [val.first, val[1]] }
|
225
|
-
| eql_incl_dash STRING { result = [val.first, val[1]] }
|
226
|
-
|
|
227
|
-
;
|
228
|
-
eql_incl_dash
|
229
|
-
: EQUAL { result = :equal }
|
230
|
-
| PREFIXMATCH { result = :prefix_match }
|
231
|
-
| SUFFIXMATCH { result = :suffix_match }
|
232
|
-
| SUBSTRINGMATCH { result = :substring_match }
|
233
|
-
| NOT_EQUAL { result = :not_equal }
|
234
|
-
| INCLUDES { result = :includes }
|
235
|
-
| DASHMATCH { result = :dash_match }
|
236
|
-
;
|
237
|
-
negation
|
238
|
-
: NOT negation_arg RPAREN {
|
239
|
-
result = Node.new(:NOT, [val[1]])
|
240
|
-
}
|
241
|
-
;
|
242
|
-
negation_arg
|
243
|
-
: element_name
|
244
|
-
| element_name hcap_1toN
|
245
|
-
| hcap_1toN
|
246
|
-
;
|
247
|
-
optional_S
|
248
|
-
: S
|
249
|
-
|
|
250
|
-
;
|
251
|
-
end
|
252
|
-
|
253
|
-
---- header
|
254
|
-
|
255
|
-
require 'nokogiri/css/parser_extras'
|
data/test/assets/nonass.y
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# nonassoc test
|
3
|
-
#
|
4
|
-
|
5
|
-
class P
|
6
|
-
|
7
|
-
preclow
|
8
|
-
nonassoc N
|
9
|
-
left P
|
10
|
-
prechigh
|
11
|
-
|
12
|
-
rule
|
13
|
-
|
14
|
-
target : exp
|
15
|
-
exp : exp N exp
|
16
|
-
| exp P exp
|
17
|
-
| T
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
---- inner
|
22
|
-
|
23
|
-
def parse
|
24
|
-
@src = [[:T,'T'], [:N,'N'], [:T,'T'], [:N,'N'], [:T,'T']]
|
25
|
-
do_parse
|
26
|
-
end
|
27
|
-
|
28
|
-
def next_token
|
29
|
-
@src.shift
|
30
|
-
end
|
31
|
-
|
32
|
-
---- footer
|
33
|
-
|
34
|
-
begin
|
35
|
-
P.new.parse
|
36
|
-
rescue ParseError
|
37
|
-
exit 0
|
38
|
-
else
|
39
|
-
$stderr.puts 'parse error not raised: nonassoc not work'
|
40
|
-
exit 1
|
41
|
-
end
|
data/test/assets/normal.y
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
|
2
|
-
class Testp
|
3
|
-
|
4
|
-
convert
|
5
|
-
A '2'
|
6
|
-
B '3'
|
7
|
-
end
|
8
|
-
|
9
|
-
prechigh
|
10
|
-
left B
|
11
|
-
preclow
|
12
|
-
|
13
|
-
rule
|
14
|
-
|
15
|
-
/* comment */
|
16
|
-
target: A B C nonterminal { action "string" == /regexp/o
|
17
|
-
1 /= 3 }
|
18
|
-
; # comment
|
19
|
-
|
20
|
-
nonterminal: A '+' B = A;
|
21
|
-
|
22
|
-
/* end */
|
23
|
-
end
|
24
|
-
|
25
|
-
---- driver
|
26
|
-
|
27
|
-
# driver is old name
|
data/test/assets/norule.y
DELETED
data/test/assets/nullbug1.y
DELETED