racc 1.5.2 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. checksums.yaml +4 -4
  2. data/README.ja.rdoc +0 -1
  3. data/README.rdoc +6 -7
  4. data/{rdoc → doc}/en/NEWS.en.rdoc +0 -0
  5. data/{rdoc → doc}/en/grammar.en.rdoc +27 -31
  6. data/doc/en/grammar2.en.rdoc +219 -0
  7. data/{rdoc → doc}/ja/NEWS.ja.rdoc +0 -0
  8. data/{rdoc → doc}/ja/command.ja.html +0 -0
  9. data/{rdoc → doc}/ja/debug.ja.rdoc +0 -0
  10. data/{rdoc → doc}/ja/grammar.ja.rdoc +0 -0
  11. data/{rdoc → doc}/ja/index.ja.html +0 -0
  12. data/{rdoc → doc}/ja/parser.ja.rdoc +0 -0
  13. data/{rdoc → doc}/ja/usage.ja.html +0 -0
  14. data/ext/racc/cparse/cparse.c +1 -1
  15. data/ext/racc/cparse/extconf.rb +1 -0
  16. data/lib/racc/info.rb +1 -1
  17. data/lib/racc/parser-text.rb +1 -1
  18. data/lib/racc/parser.rb +1 -1
  19. data/lib/racc/parserfilegenerator.rb +0 -44
  20. data/lib/racc/statetransitiontable.rb +2 -8
  21. metadata +15 -121
  22. data/Rakefile +0 -79
  23. data/ext/racc/com/headius/racc/Cparse.java +0 -849
  24. data/lib/racc/pre-setup +0 -13
  25. data/sample/array.y +0 -67
  26. data/sample/array2.y +0 -59
  27. data/sample/calc-ja.y +0 -66
  28. data/sample/calc.y +0 -65
  29. data/sample/conflict.y +0 -15
  30. data/sample/hash.y +0 -60
  31. data/sample/lalr.y +0 -17
  32. data/sample/lists.y +0 -57
  33. data/sample/syntax.y +0 -46
  34. data/sample/yyerr.y +0 -46
  35. data/test/assets/cadenza.y +0 -170
  36. data/test/assets/cast.y +0 -926
  37. data/test/assets/chk.y +0 -126
  38. data/test/assets/conf.y +0 -16
  39. data/test/assets/csspool.y +0 -729
  40. data/test/assets/digraph.y +0 -29
  41. data/test/assets/echk.y +0 -118
  42. data/test/assets/edtf.y +0 -583
  43. data/test/assets/err.y +0 -60
  44. data/test/assets/error_recovery.y +0 -35
  45. data/test/assets/expect.y +0 -7
  46. data/test/assets/firstline.y +0 -4
  47. data/test/assets/huia.y +0 -318
  48. data/test/assets/ichk.y +0 -102
  49. data/test/assets/intp.y +0 -546
  50. data/test/assets/journey.y +0 -47
  51. data/test/assets/liquor.y +0 -313
  52. data/test/assets/machete.y +0 -423
  53. data/test/assets/macruby.y +0 -2197
  54. data/test/assets/mailp.y +0 -437
  55. data/test/assets/mediacloth.y +0 -599
  56. data/test/assets/mof.y +0 -649
  57. data/test/assets/namae.y +0 -302
  58. data/test/assets/nasl.y +0 -626
  59. data/test/assets/newsyn.y +0 -25
  60. data/test/assets/noend.y +0 -4
  61. data/test/assets/nokogiri-css.y +0 -255
  62. data/test/assets/nonass.y +0 -41
  63. data/test/assets/normal.y +0 -27
  64. data/test/assets/norule.y +0 -4
  65. data/test/assets/nullbug1.y +0 -25
  66. data/test/assets/nullbug2.y +0 -15
  67. data/test/assets/opal.y +0 -1807
  68. data/test/assets/opt.y +0 -123
  69. data/test/assets/percent.y +0 -35
  70. data/test/assets/php_serialization.y +0 -98
  71. data/test/assets/recv.y +0 -97
  72. data/test/assets/riml.y +0 -665
  73. data/test/assets/rrconf.y +0 -14
  74. data/test/assets/ruby18.y +0 -1943
  75. data/test/assets/ruby19.y +0 -2174
  76. data/test/assets/ruby20.y +0 -2350
  77. data/test/assets/ruby21.y +0 -2359
  78. data/test/assets/ruby22.y +0 -2381
  79. data/test/assets/scan.y +0 -72
  80. data/test/assets/syntax.y +0 -50
  81. data/test/assets/tp_plus.y +0 -622
  82. data/test/assets/twowaysql.y +0 -278
  83. data/test/assets/unterm.y +0 -5
  84. data/test/assets/useless.y +0 -12
  85. data/test/assets/yyerr.y +0 -46
  86. data/test/bench.y +0 -36
  87. data/test/helper.rb +0 -115
  88. data/test/infini.y +0 -8
  89. data/test/regress/cadenza +0 -796
  90. data/test/regress/cast +0 -3428
  91. data/test/regress/csspool +0 -2314
  92. data/test/regress/edtf +0 -1794
  93. data/test/regress/huia +0 -1392
  94. data/test/regress/journey +0 -222
  95. data/test/regress/liquor +0 -885
  96. data/test/regress/machete +0 -833
  97. data/test/regress/mediacloth +0 -1463
  98. data/test/regress/mof +0 -1368
  99. data/test/regress/namae +0 -634
  100. data/test/regress/nasl +0 -2058
  101. data/test/regress/nokogiri-css +0 -836
  102. data/test/regress/opal +0 -6431
  103. data/test/regress/php_serialization +0 -336
  104. data/test/regress/riml +0 -3283
  105. data/test/regress/ruby18 +0 -6344
  106. data/test/regress/ruby22 +0 -7460
  107. data/test/regress/tp_plus +0 -1933
  108. data/test/regress/twowaysql +0 -556
  109. data/test/scandata/brace +0 -7
  110. data/test/scandata/gvar +0 -1
  111. data/test/scandata/normal +0 -4
  112. data/test/scandata/percent +0 -18
  113. data/test/scandata/slash +0 -10
  114. data/test/src.intp +0 -34
  115. data/test/start.y +0 -20
  116. data/test/test_chk_y.rb +0 -52
  117. data/test/test_grammar_file_parser.rb +0 -15
  118. data/test/test_racc_command.rb +0 -339
  119. data/test/test_scan_y.rb +0 -52
  120. data/test/testscanner.rb +0 -51
  121. data/web/racc.en.rhtml +0 -42
  122. 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