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/opt.y
DELETED
@@ -1,123 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# check options working
|
3
|
-
#
|
4
|
-
|
5
|
-
class Calcp
|
6
|
-
|
7
|
-
prechigh
|
8
|
-
left '*' '/'
|
9
|
-
left '+' '-'
|
10
|
-
preclow
|
11
|
-
|
12
|
-
convert
|
13
|
-
NUMBER 'Number'
|
14
|
-
end
|
15
|
-
|
16
|
-
options no_omit_action_call no_result_var
|
17
|
-
|
18
|
-
rule
|
19
|
-
|
20
|
-
target : exp | /* none */ { 0 } ;
|
21
|
-
|
22
|
-
exp : exp '+' exp { chk(val[0] + val[2]) }
|
23
|
-
| exp '-' exp { chk(val[0] - val[2]) }
|
24
|
-
| exp '*' exp { chk(val[0] * val[2]) }
|
25
|
-
| exp '/' exp { chk(val[0] / val[2]) }
|
26
|
-
| '(' { $emb = true } exp ')'
|
27
|
-
{
|
28
|
-
raise 'must not happen' unless $emb
|
29
|
-
val[2]
|
30
|
-
}
|
31
|
-
| '-' NUMBER { -val[1] }
|
32
|
-
| NUMBER
|
33
|
-
;
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
----header
|
38
|
-
|
39
|
-
class Number; end
|
40
|
-
|
41
|
-
----inner
|
42
|
-
|
43
|
-
def parse( src )
|
44
|
-
@src = src
|
45
|
-
do_parse
|
46
|
-
end
|
47
|
-
|
48
|
-
def next_token
|
49
|
-
@src.shift
|
50
|
-
end
|
51
|
-
|
52
|
-
def initialize
|
53
|
-
@yydebug = true
|
54
|
-
end
|
55
|
-
|
56
|
-
def chk( i )
|
57
|
-
# p i
|
58
|
-
i
|
59
|
-
end
|
60
|
-
|
61
|
-
----footer
|
62
|
-
|
63
|
-
$parser = Calcp.new
|
64
|
-
$test_number = 1
|
65
|
-
|
66
|
-
def chk( src, ans )
|
67
|
-
result = $parser.parse(src)
|
68
|
-
raise "test #{$test_number} failed" unless result == ans
|
69
|
-
$test_number += 1
|
70
|
-
end
|
71
|
-
|
72
|
-
chk(
|
73
|
-
[ [Number, 9],
|
74
|
-
[false, false],
|
75
|
-
[false, false] ], 9
|
76
|
-
)
|
77
|
-
|
78
|
-
chk(
|
79
|
-
[ [Number, 5],
|
80
|
-
['*', nil],
|
81
|
-
[Number, 1],
|
82
|
-
['-', nil],
|
83
|
-
[Number, 1],
|
84
|
-
['*', nil],
|
85
|
-
[Number, 8],
|
86
|
-
[false, false],
|
87
|
-
[false, false] ], -3
|
88
|
-
)
|
89
|
-
|
90
|
-
chk(
|
91
|
-
[ [Number, 5],
|
92
|
-
['+', nil],
|
93
|
-
[Number, 2],
|
94
|
-
['-', nil],
|
95
|
-
[Number, 5],
|
96
|
-
['+', nil],
|
97
|
-
[Number, 2],
|
98
|
-
['-', nil],
|
99
|
-
[Number, 5],
|
100
|
-
[false, false],
|
101
|
-
[false, false] ], -1
|
102
|
-
)
|
103
|
-
|
104
|
-
chk(
|
105
|
-
[ ['-', nil],
|
106
|
-
[Number, 4],
|
107
|
-
[false, false],
|
108
|
-
[false, false] ], -4
|
109
|
-
)
|
110
|
-
|
111
|
-
chk(
|
112
|
-
[ [Number, 7],
|
113
|
-
['*', nil],
|
114
|
-
['(', nil],
|
115
|
-
[Number, 4],
|
116
|
-
['+', nil],
|
117
|
-
[Number, 3],
|
118
|
-
[')', nil],
|
119
|
-
['-', nil],
|
120
|
-
[Number, 9],
|
121
|
-
[false, false],
|
122
|
-
[false, false] ], 40
|
123
|
-
)
|
data/test/assets/percent.y
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
class ScannerChecker
|
2
|
-
rule
|
3
|
-
target: A
|
4
|
-
{
|
5
|
-
i = 7
|
6
|
-
i %= 4
|
7
|
-
raise 'assert failed' unless i == 3
|
8
|
-
tmp = %-This is percent string.-
|
9
|
-
raise 'assert failed' unless tmp == 'This is percent string.'
|
10
|
-
a = 5; b = 3
|
11
|
-
assert_equal(2,(a%b)) #A
|
12
|
-
# assert_equal(2,(a %b)) # is %-string
|
13
|
-
assert_equal(2,(a% b)) #B
|
14
|
-
assert_equal(2,(a % b)) #C
|
15
|
-
}
|
16
|
-
end
|
17
|
-
|
18
|
-
---- inner ----
|
19
|
-
|
20
|
-
def parse
|
21
|
-
@q = [[:A, 'A'], [false, '$']]
|
22
|
-
do_parse
|
23
|
-
end
|
24
|
-
|
25
|
-
def next_token
|
26
|
-
@q.shift
|
27
|
-
end
|
28
|
-
|
29
|
-
def assert_equal( expect, real )
|
30
|
-
raise "expect #{expect.inspect} but #{real.inspect}" unless expect == real
|
31
|
-
end
|
32
|
-
|
33
|
-
---- footer ----
|
34
|
-
|
35
|
-
parser = ScannerChecker.new.parse
|
@@ -1,98 +0,0 @@
|
|
1
|
-
# MIT License
|
2
|
-
# See https://github.com/divoxx/ruby-php-serialization/blob/master/LICENSE.txt
|
3
|
-
|
4
|
-
class PhpSerialization::Unserializer
|
5
|
-
rule
|
6
|
-
|
7
|
-
data : null ';' { @object = val[0] }
|
8
|
-
| bool ';' { @object = val[0] }
|
9
|
-
| integer ';' { @object = val[0] }
|
10
|
-
| double ';' { @object = val[0] }
|
11
|
-
| string ';' { @object = val[0] }
|
12
|
-
| assoc_array { @object = val[0] }
|
13
|
-
| object { @object = val[0] }
|
14
|
-
;
|
15
|
-
|
16
|
-
null : 'N' { result = nil }
|
17
|
-
;
|
18
|
-
|
19
|
-
bool : 'b' ':' NUMBER { result = Integer(val[2]) > 0 }
|
20
|
-
;
|
21
|
-
|
22
|
-
integer : 'i' ':' NUMBER { result = Integer(val[2]) }
|
23
|
-
;
|
24
|
-
|
25
|
-
double : 'd' ':' NUMBER { result = Float(val[2]) }
|
26
|
-
;
|
27
|
-
|
28
|
-
string : 's' ':' NUMBER ':' STRING { result = val[4] }
|
29
|
-
;
|
30
|
-
|
31
|
-
object : 'O' ':' NUMBER ':' STRING ':' NUMBER ':' '{' attribute_list '}'
|
32
|
-
{
|
33
|
-
if eval("defined?(#{val[4]})")
|
34
|
-
result = Object.const_get(val[4]).new
|
35
|
-
|
36
|
-
val[9].each do |(attr_name, value)|
|
37
|
-
# Protected and private attributes will have a \0..\0 prefix
|
38
|
-
attr_name = attr_name.gsub(/\A\\0[^\\]+\\0/, '')
|
39
|
-
result.instance_variable_set("@#{attr_name}", value)
|
40
|
-
end
|
41
|
-
else
|
42
|
-
klass_name = val[4].gsub(/^Struct::/, '')
|
43
|
-
attr_names, values = [], []
|
44
|
-
|
45
|
-
val[9].each do |(attr_name, value)|
|
46
|
-
# Protected and private attributes will have a \0..\0 prefix
|
47
|
-
attr_names << attr_name.gsub(/\A\\0[^\\]+\\0/, '')
|
48
|
-
values << value
|
49
|
-
end
|
50
|
-
|
51
|
-
result = Struct.new(klass_name, *attr_names).new(*values)
|
52
|
-
result.instance_variable_set("@_php_class", klass_name)
|
53
|
-
end
|
54
|
-
}
|
55
|
-
;
|
56
|
-
|
57
|
-
attribute_list : attribute_list attribute { result = val[0] << val[1] }
|
58
|
-
| { result = [] }
|
59
|
-
;
|
60
|
-
|
61
|
-
attribute : data data { result = val }
|
62
|
-
;
|
63
|
-
|
64
|
-
assoc_array : 'a' ':' NUMBER ':' '{' attribute_list '}'
|
65
|
-
{
|
66
|
-
# Checks if the keys are a sequence of integers
|
67
|
-
idx = -1
|
68
|
-
arr = val[5].all? { |(k,v)| k == (idx += 1) }
|
69
|
-
|
70
|
-
if arr
|
71
|
-
result = val[5].map { |(k,v)| v }
|
72
|
-
else
|
73
|
-
result = Hash[val[5]]
|
74
|
-
end
|
75
|
-
}
|
76
|
-
;
|
77
|
-
|
78
|
-
end
|
79
|
-
|
80
|
-
---- header ----
|
81
|
-
require 'php_serialization/tokenizer'
|
82
|
-
|
83
|
-
---- inner ----
|
84
|
-
def initialize(tokenizer_klass = Tokenizer)
|
85
|
-
@tokenizer_klass = tokenizer_klass
|
86
|
-
end
|
87
|
-
|
88
|
-
def run(string)
|
89
|
-
@tokenizer = @tokenizer_klass.new(string)
|
90
|
-
yyparse(@tokenizer, :each)
|
91
|
-
return @object
|
92
|
-
ensure
|
93
|
-
@tokenizer = nil
|
94
|
-
end
|
95
|
-
|
96
|
-
def next_token
|
97
|
-
@tokenizer.next_token
|
98
|
-
end
|
data/test/assets/recv.y
DELETED
@@ -1,97 +0,0 @@
|
|
1
|
-
# s/r 5, r/r 10
|
2
|
-
class A
|
3
|
-
rule
|
4
|
-
|
5
|
-
content: RecvH received
|
6
|
-
;
|
7
|
-
|
8
|
-
datetime: day
|
9
|
-
;
|
10
|
-
|
11
|
-
msgid: '<' spec '>';
|
12
|
-
|
13
|
-
day:
|
14
|
-
| ATOM ','
|
15
|
-
;
|
16
|
-
|
17
|
-
received: recvitem_list recvdatetime
|
18
|
-
;
|
19
|
-
|
20
|
-
recvitem_list:
|
21
|
-
| recvitem_list recvitem
|
22
|
-
;
|
23
|
-
|
24
|
-
recvitem: by | via | with | for ;
|
25
|
-
|
26
|
-
by:
|
27
|
-
| BY domain
|
28
|
-
;
|
29
|
-
|
30
|
-
via:
|
31
|
-
| VIA ATOM
|
32
|
-
;
|
33
|
-
|
34
|
-
with: WITH ATOM
|
35
|
-
;
|
36
|
-
|
37
|
-
for:
|
38
|
-
| FOR addr
|
39
|
-
;
|
40
|
-
|
41
|
-
recvdatetime:
|
42
|
-
| ';' datetime
|
43
|
-
;
|
44
|
-
|
45
|
-
addr: mbox | group ;
|
46
|
-
|
47
|
-
mboxes: mbox
|
48
|
-
| mboxes ',' mbox
|
49
|
-
;
|
50
|
-
|
51
|
-
mbox: spec
|
52
|
-
| routeaddr
|
53
|
-
| phrase routeaddr
|
54
|
-
;
|
55
|
-
|
56
|
-
group: phrase ':' mboxes ';'
|
57
|
-
;
|
58
|
-
|
59
|
-
routeaddr: '<' route spec '>'
|
60
|
-
| '<' spec '>'
|
61
|
-
;
|
62
|
-
|
63
|
-
route: at_domains ':' ;
|
64
|
-
|
65
|
-
at_domains: '@' domain
|
66
|
-
| at_domains ',' '@' domain
|
67
|
-
;
|
68
|
-
|
69
|
-
spec: local '@' domain
|
70
|
-
| local
|
71
|
-
;
|
72
|
-
|
73
|
-
local: word
|
74
|
-
| local '.' word
|
75
|
-
;
|
76
|
-
|
77
|
-
domain: domword
|
78
|
-
| domain '.' domword
|
79
|
-
;
|
80
|
-
|
81
|
-
domword: atom
|
82
|
-
| DOMLIT
|
83
|
-
| DIGIT
|
84
|
-
;
|
85
|
-
|
86
|
-
phrase: word
|
87
|
-
| phrase word
|
88
|
-
;
|
89
|
-
|
90
|
-
word: atom
|
91
|
-
| QUOTED
|
92
|
-
| DIGIT
|
93
|
-
;
|
94
|
-
|
95
|
-
atom: ATOM | FROM | BY | VIA | WITH | ID | FOR ;
|
96
|
-
|
97
|
-
end
|