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/mailp.y
DELETED
@@ -1,437 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# mailp for test
|
3
|
-
#
|
4
|
-
|
5
|
-
class Testp
|
6
|
-
|
7
|
-
rule
|
8
|
-
|
9
|
-
content : DateH datetime { @field.date = val[1] }
|
10
|
-
| RecvH received
|
11
|
-
| RetpathH returnpath
|
12
|
-
| MaddrH addrs { @field.addrs.replace val[1] }
|
13
|
-
| SaddrH addr { @field.addr = val[1] }
|
14
|
-
| MmboxH mboxes { @field.addrs.replace val[1] }
|
15
|
-
| SmboxH mbox { @field.addr = val[1] }
|
16
|
-
| MsgidH msgid { @field.msgid = val[1] }
|
17
|
-
| KeyH keys { @field.keys.replace val[1] }
|
18
|
-
| EncH enc
|
19
|
-
| VersionH version
|
20
|
-
| CTypeH ctype
|
21
|
-
| CEncodingH cencode
|
22
|
-
| CDispositionH cdisp
|
23
|
-
| Mbox mbox
|
24
|
-
{
|
25
|
-
mb = val[1]
|
26
|
-
@field.phrase = mb.phrase
|
27
|
-
@field.setroute mb.route
|
28
|
-
@field.local = mb.local
|
29
|
-
@field.domain = mb.domain
|
30
|
-
}
|
31
|
-
| Spec spec
|
32
|
-
{
|
33
|
-
mb = val[1]
|
34
|
-
@field.local = mb.local
|
35
|
-
@field.domain = mb.domain
|
36
|
-
}
|
37
|
-
;
|
38
|
-
|
39
|
-
datetime : day DIGIT ATOM DIGIT hour zone
|
40
|
-
# 0 1 2 3 4 5
|
41
|
-
# day month year
|
42
|
-
{
|
43
|
-
t = Time.gm( val[3].to_i, val[2], val[1].to_i, 0, 0, 0 )
|
44
|
-
result = (t + val[4] - val[5]).localtime
|
45
|
-
}
|
46
|
-
;
|
47
|
-
|
48
|
-
day : /* none */
|
49
|
-
| ATOM ','
|
50
|
-
;
|
51
|
-
|
52
|
-
hour : DIGIT ':' DIGIT
|
53
|
-
{
|
54
|
-
result = (result.to_i * 60 * 60) + (val[2].to_i * 60)
|
55
|
-
}
|
56
|
-
| DIGIT ':' DIGIT ':' DIGIT
|
57
|
-
{
|
58
|
-
result = (result.to_i * 60 * 60) +
|
59
|
-
(val[2].to_i * 60)
|
60
|
-
+ val[4].to_i
|
61
|
-
}
|
62
|
-
;
|
63
|
-
|
64
|
-
zone : ATOM
|
65
|
-
{
|
66
|
-
result = ::TMail.zonestr2i( val[0] ) * 60
|
67
|
-
}
|
68
|
-
;
|
69
|
-
|
70
|
-
received : from by via with id for recvdatetime
|
71
|
-
;
|
72
|
-
|
73
|
-
from : /* none */
|
74
|
-
| FROM domain
|
75
|
-
{
|
76
|
-
@field.from = Address.join( val[1] )
|
77
|
-
}
|
78
|
-
| FROM domain '@' domain
|
79
|
-
{
|
80
|
-
@field.from = Address.join( val[3] )
|
81
|
-
}
|
82
|
-
| FROM domain DOMLIT
|
83
|
-
{
|
84
|
-
@field.from = Address.join( val[1] )
|
85
|
-
}
|
86
|
-
;
|
87
|
-
|
88
|
-
by : /* none */
|
89
|
-
| BY domain
|
90
|
-
{
|
91
|
-
@field.by = Address.join( val[1] )
|
92
|
-
}
|
93
|
-
;
|
94
|
-
|
95
|
-
via : /* none */
|
96
|
-
| VIA ATOM
|
97
|
-
{
|
98
|
-
@field.via = val[1]
|
99
|
-
}
|
100
|
-
;
|
101
|
-
|
102
|
-
with : /* none */
|
103
|
-
| WITH ATOM
|
104
|
-
{
|
105
|
-
@field.with.push val[1]
|
106
|
-
}
|
107
|
-
;
|
108
|
-
|
109
|
-
id : /* none */
|
110
|
-
| ID msgid
|
111
|
-
{
|
112
|
-
@field.msgid = val[1]
|
113
|
-
}
|
114
|
-
| ID ATOM
|
115
|
-
{
|
116
|
-
@field.msgid = val[1]
|
117
|
-
}
|
118
|
-
;
|
119
|
-
|
120
|
-
for : /* none */
|
121
|
-
| FOR addr
|
122
|
-
{
|
123
|
-
@field.for_ = val[1].address
|
124
|
-
}
|
125
|
-
;
|
126
|
-
|
127
|
-
recvdatetime
|
128
|
-
: /* none */
|
129
|
-
| ';' datetime
|
130
|
-
{
|
131
|
-
@field.date = val[1]
|
132
|
-
}
|
133
|
-
;
|
134
|
-
|
135
|
-
returnpath: '<' '>'
|
136
|
-
| routeaddr
|
137
|
-
{
|
138
|
-
@field.route.replace result.route
|
139
|
-
@field.addr = result.addr
|
140
|
-
}
|
141
|
-
;
|
142
|
-
|
143
|
-
addrs : addr { result = val }
|
144
|
-
| addrs ',' addr { result.push val[2] }
|
145
|
-
;
|
146
|
-
|
147
|
-
addr : mbox
|
148
|
-
| group
|
149
|
-
;
|
150
|
-
|
151
|
-
mboxes : mbox
|
152
|
-
{
|
153
|
-
result = val
|
154
|
-
}
|
155
|
-
| mboxes ',' mbox
|
156
|
-
{
|
157
|
-
result.push val[2]
|
158
|
-
}
|
159
|
-
;
|
160
|
-
|
161
|
-
mbox : spec
|
162
|
-
| routeaddr
|
163
|
-
| phrase routeaddr
|
164
|
-
{
|
165
|
-
val[1].phrase = HFdecoder.decode( result )
|
166
|
-
result = val[1]
|
167
|
-
}
|
168
|
-
;
|
169
|
-
|
170
|
-
group : phrase ':' mboxes ';'
|
171
|
-
{
|
172
|
-
result = AddressGroup.new( result, val[2] )
|
173
|
-
}
|
174
|
-
# | phrase ':' ';' { result = AddressGroup.new( result ) }
|
175
|
-
;
|
176
|
-
|
177
|
-
routeaddr : '<' route spec '>'
|
178
|
-
{
|
179
|
-
result = val[2]
|
180
|
-
result.route = val[1]
|
181
|
-
}
|
182
|
-
| '<' spec '>'
|
183
|
-
{
|
184
|
-
result = val[1]
|
185
|
-
}
|
186
|
-
;
|
187
|
-
|
188
|
-
route : at_domains ':'
|
189
|
-
;
|
190
|
-
|
191
|
-
at_domains: '@' domain { result = [ val[1] ] }
|
192
|
-
| at_domains ',' '@' domain { result.push val[3] }
|
193
|
-
;
|
194
|
-
|
195
|
-
spec : local '@' domain { result = Address.new( val[0], val[2] ) }
|
196
|
-
| local { result = Address.new( result, nil ) }
|
197
|
-
;
|
198
|
-
|
199
|
-
local : word { result = val }
|
200
|
-
| local '.' word { result.push val[2] }
|
201
|
-
;
|
202
|
-
|
203
|
-
domain : domword { result = val }
|
204
|
-
| domain '.' domword { result.push val[2] }
|
205
|
-
;
|
206
|
-
|
207
|
-
domword : atom
|
208
|
-
| DOMLIT
|
209
|
-
| DIGIT
|
210
|
-
;
|
211
|
-
|
212
|
-
msgid : '<' spec '>'
|
213
|
-
{
|
214
|
-
val[1] = val[1].addr
|
215
|
-
result = val.join('')
|
216
|
-
}
|
217
|
-
;
|
218
|
-
|
219
|
-
phrase : word
|
220
|
-
| phrase word { result << ' ' << val[1] }
|
221
|
-
;
|
222
|
-
|
223
|
-
word : atom
|
224
|
-
| QUOTED
|
225
|
-
| DIGIT
|
226
|
-
;
|
227
|
-
|
228
|
-
keys : phrase
|
229
|
-
| keys ',' phrase
|
230
|
-
;
|
231
|
-
|
232
|
-
enc : word
|
233
|
-
{
|
234
|
-
@field.encrypter = val[0]
|
235
|
-
}
|
236
|
-
| word word
|
237
|
-
{
|
238
|
-
@field.encrypter = val[0]
|
239
|
-
@field.keyword = val[1]
|
240
|
-
}
|
241
|
-
;
|
242
|
-
|
243
|
-
version : DIGIT '.' DIGIT
|
244
|
-
{
|
245
|
-
@field.major = val[0].to_i
|
246
|
-
@field.minor = val[2].to_i
|
247
|
-
}
|
248
|
-
;
|
249
|
-
|
250
|
-
ctype : TOKEN '/' TOKEN params
|
251
|
-
{
|
252
|
-
@field.main = val[0]
|
253
|
-
@field.sub = val[2]
|
254
|
-
}
|
255
|
-
| TOKEN params
|
256
|
-
{
|
257
|
-
@field.main = val[0]
|
258
|
-
@field.sub = ''
|
259
|
-
}
|
260
|
-
;
|
261
|
-
|
262
|
-
params : /* none */
|
263
|
-
| params ';' TOKEN '=' value
|
264
|
-
{
|
265
|
-
@field.params[ val[2].downcase ] = val[4]
|
266
|
-
}
|
267
|
-
;
|
268
|
-
|
269
|
-
value : TOKEN
|
270
|
-
| QUOTED
|
271
|
-
;
|
272
|
-
|
273
|
-
cencode : TOKEN
|
274
|
-
{
|
275
|
-
@field.encoding = val[0]
|
276
|
-
}
|
277
|
-
;
|
278
|
-
|
279
|
-
cdisp : TOKEN disp_params
|
280
|
-
{
|
281
|
-
@field.disposition = val[0]
|
282
|
-
}
|
283
|
-
;
|
284
|
-
|
285
|
-
disp_params
|
286
|
-
: /* none */
|
287
|
-
| disp_params ';' disp_param
|
288
|
-
;
|
289
|
-
|
290
|
-
disp_param: /* none */
|
291
|
-
| TOKEN '=' value
|
292
|
-
{
|
293
|
-
@field.params[ val[0].downcase ] = val[2]
|
294
|
-
}
|
295
|
-
;
|
296
|
-
|
297
|
-
atom : ATOM
|
298
|
-
| FROM
|
299
|
-
| BY
|
300
|
-
| VIA
|
301
|
-
| WITH
|
302
|
-
| ID
|
303
|
-
| FOR
|
304
|
-
;
|
305
|
-
|
306
|
-
end
|
307
|
-
|
308
|
-
|
309
|
-
---- header
|
310
|
-
#
|
311
|
-
# mailp for test
|
312
|
-
#
|
313
|
-
|
314
|
-
require 'tmail/mails'
|
315
|
-
|
316
|
-
|
317
|
-
module TMail
|
318
|
-
|
319
|
-
---- inner
|
320
|
-
|
321
|
-
MAILP_DEBUG = false
|
322
|
-
|
323
|
-
def initialize
|
324
|
-
self.debug = MAILP_DEBUG
|
325
|
-
end
|
326
|
-
|
327
|
-
def debug=( flag )
|
328
|
-
@yydebug = flag && Racc_debug_parser
|
329
|
-
@scanner_debug = flag
|
330
|
-
end
|
331
|
-
|
332
|
-
def debug
|
333
|
-
@yydebug
|
334
|
-
end
|
335
|
-
|
336
|
-
|
337
|
-
def Mailp.parse( str, obj, ident )
|
338
|
-
new.parse( str, obj, ident )
|
339
|
-
end
|
340
|
-
|
341
|
-
|
342
|
-
NATIVE_ROUTINE = {
|
343
|
-
'TMail::MsgidH' => :msgid_parse,
|
344
|
-
'TMail::RefH' => :refs_parse
|
345
|
-
}
|
346
|
-
|
347
|
-
def parse( str, obj, ident )
|
348
|
-
return if /\A\s*\z/ === str
|
349
|
-
|
350
|
-
@field = obj
|
351
|
-
|
352
|
-
if mid = NATIVE_ROUTINE[ obj.type.name ] then
|
353
|
-
send mid, str
|
354
|
-
else
|
355
|
-
unless ident then
|
356
|
-
ident = obj.type.name.split('::')[-1].to_s
|
357
|
-
cmt = []
|
358
|
-
obj.comments.replace cmt
|
359
|
-
else
|
360
|
-
cmt = nil
|
361
|
-
end
|
362
|
-
|
363
|
-
@scanner = MailScanner.new( str, ident, cmt )
|
364
|
-
@scanner.debug = @scanner_debug
|
365
|
-
@first = [ ident.intern, ident ]
|
366
|
-
@pass_array = [nil, nil]
|
367
|
-
|
368
|
-
do_parse
|
369
|
-
end
|
370
|
-
end
|
371
|
-
|
372
|
-
|
373
|
-
private
|
374
|
-
|
375
|
-
|
376
|
-
def next_token
|
377
|
-
if @first then
|
378
|
-
ret = @first
|
379
|
-
@first = nil
|
380
|
-
ret
|
381
|
-
else
|
382
|
-
@scanner.scan @pass_array
|
383
|
-
end
|
384
|
-
end
|
385
|
-
|
386
|
-
def on_error( tok, val, vstack )
|
387
|
-
raise ParseError,
|
388
|
-
"\nparse error in '#{@field.name}' header, on token #{val.inspect}"
|
389
|
-
end
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
def refs_parse( str )
|
394
|
-
arr = []
|
395
|
-
|
396
|
-
while mdata = ::TMail::MSGID.match( str ) do
|
397
|
-
str = mdata.post_match
|
398
|
-
|
399
|
-
pre = mdata.pre_match
|
400
|
-
pre.strip!
|
401
|
-
proc_phrase pre, arr unless pre.empty?
|
402
|
-
arr.push mdata.to_s
|
403
|
-
end
|
404
|
-
str.strip!
|
405
|
-
proc_phrase str, arr if not pre or pre.empty?
|
406
|
-
|
407
|
-
@field.refs.replace arr
|
408
|
-
end
|
409
|
-
|
410
|
-
def proc_phrase( str, arr )
|
411
|
-
while mdata = /"([^\\]*(?:\\.[^"\\]*)*)"/.match( str ) do
|
412
|
-
str = mdata.post_match
|
413
|
-
|
414
|
-
pre = mdata.pre_match
|
415
|
-
pre.strip!
|
416
|
-
arr.push pre unless pre.empty?
|
417
|
-
arr.push mdata[1]
|
418
|
-
end
|
419
|
-
str.strip!
|
420
|
-
arr.push unless str.empty?
|
421
|
-
end
|
422
|
-
|
423
|
-
|
424
|
-
def msgid_parse( str )
|
425
|
-
if mdata = ::TMail::MSGID.match( str ) then
|
426
|
-
@field.msgid = mdata.to_s
|
427
|
-
else
|
428
|
-
raise ParseError, "wrong Message-ID format: #{str}"
|
429
|
-
end
|
430
|
-
end
|
431
|
-
|
432
|
-
---- footer
|
433
|
-
|
434
|
-
end # module TMail
|
435
|
-
|
436
|
-
mp = TMail::Testp.new
|
437
|
-
mp.parse
|