racc 1.4.15 → 1.4.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/COPYING +22 -515
- data/Manifest.txt +3 -9
- data/README.ja.rdoc +3 -4
- data/README.rdoc +4 -4
- data/Rakefile +13 -55
- data/bin/racc +2 -4
- data/ext/racc/{cparse.c → cparse/cparse.c} +64 -31
- data/ext/racc/cparse/extconf.rb +8 -0
- data/lib/racc/exception.rb +3 -5
- data/lib/racc/grammar.rb +5 -7
- data/lib/racc/grammarfileparser.rb +4 -3
- data/lib/racc/info.rb +4 -6
- data/lib/racc/iset.rb +2 -2
- data/lib/racc/logfilegenerator.rb +2 -2
- data/lib/racc/parser-text.rb +14 -11
- data/lib/racc/parser.rb +14 -11
- data/lib/racc/parserfilegenerator.rb +5 -7
- data/lib/racc/state.rb +11 -13
- data/test/assets/intp.y +4 -4
- data/test/assets/mailp.y +27 -27
- data/test/assets/mof.y +12 -12
- data/test/assets/nullbug2.y +2 -2
- data/test/assets/recv.y +20 -20
- data/test/assets/syntax.y +1 -1
- data/test/assets/twowaysql.y +1 -1
- data/test/helper.rb +46 -35
- data/test/regress/cadenza +60 -60
- data/test/regress/cast +8 -8
- data/test/regress/csspool +167 -167
- data/test/regress/edtf +115 -115
- data/test/regress/huia +75 -75
- data/test/regress/journey +12 -12
- data/test/regress/liquor +54 -54
- data/test/regress/machete +37 -37
- data/test/regress/mediacloth +83 -83
- data/test/regress/mof +60 -60
- data/test/regress/namae +29 -29
- data/test/regress/nasl +174 -174
- data/test/regress/nokogiri-css +59 -59
- data/test/regress/opal +352 -352
- data/test/regress/php_serialization +20 -20
- data/test/regress/riml +261 -261
- data/test/regress/ruby18 +353 -353
- data/test/regress/ruby22 +433 -433
- data/test/regress/tp_plus +125 -125
- data/test/regress/twowaysql +30 -30
- data/test/test_chk_y.rb +1 -0
- data/test/test_racc_command.rb +5 -24
- data/test/test_scan_y.rb +1 -0
- data/test/testscanner.rb +1 -1
- metadata +9 -76
- data/ext/racc/depend +0 -1
- data/ext/racc/extconf.rb +0 -7
- data/test/assets/bibtex.y +0 -141
- data/test/assets/rdblockparser.y +0 -576
- data/test/assets/rdinlineparser.y +0 -561
- data/test/regress/bibtex +0 -474
- data/test/regress/rdblockparser +0 -1061
- data/test/regress/rdinlineparser +0 -1243
data/test/assets/mailp.y
CHANGED
@@ -35,7 +35,7 @@ rule
|
|
35
35
|
@field.domain = mb.domain
|
36
36
|
}
|
37
37
|
;
|
38
|
-
|
38
|
+
|
39
39
|
datetime : day DIGIT ATOM DIGIT hour zone
|
40
40
|
# 0 1 2 3 4 5
|
41
41
|
# day month year
|
@@ -44,11 +44,11 @@ rule
|
|
44
44
|
result = (t + val[4] - val[5]).localtime
|
45
45
|
}
|
46
46
|
;
|
47
|
-
|
47
|
+
|
48
48
|
day : /* none */
|
49
49
|
| ATOM ','
|
50
50
|
;
|
51
|
-
|
51
|
+
|
52
52
|
hour : DIGIT ':' DIGIT
|
53
53
|
{
|
54
54
|
result = (result.to_i * 60 * 60) + (val[2].to_i * 60)
|
@@ -60,16 +60,16 @@ rule
|
|
60
60
|
+ val[4].to_i
|
61
61
|
}
|
62
62
|
;
|
63
|
-
|
63
|
+
|
64
64
|
zone : ATOM
|
65
65
|
{
|
66
66
|
result = ::TMail.zonestr2i( val[0] ) * 60
|
67
67
|
}
|
68
68
|
;
|
69
|
-
|
69
|
+
|
70
70
|
received : from by via with id for recvdatetime
|
71
71
|
;
|
72
|
-
|
72
|
+
|
73
73
|
from : /* none */
|
74
74
|
| FROM domain
|
75
75
|
{
|
@@ -84,28 +84,28 @@ rule
|
|
84
84
|
@field.from = Address.join( val[1] )
|
85
85
|
}
|
86
86
|
;
|
87
|
-
|
87
|
+
|
88
88
|
by : /* none */
|
89
89
|
| BY domain
|
90
90
|
{
|
91
91
|
@field.by = Address.join( val[1] )
|
92
92
|
}
|
93
93
|
;
|
94
|
-
|
94
|
+
|
95
95
|
via : /* none */
|
96
96
|
| VIA ATOM
|
97
97
|
{
|
98
98
|
@field.via = val[1]
|
99
99
|
}
|
100
100
|
;
|
101
|
-
|
101
|
+
|
102
102
|
with : /* none */
|
103
103
|
| WITH ATOM
|
104
104
|
{
|
105
105
|
@field.with.push val[1]
|
106
106
|
}
|
107
107
|
;
|
108
|
-
|
108
|
+
|
109
109
|
id : /* none */
|
110
110
|
| ID msgid
|
111
111
|
{
|
@@ -116,14 +116,14 @@ rule
|
|
116
116
|
@field.msgid = val[1]
|
117
117
|
}
|
118
118
|
;
|
119
|
-
|
119
|
+
|
120
120
|
for : /* none */
|
121
121
|
| FOR addr
|
122
122
|
{
|
123
123
|
@field.for_ = val[1].address
|
124
124
|
}
|
125
125
|
;
|
126
|
-
|
126
|
+
|
127
127
|
recvdatetime
|
128
128
|
: /* none */
|
129
129
|
| ';' datetime
|
@@ -131,7 +131,7 @@ rule
|
|
131
131
|
@field.date = val[1]
|
132
132
|
}
|
133
133
|
;
|
134
|
-
|
134
|
+
|
135
135
|
returnpath: '<' '>'
|
136
136
|
| routeaddr
|
137
137
|
{
|
@@ -173,7 +173,7 @@ rule
|
|
173
173
|
}
|
174
174
|
# | phrase ':' ';' { result = AddressGroup.new( result ) }
|
175
175
|
;
|
176
|
-
|
176
|
+
|
177
177
|
routeaddr : '<' route spec '>'
|
178
178
|
{
|
179
179
|
result = val[2]
|
@@ -184,22 +184,22 @@ rule
|
|
184
184
|
result = val[1]
|
185
185
|
}
|
186
186
|
;
|
187
|
-
|
187
|
+
|
188
188
|
route : at_domains ':'
|
189
189
|
;
|
190
|
-
|
190
|
+
|
191
191
|
at_domains: '@' domain { result = [ val[1] ] }
|
192
192
|
| at_domains ',' '@' domain { result.push val[3] }
|
193
193
|
;
|
194
|
-
|
194
|
+
|
195
195
|
spec : local '@' domain { result = Address.new( val[0], val[2] ) }
|
196
196
|
| local { result = Address.new( result, nil ) }
|
197
197
|
;
|
198
|
-
|
198
|
+
|
199
199
|
local : word { result = val }
|
200
200
|
| local '.' word { result.push val[2] }
|
201
201
|
;
|
202
|
-
|
202
|
+
|
203
203
|
domain : domword { result = val }
|
204
204
|
| domain '.' domword { result.push val[2] }
|
205
205
|
;
|
@@ -215,11 +215,11 @@ rule
|
|
215
215
|
result = val.join('')
|
216
216
|
}
|
217
217
|
;
|
218
|
-
|
218
|
+
|
219
219
|
phrase : word
|
220
220
|
| phrase word { result << ' ' << val[1] }
|
221
221
|
;
|
222
|
-
|
222
|
+
|
223
223
|
word : atom
|
224
224
|
| QUOTED
|
225
225
|
| DIGIT
|
@@ -228,7 +228,7 @@ rule
|
|
228
228
|
keys : phrase
|
229
229
|
| keys ',' phrase
|
230
230
|
;
|
231
|
-
|
231
|
+
|
232
232
|
enc : word
|
233
233
|
{
|
234
234
|
@field.encrypter = val[0]
|
@@ -258,7 +258,7 @@ rule
|
|
258
258
|
@field.sub = ''
|
259
259
|
}
|
260
260
|
;
|
261
|
-
|
261
|
+
|
262
262
|
params : /* none */
|
263
263
|
| params ';' TOKEN '=' value
|
264
264
|
{
|
@@ -281,7 +281,7 @@ rule
|
|
281
281
|
@field.disposition = val[0]
|
282
282
|
}
|
283
283
|
;
|
284
|
-
|
284
|
+
|
285
285
|
disp_params
|
286
286
|
: /* none */
|
287
287
|
| disp_params ';' disp_param
|
@@ -293,7 +293,7 @@ rule
|
|
293
293
|
@field.params[ val[0].downcase ] = val[2]
|
294
294
|
}
|
295
295
|
;
|
296
|
-
|
296
|
+
|
297
297
|
atom : ATOM
|
298
298
|
| FROM
|
299
299
|
| BY
|
@@ -302,7 +302,7 @@ rule
|
|
302
302
|
| ID
|
303
303
|
| FOR
|
304
304
|
;
|
305
|
-
|
305
|
+
|
306
306
|
end
|
307
307
|
|
308
308
|
|
@@ -382,7 +382,7 @@ module TMail
|
|
382
382
|
@scanner.scan @pass_array
|
383
383
|
end
|
384
384
|
end
|
385
|
-
|
385
|
+
|
386
386
|
def on_error( tok, val, vstack )
|
387
387
|
raise ParseError,
|
388
388
|
"\nparse error in '#{@field.name}' header, on token #{val.inspect}"
|
data/test/assets/mof.y
CHANGED
@@ -33,7 +33,7 @@ class MOF::Parser
|
|
33
33
|
octalValue
|
34
34
|
decimalValue
|
35
35
|
hexValue
|
36
|
-
|
36
|
+
|
37
37
|
rule
|
38
38
|
|
39
39
|
/* Returns a Hash of filename and MofResult */
|
@@ -47,7 +47,7 @@ rule
|
|
47
47
|
result[@name] = @result
|
48
48
|
}
|
49
49
|
;
|
50
|
-
|
50
|
+
|
51
51
|
mofProduction
|
52
52
|
: compilerDirective
|
53
53
|
| classDeclaration
|
@@ -66,7 +66,7 @@ rule
|
|
66
66
|
* compilerDirective
|
67
67
|
*
|
68
68
|
*/
|
69
|
-
|
69
|
+
|
70
70
|
compilerDirective
|
71
71
|
: "#" PRAGMA INCLUDE pragmaParameters_opt
|
72
72
|
{ raise MOF::Helper::Error.new(@name,@lineno,@line,"Missing filename after '#pragma include'") unless val[3]
|
@@ -107,7 +107,7 @@ rule
|
|
107
107
|
* classDeclaration
|
108
108
|
*
|
109
109
|
*/
|
110
|
-
|
110
|
+
|
111
111
|
classDeclaration
|
112
112
|
: qualifierList_opt CLASS className alias_opt superClass_opt "{" classFeatures "}" ";"
|
113
113
|
{ qualifiers = val[0]
|
@@ -151,7 +151,7 @@ rule
|
|
151
151
|
result << val[2] if val[2]
|
152
152
|
}
|
153
153
|
;
|
154
|
-
|
154
|
+
|
155
155
|
qualifier
|
156
156
|
: qualifierName qualifierParameter_opt flavor_opt
|
157
157
|
{ # Get qualifier decl
|
@@ -242,7 +242,7 @@ rule
|
|
242
242
|
result = CIM::Property.new(type,val[2],val[0],val[4])
|
243
243
|
}
|
244
244
|
;
|
245
|
-
|
245
|
+
|
246
246
|
referenceDeclaration
|
247
247
|
: qualifierList_opt objectRef referenceName array_opt defaultValue_opt ";"
|
248
248
|
{ if val[4]
|
@@ -308,7 +308,7 @@ rule
|
|
308
308
|
: /* empty */
|
309
309
|
| parameterList
|
310
310
|
;
|
311
|
-
|
311
|
+
|
312
312
|
parameterList
|
313
313
|
: parameter parameters
|
314
314
|
{ result = val[1].unshift val[0] }
|
@@ -367,7 +367,7 @@ rule
|
|
367
367
|
: /* empty */
|
368
368
|
| defaultValue
|
369
369
|
;
|
370
|
-
|
370
|
+
|
371
371
|
defaultValue
|
372
372
|
: "=" initializer
|
373
373
|
{ result = val[1] }
|
@@ -416,7 +416,7 @@ rule
|
|
416
416
|
| string stringValue
|
417
417
|
{ result = val[0] + val[1] }
|
418
418
|
;
|
419
|
-
|
419
|
+
|
420
420
|
referenceInitializer
|
421
421
|
: objectHandle
|
422
422
|
| aliasIdentifier
|
@@ -465,7 +465,7 @@ rule
|
|
465
465
|
* qualifierDeclaration
|
466
466
|
*
|
467
467
|
*/
|
468
|
-
|
468
|
+
|
469
469
|
qualifierDeclaration
|
470
470
|
/* 0 1 2 3 4 */
|
471
471
|
: QUALIFIER qualifierName qualifierType scope defaultFlavor_opt ";"
|
@@ -534,7 +534,7 @@ rule
|
|
534
534
|
* instanceDeclaration
|
535
535
|
*
|
536
536
|
*/
|
537
|
-
|
537
|
+
|
538
538
|
instanceDeclaration
|
539
539
|
: instance ";"
|
540
540
|
;
|
@@ -583,7 +583,7 @@ def initialize options = {}
|
|
583
583
|
@includes = options[:includes] || []
|
584
584
|
@quiet = options[:quiet]
|
585
585
|
@style = options[:style] || :cim # default to style CIM v2.2 syntax
|
586
|
-
|
586
|
+
|
587
587
|
@lineno = 1
|
588
588
|
@file = nil
|
589
589
|
@iconv = nil
|
data/test/assets/nullbug2.y
CHANGED
data/test/assets/recv.y
CHANGED
@@ -4,19 +4,19 @@ rule
|
|
4
4
|
|
5
5
|
content: RecvH received
|
6
6
|
;
|
7
|
-
|
7
|
+
|
8
8
|
datetime: day
|
9
9
|
;
|
10
|
-
|
10
|
+
|
11
11
|
msgid: '<' spec '>';
|
12
|
-
|
12
|
+
|
13
13
|
day:
|
14
14
|
| ATOM ','
|
15
15
|
;
|
16
|
-
|
16
|
+
|
17
17
|
received: recvitem_list recvdatetime
|
18
18
|
;
|
19
|
-
|
19
|
+
|
20
20
|
recvitem_list:
|
21
21
|
| recvitem_list recvitem
|
22
22
|
;
|
@@ -26,25 +26,25 @@ rule
|
|
26
26
|
by:
|
27
27
|
| BY domain
|
28
28
|
;
|
29
|
-
|
29
|
+
|
30
30
|
via:
|
31
31
|
| VIA ATOM
|
32
32
|
;
|
33
|
-
|
33
|
+
|
34
34
|
with: WITH ATOM
|
35
35
|
;
|
36
|
-
|
36
|
+
|
37
37
|
for:
|
38
38
|
| FOR addr
|
39
39
|
;
|
40
|
-
|
40
|
+
|
41
41
|
recvdatetime:
|
42
42
|
| ';' datetime
|
43
43
|
;
|
44
|
-
|
44
|
+
|
45
45
|
addr: mbox | group ;
|
46
46
|
|
47
|
-
mboxes: mbox
|
47
|
+
mboxes: mbox
|
48
48
|
| mboxes ',' mbox
|
49
49
|
;
|
50
50
|
|
@@ -59,21 +59,21 @@ rule
|
|
59
59
|
routeaddr: '<' route spec '>'
|
60
60
|
| '<' spec '>'
|
61
61
|
;
|
62
|
-
|
62
|
+
|
63
63
|
route: at_domains ':' ;
|
64
|
-
|
65
|
-
at_domains: '@' domain
|
64
|
+
|
65
|
+
at_domains: '@' domain
|
66
66
|
| at_domains ',' '@' domain
|
67
67
|
;
|
68
|
-
|
68
|
+
|
69
69
|
spec: local '@' domain
|
70
|
-
| local
|
70
|
+
| local
|
71
71
|
;
|
72
|
-
|
72
|
+
|
73
73
|
local: word
|
74
74
|
| local '.' word
|
75
75
|
;
|
76
|
-
|
76
|
+
|
77
77
|
domain: domword
|
78
78
|
| domain '.' domword
|
79
79
|
;
|
@@ -86,12 +86,12 @@ rule
|
|
86
86
|
phrase: word
|
87
87
|
| phrase word
|
88
88
|
;
|
89
|
-
|
89
|
+
|
90
90
|
word: atom
|
91
91
|
| QUOTED
|
92
92
|
| DIGIT
|
93
93
|
;
|
94
94
|
|
95
95
|
atom: ATOM | FROM | BY | VIA | WITH | ID | FOR ;
|
96
|
-
|
96
|
+
|
97
97
|
end
|
data/test/assets/syntax.y
CHANGED
data/test/assets/twowaysql.y
CHANGED
data/test/helper.rb
CHANGED
@@ -1,21 +1,28 @@
|
|
1
|
+
verbose = $VERBOSE
|
1
2
|
$VERBOSE = true
|
2
|
-
|
3
|
+
begin
|
4
|
+
|
5
|
+
require 'test/unit'
|
6
|
+
begin
|
7
|
+
require_relative './lib/core_assertions'
|
8
|
+
Test::Unit::TestCase.include Test::Unit::CoreAssertions
|
9
|
+
rescue LoadError
|
10
|
+
end
|
3
11
|
require 'racc/static'
|
4
12
|
require 'fileutils'
|
5
13
|
require 'tempfile'
|
6
14
|
require 'timeout'
|
7
15
|
|
8
16
|
module Racc
|
9
|
-
class TestCase <
|
17
|
+
class TestCase < Test::Unit::TestCase
|
10
18
|
PROJECT_DIR = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
11
19
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
ERR_DIR = File.join(TEST_DIR, 'err')
|
20
|
+
test_dir = File.join(PROJECT_DIR, 'test')
|
21
|
+
test_dir = File.join(PROJECT_DIR, 'racc') unless File.exist?(test_dir)
|
22
|
+
TEST_DIR = test_dir
|
23
|
+
racc = File.join(PROJECT_DIR, 'bin', 'racc')
|
24
|
+
racc = File.join(PROJECT_DIR, '..', 'libexec', 'racc') unless File.exist?(racc)
|
25
|
+
RACC = racc
|
19
26
|
ASSET_DIR = File.join(TEST_DIR, 'assets') # test grammars
|
20
27
|
REGRESS_DIR = File.join(TEST_DIR, 'regress') # known-good generated outputs
|
21
28
|
|
@@ -25,32 +32,35 @@ module Racc
|
|
25
32
|
].join(':')
|
26
33
|
|
27
34
|
def setup
|
28
|
-
|
29
|
-
|
30
|
-
|
35
|
+
@TEMP_DIR = Dir.mktmpdir("racc")
|
36
|
+
@OUT_DIR = File.join(@TEMP_DIR, 'out')
|
37
|
+
@TAB_DIR = File.join(@TEMP_DIR, 'tab') # generated parsers go here
|
38
|
+
@LOG_DIR = File.join(@TEMP_DIR, 'log')
|
39
|
+
@ERR_DIR = File.join(@TEMP_DIR, 'err')
|
40
|
+
FileUtils.mkdir_p([@OUT_DIR, @TAB_DIR, @LOG_DIR, @ERR_DIR])
|
41
|
+
FileUtils.cp File.join(TEST_DIR, "src.intp"), @TEMP_DIR
|
31
42
|
end
|
32
43
|
|
33
44
|
def teardown
|
34
|
-
|
35
|
-
|
36
|
-
end
|
45
|
+
FileUtils.rm_f(File.join(@TEMP_DIR, "src.intp"))
|
46
|
+
FileUtils.rm_rf([@OUT_DIR, @TAB_DIR, @LOG_DIR, @ERR_DIR, @TEMP_DIR])
|
37
47
|
end
|
38
48
|
|
39
|
-
def assert_compile(asset, args = [])
|
49
|
+
def assert_compile(asset, args = [], **opt)
|
40
50
|
file = File.basename(asset, '.y')
|
41
51
|
args = ([args].flatten) + [
|
42
52
|
"#{ASSET_DIR}/#{file}.y",
|
43
53
|
'-Do',
|
44
|
-
"-O#{OUT_DIR}/#{file}",
|
45
|
-
"-o#{TAB_DIR}/#{file}",
|
54
|
+
"-O#{@OUT_DIR}/#{file}",
|
55
|
+
"-o#{@TAB_DIR}/#{file}",
|
46
56
|
]
|
47
|
-
racc
|
57
|
+
racc(*args, **opt)
|
48
58
|
end
|
49
59
|
|
50
60
|
def assert_debugfile(asset, ok)
|
51
61
|
file = File.basename(asset, '.y')
|
52
|
-
Dir.chdir(
|
53
|
-
File.foreach("
|
62
|
+
Dir.chdir(@LOG_DIR) do
|
63
|
+
File.foreach("#{file}.y") do |line|
|
54
64
|
line.strip!
|
55
65
|
case line
|
56
66
|
when /sr/ then assert_equal "sr#{ok[0]}", line
|
@@ -66,10 +76,9 @@ module Racc
|
|
66
76
|
end
|
67
77
|
|
68
78
|
def assert_exec(asset)
|
79
|
+
lib_path = File.expand_path("../../lib", __FILE__)
|
69
80
|
file = File.basename(asset, '.y')
|
70
|
-
|
71
|
-
ruby("#{TAB_DIR}/#{file}")
|
72
|
-
end
|
81
|
+
ruby "-I#{lib_path}", "#{@TAB_DIR}/#{file}"
|
73
82
|
end
|
74
83
|
|
75
84
|
def strip_version(source)
|
@@ -77,28 +86,30 @@ module Racc
|
|
77
86
|
end
|
78
87
|
|
79
88
|
def assert_output_unchanged(asset)
|
89
|
+
# racc generates the difference results in GitHub Actions
|
90
|
+
omit unless RUBY_PLATFORM =~ /darwin/
|
91
|
+
|
80
92
|
file = File.basename(asset, '.y')
|
81
93
|
|
82
94
|
expected = File.read("#{REGRESS_DIR}/#{file}")
|
83
|
-
actual = File.read("#{TAB_DIR}/#{file}")
|
95
|
+
actual = File.read("#{@TAB_DIR}/#{file}")
|
84
96
|
result = (strip_version(expected) == strip_version(actual))
|
85
97
|
|
86
98
|
assert(result, "Output of test/assets/#{file}.y differed from " \
|
87
99
|
"expectation. Try compiling it and diff with test/regress/#{file}.")
|
88
100
|
end
|
89
101
|
|
90
|
-
def racc(arg)
|
91
|
-
|
102
|
+
def racc(*arg, **opt)
|
103
|
+
lib_path = File.expand_path("../../lib", __FILE__)
|
104
|
+
ruby "-I#{lib_path}", "-S", RACC, *arg, **opt
|
92
105
|
end
|
93
106
|
|
94
|
-
def ruby(arg)
|
95
|
-
|
96
|
-
Tempfile.open 'test' do |io|
|
97
|
-
cmd = "#{ENV['_'] || Gem.ruby} -I #{INC} #{arg} 2>#{io.path}"
|
98
|
-
result = system(cmd)
|
99
|
-
assert(result, io.read)
|
100
|
-
end
|
101
|
-
end
|
107
|
+
def ruby(*arg, **opt)
|
108
|
+
assert_ruby_status(["-C", @TEMP_DIR, *arg], **opt)
|
102
109
|
end
|
103
110
|
end
|
104
111
|
end
|
112
|
+
|
113
|
+
ensure
|
114
|
+
$VERBOSE = verbose
|
115
|
+
end
|