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/lib/racc/pre-setup
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
def generate_parser_text_rb(target)
|
2
|
-
return if File.exist?(srcfile(target))
|
3
|
-
$stderr.puts "generating #{target}..."
|
4
|
-
File.open(target, 'w') {|f|
|
5
|
-
f.puts "module Racc"
|
6
|
-
f.puts " PARSER_TEXT = <<'__end_of_file__'"
|
7
|
-
f.puts File.read(srcfile('parser.rb'))
|
8
|
-
f.puts "__end_of_file__"
|
9
|
-
f.puts "end"
|
10
|
-
}
|
11
|
-
end
|
12
|
-
|
13
|
-
generate_parser_text_rb 'parser-text.rb'
|
data/sample/array.y
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# convert Array-like string into Ruby's Array.
|
4
|
-
|
5
|
-
class ArrayParser
|
6
|
-
|
7
|
-
rule
|
8
|
-
|
9
|
-
array : '[' contents ']'
|
10
|
-
{
|
11
|
-
result = val[1]
|
12
|
-
}
|
13
|
-
| '[' ']'
|
14
|
-
{
|
15
|
-
result = []
|
16
|
-
}
|
17
|
-
|
18
|
-
contents: ITEM
|
19
|
-
{
|
20
|
-
result = val
|
21
|
-
}
|
22
|
-
| contents ',' ITEM
|
23
|
-
{
|
24
|
-
result.push val[2]
|
25
|
-
}
|
26
|
-
|
27
|
-
---- inner
|
28
|
-
|
29
|
-
def parse(str)
|
30
|
-
str = str.strip
|
31
|
-
@q = []
|
32
|
-
until str.empty?
|
33
|
-
case str
|
34
|
-
when /\A\s+/
|
35
|
-
str = $'
|
36
|
-
when /\A\w+/
|
37
|
-
@q.push [:ITEM, $&]
|
38
|
-
str = $'
|
39
|
-
else
|
40
|
-
c = str[0,1]
|
41
|
-
@q.push [c, c]
|
42
|
-
str = str[1..-1]
|
43
|
-
end
|
44
|
-
end
|
45
|
-
@q.push [false, '$'] # is optional from Racc 1.3.7
|
46
|
-
do_parse
|
47
|
-
end
|
48
|
-
|
49
|
-
def next_token
|
50
|
-
@q.shift
|
51
|
-
end
|
52
|
-
|
53
|
-
---- footer
|
54
|
-
|
55
|
-
if $0 == __FILE__
|
56
|
-
src = <<EOS
|
57
|
-
[
|
58
|
-
a, b, c,
|
59
|
-
d,
|
60
|
-
e ]
|
61
|
-
EOS
|
62
|
-
puts 'parsing:'
|
63
|
-
print src
|
64
|
-
puts
|
65
|
-
puts 'result:'
|
66
|
-
p ArrayParser.new.parse(src)
|
67
|
-
end
|
data/sample/array2.y
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Converting Array-like string into Ruby's Array, version 2.
|
4
|
-
# This grammer uses no_result_var.
|
5
|
-
|
6
|
-
class ArrayParser2
|
7
|
-
options no_result_var
|
8
|
-
rule
|
9
|
-
array : '[' contents ']' { val[1] }
|
10
|
-
| '[' ']' { [] }
|
11
|
-
|
12
|
-
contents: ITEM { val }
|
13
|
-
| contents ',' ITEM { val[0].push val[2]; val[0] }
|
14
|
-
end
|
15
|
-
|
16
|
-
---- inner
|
17
|
-
|
18
|
-
def parse(str)
|
19
|
-
@str = str
|
20
|
-
yyparse self, :scan
|
21
|
-
end
|
22
|
-
|
23
|
-
def scan
|
24
|
-
str = @str.strip
|
25
|
-
until str.empty?
|
26
|
-
case str
|
27
|
-
when /\A\s+/
|
28
|
-
str = $'
|
29
|
-
when /\A\w+/
|
30
|
-
yield :ITEM, $&
|
31
|
-
str = $'
|
32
|
-
else
|
33
|
-
c = str[0,1]
|
34
|
-
yield c, c
|
35
|
-
str = str[1..-1]
|
36
|
-
end
|
37
|
-
end
|
38
|
-
yield false, '$' # is optional from Racc 1.3.7
|
39
|
-
end
|
40
|
-
|
41
|
-
def next_token
|
42
|
-
@q.shift
|
43
|
-
end
|
44
|
-
|
45
|
-
---- footer
|
46
|
-
|
47
|
-
if $0 == __FILE__
|
48
|
-
src = <<EOS
|
49
|
-
[
|
50
|
-
a, b, c,
|
51
|
-
d,
|
52
|
-
e ]
|
53
|
-
EOS
|
54
|
-
puts 'parsing:'
|
55
|
-
print src
|
56
|
-
puts
|
57
|
-
puts 'result:'
|
58
|
-
p ArrayParser2.new.parse(src)
|
59
|
-
end
|
data/sample/calc-ja.y
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# A simple calculator, version 2.
|
4
|
-
# This file contains Japanese characters (encoding=EUC-JP).
|
5
|
-
|
6
|
-
class Calculator2
|
7
|
-
prechigh
|
8
|
-
nonassoc UMINUS
|
9
|
-
left '*' '/'
|
10
|
-
left '+' '-'
|
11
|
-
preclow
|
12
|
-
options no_result_var
|
13
|
-
rule
|
14
|
-
target : exp
|
15
|
-
| /* none */ { 0 }
|
16
|
-
|
17
|
-
exp : exp '+' exp { val[0] + val[2] }
|
18
|
-
| exp '-' exp { val[0] - val[2] }
|
19
|
-
| exp '*' exp { val[0] * val[2] }
|
20
|
-
| exp '/' exp { val[0] / val[2] }
|
21
|
-
| '(' exp ')' { val[1] }
|
22
|
-
| '-' NUMBER =UMINUS { -(val[1]) }
|
23
|
-
| NUMBER
|
24
|
-
end
|
25
|
-
|
26
|
-
---- header
|
27
|
-
#
|
28
|
-
---- inner
|
29
|
-
|
30
|
-
def evaluate(str)
|
31
|
-
@tokens = []
|
32
|
-
until str.empty?
|
33
|
-
case str
|
34
|
-
when /\A\s+/
|
35
|
-
;
|
36
|
-
when /\A\d+/
|
37
|
-
@tokens.push [:NUMBER, $&.to_i]
|
38
|
-
when /\A.|\n/
|
39
|
-
s = $&
|
40
|
-
@tokens.push [s, s]
|
41
|
-
end
|
42
|
-
str = $'
|
43
|
-
end
|
44
|
-
@tokens.push [false, '$']
|
45
|
-
do_parse
|
46
|
-
end
|
47
|
-
|
48
|
-
def next_token
|
49
|
-
@tokens.shift
|
50
|
-
end
|
51
|
-
|
52
|
-
---- footer
|
53
|
-
|
54
|
-
puts 'Ķ������� 2 �浡'
|
55
|
-
puts 'Q �ǽ�λ���ޤ�'
|
56
|
-
calc = Calculator2.new
|
57
|
-
while true
|
58
|
-
print '>>> '; $stdout.flush
|
59
|
-
str = $stdin.gets.strip
|
60
|
-
break if /q/i =~ str
|
61
|
-
begin
|
62
|
-
p calc.evaluate(str)
|
63
|
-
rescue ParseError
|
64
|
-
puts 'parse error'
|
65
|
-
end
|
66
|
-
end
|
data/sample/calc.y
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Very simple calculater.
|
4
|
-
|
5
|
-
class Calcp
|
6
|
-
prechigh
|
7
|
-
nonassoc UMINUS
|
8
|
-
left '*' '/'
|
9
|
-
left '+' '-'
|
10
|
-
preclow
|
11
|
-
rule
|
12
|
-
target: exp
|
13
|
-
| /* none */ { result = 0 }
|
14
|
-
|
15
|
-
exp: exp '+' exp { result += val[2] }
|
16
|
-
| exp '-' exp { result -= val[2] }
|
17
|
-
| exp '*' exp { result *= val[2] }
|
18
|
-
| exp '/' exp { result /= val[2] }
|
19
|
-
| '(' exp ')' { result = val[1] }
|
20
|
-
| '-' NUMBER =UMINUS { result = -val[1] }
|
21
|
-
| NUMBER
|
22
|
-
end
|
23
|
-
|
24
|
-
---- header
|
25
|
-
#
|
26
|
-
---- inner
|
27
|
-
|
28
|
-
def parse(str)
|
29
|
-
@q = []
|
30
|
-
until str.empty?
|
31
|
-
case str
|
32
|
-
when /\A\s+/
|
33
|
-
when /\A\d+/
|
34
|
-
@q.push [:NUMBER, $&.to_i]
|
35
|
-
when /\A.|\n/o
|
36
|
-
s = $&
|
37
|
-
@q.push [s, s]
|
38
|
-
end
|
39
|
-
str = $'
|
40
|
-
end
|
41
|
-
@q.push [false, '$end']
|
42
|
-
do_parse
|
43
|
-
end
|
44
|
-
|
45
|
-
def next_token
|
46
|
-
@q.shift
|
47
|
-
end
|
48
|
-
|
49
|
-
---- footer
|
50
|
-
|
51
|
-
parser = Calcp.new
|
52
|
-
puts
|
53
|
-
puts 'type "Q" to quit.'
|
54
|
-
puts
|
55
|
-
while true
|
56
|
-
puts
|
57
|
-
print '? '
|
58
|
-
str = gets.chop!
|
59
|
-
break if /q/i =~ str
|
60
|
-
begin
|
61
|
-
puts "= #{parser.parse(str)}"
|
62
|
-
rescue ParseError
|
63
|
-
puts $!
|
64
|
-
end
|
65
|
-
end
|
data/sample/conflict.y
DELETED
data/sample/hash.y
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Converting Hash-like string into Ruby's Hash.
|
4
|
-
|
5
|
-
class HashParser
|
6
|
-
options no_result_var
|
7
|
-
rule
|
8
|
-
hash : '{' contents '}' { val[1] }
|
9
|
-
| '{' '}' { Hash.new }
|
10
|
-
|
11
|
-
# Racc can handle string over 2 bytes.
|
12
|
-
contents: IDENT '=>' IDENT { {val[0] => val[2]} }
|
13
|
-
| contents ',' IDENT '=>' IDENT { val[0][val[2]] = val[4]; val[0] }
|
14
|
-
end
|
15
|
-
|
16
|
-
---- inner
|
17
|
-
|
18
|
-
def parse(str)
|
19
|
-
@str = str
|
20
|
-
yyparse self, :scan
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def scan
|
26
|
-
str = @str
|
27
|
-
until str.empty?
|
28
|
-
case str
|
29
|
-
when /\A\s+/
|
30
|
-
str = $'
|
31
|
-
when /\A\w+/
|
32
|
-
yield :IDENT, $&
|
33
|
-
str = $'
|
34
|
-
when /\A=>/
|
35
|
-
yield '=>', '=>'
|
36
|
-
str = $'
|
37
|
-
else
|
38
|
-
c = str[0,1]
|
39
|
-
yield c, c
|
40
|
-
str = str[1..-1]
|
41
|
-
end
|
42
|
-
end
|
43
|
-
yield false, '$' # is optional from Racc 1.3.7
|
44
|
-
end
|
45
|
-
|
46
|
-
---- footer
|
47
|
-
|
48
|
-
if $0 == __FILE__
|
49
|
-
src = <<EOS
|
50
|
-
{
|
51
|
-
name => MyName,
|
52
|
-
id => MyIdent
|
53
|
-
}
|
54
|
-
EOS
|
55
|
-
puts 'Parsing (String):'
|
56
|
-
print src
|
57
|
-
puts
|
58
|
-
puts 'Result (Ruby Object):'
|
59
|
-
p HashParser.new.parse(src)
|
60
|
-
end
|
data/sample/lalr.y
DELETED
data/sample/lists.y
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Rules for verious lists.
|
4
|
-
# This file is just an example, you cannot compile this file.
|
5
|
-
|
6
|
-
class ExampleOnly
|
7
|
-
rule
|
8
|
-
|
9
|
-
# a list, which minimum number of items is 0
|
10
|
-
list0 :
|
11
|
-
{
|
12
|
-
result = []
|
13
|
-
}
|
14
|
-
| list0 item
|
15
|
-
{
|
16
|
-
result.push val[1]
|
17
|
-
}
|
18
|
-
|
19
|
-
# a list, which minimum number of items is 1
|
20
|
-
list1 : item
|
21
|
-
{
|
22
|
-
result = val
|
23
|
-
}
|
24
|
-
| list1 item
|
25
|
-
{
|
26
|
-
result.push val[1]
|
27
|
-
}
|
28
|
-
|
29
|
-
# a list, separated by comma
|
30
|
-
clist : item
|
31
|
-
{
|
32
|
-
result = val
|
33
|
-
}
|
34
|
-
| clist ',' item
|
35
|
-
{
|
36
|
-
result.push val[2]
|
37
|
-
}
|
38
|
-
|
39
|
-
# a hash. see also "hash.y".
|
40
|
-
hash : '{' hash_contents '}'
|
41
|
-
{
|
42
|
-
result = val[1]
|
43
|
-
}
|
44
|
-
| '{' '}'
|
45
|
-
{
|
46
|
-
result = {}
|
47
|
-
}
|
48
|
-
|
49
|
-
hash_contents
|
50
|
-
: item "=>" item
|
51
|
-
{
|
52
|
-
result = { val[0] => val[2] }
|
53
|
-
}
|
54
|
-
| hash_contents ',' item "=>" item
|
55
|
-
{
|
56
|
-
result[val[2]] = val[4]
|
57
|
-
}
|
data/sample/syntax.y
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Racc syntax checker. This grammer file generates
|
4
|
-
# invalid ruby program, you cannot run this parser.
|
5
|
-
|
6
|
-
class P
|
7
|
-
token A B C
|
8
|
-
|
9
|
-
convert
|
10
|
-
A '5'
|
11
|
-
end
|
12
|
-
|
13
|
-
prechigh
|
14
|
-
left B
|
15
|
-
preclow
|
16
|
-
|
17
|
-
options omit_action_call
|
18
|
-
|
19
|
-
start target
|
20
|
-
rule
|
21
|
-
target: A B C
|
22
|
-
{
|
23
|
-
print 'abc'
|
24
|
-
}
|
25
|
-
| B C A
|
26
|
-
| C B A
|
27
|
-
{
|
28
|
-
print 'cba'
|
29
|
-
}
|
30
|
-
| cont
|
31
|
-
|
32
|
-
cont : A c2 B c2 C
|
33
|
-
|
34
|
-
c2 : C C C C C
|
35
|
-
end
|
36
|
-
|
37
|
-
---- inner
|
38
|
-
|
39
|
-
junk code !!!!
|
40
|
-
|
41
|
-
kjaljlajrlaolanbla /// %%% (*((( token rule
|
42
|
-
akiurtlajluealjflaj @@@@ end end end end __END__
|
43
|
-
laieu2o879urkq96ga(Q#*&%Q#
|
44
|
-
#&lkji END
|
45
|
-
|
46
|
-
q395q?/// liutjqlkr7
|
data/sample/yyerr.y
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Test grammer file for error handling.
|
4
|
-
|
5
|
-
class A
|
6
|
-
rule
|
7
|
-
|
8
|
-
target: a b c
|
9
|
-
|
10
|
-
a :
|
11
|
-
{
|
12
|
-
yyerror
|
13
|
-
raise ArgumentError, "yyerror failed"
|
14
|
-
}
|
15
|
-
| error
|
16
|
-
|
17
|
-
b :
|
18
|
-
{
|
19
|
-
yyerrok
|
20
|
-
}
|
21
|
-
|
22
|
-
c :
|
23
|
-
{
|
24
|
-
yyaccept
|
25
|
-
raise "yyaccept failed"
|
26
|
-
}
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
---- inner
|
31
|
-
|
32
|
-
def parse
|
33
|
-
do_parse
|
34
|
-
end
|
35
|
-
|
36
|
-
def next_token
|
37
|
-
[false, '$end']
|
38
|
-
end
|
39
|
-
|
40
|
-
def on_error(*args)
|
41
|
-
$stderr.puts "on_error called: args=#{args.inspect}"
|
42
|
-
end
|
43
|
-
|
44
|
-
---- footer
|
45
|
-
|
46
|
-
A.new.parse
|
data/test/assets/cadenza.y
DELETED
@@ -1,170 +0,0 @@
|
|
1
|
-
# This grammar is released under an MIT license
|
2
|
-
# Author: William Howard (http://github.com/whoward)
|
3
|
-
# Source: https://github.com/whoward/cadenza/blob/master/src/cadenza.y
|
4
|
-
|
5
|
-
class Cadenza::RaccParser
|
6
|
-
|
7
|
-
/* expect this many shift/reduce conflicts */
|
8
|
-
expect 37
|
9
|
-
|
10
|
-
rule
|
11
|
-
target
|
12
|
-
: document
|
13
|
-
| /* none */ { result = nil }
|
14
|
-
;
|
15
|
-
|
16
|
-
parameter_list
|
17
|
-
: logical_expression { result = [val[0]] }
|
18
|
-
| parameter_list ',' logical_expression { result = val[0].push(val[2]) }
|
19
|
-
;
|
20
|
-
|
21
|
-
/* this has a shift/reduce conflict but since Racc will shift in this case it is the correct behavior */
|
22
|
-
primary_expression
|
23
|
-
: IDENTIFIER { result = VariableNode.new(val[0].value) }
|
24
|
-
| IDENTIFIER parameter_list { result = VariableNode.new(val[0].value, val[1]) }
|
25
|
-
| INTEGER { result = ConstantNode.new(val[0].value) }
|
26
|
-
| REAL { result = ConstantNode.new(val[0].value) }
|
27
|
-
| STRING { result = ConstantNode.new(val[0].value) }
|
28
|
-
| '(' filtered_expression ')' { result = val[1] }
|
29
|
-
;
|
30
|
-
|
31
|
-
multiplicative_expression
|
32
|
-
: primary_expression
|
33
|
-
| multiplicative_expression '*' primary_expression { result = OperationNode.new(val[0], "*", val[2]) }
|
34
|
-
| multiplicative_expression '/' primary_expression { result = OperationNode.new(val[0], "/", val[2]) }
|
35
|
-
;
|
36
|
-
|
37
|
-
additive_expression
|
38
|
-
: multiplicative_expression
|
39
|
-
| additive_expression '+' multiplicative_expression { result = OperationNode.new(val[0], "+", val[2]) }
|
40
|
-
| additive_expression '-' multiplicative_expression { result = OperationNode.new(val[0], "-", val[2]) }
|
41
|
-
;
|
42
|
-
|
43
|
-
boolean_expression
|
44
|
-
: additive_expression
|
45
|
-
| boolean_expression OP_EQ additive_expression { result = OperationNode.new(val[0], "==", val[2]) }
|
46
|
-
| boolean_expression OP_NEQ additive_expression { result = OperationNode.new(val[0], "!=", val[2]) }
|
47
|
-
| boolean_expression OP_LEQ additive_expression { result = OperationNode.new(val[0], "<=", val[2]) }
|
48
|
-
| boolean_expression OP_GEQ additive_expression { result = OperationNode.new(val[0], ">=", val[2]) }
|
49
|
-
| boolean_expression '>' additive_expression { result = OperationNode.new(val[0], ">", val[2]) }
|
50
|
-
| boolean_expression '<' additive_expression { result = OperationNode.new(val[0], "<", val[2]) }
|
51
|
-
;
|
52
|
-
|
53
|
-
inverse_expression
|
54
|
-
: boolean_expression
|
55
|
-
| NOT boolean_expression { result = BooleanInverseNode.new(val[1]) }
|
56
|
-
;
|
57
|
-
|
58
|
-
logical_expression
|
59
|
-
: inverse_expression
|
60
|
-
| logical_expression AND inverse_expression { result = OperationNode.new(val[0], "and", val[2]) }
|
61
|
-
| logical_expression OR inverse_expression { result = OperationNode.new(val[0], "or", val[2]) }
|
62
|
-
;
|
63
|
-
|
64
|
-
filter
|
65
|
-
: IDENTIFIER { result = FilterNode.new(val[0].value) }
|
66
|
-
| IDENTIFIER ':' parameter_list { result = FilterNode.new(val[0].value, val[2]) }
|
67
|
-
;
|
68
|
-
|
69
|
-
filter_list
|
70
|
-
: filter { result = [val[0]] }
|
71
|
-
| filter_list '|' filter { result = val[0].push(val[2]) }
|
72
|
-
;
|
73
|
-
|
74
|
-
filtered_expression
|
75
|
-
: logical_expression
|
76
|
-
| logical_expression '|' filter_list { result = FilteredValueNode.new(val[0], val[2]) }
|
77
|
-
;
|
78
|
-
|
79
|
-
inject_statement
|
80
|
-
: VAR_OPEN filtered_expression VAR_CLOSE { result = val[1] }
|
81
|
-
;
|
82
|
-
|
83
|
-
if_tag
|
84
|
-
: STMT_OPEN IF logical_expression STMT_CLOSE { open_scope!; result = val[2] }
|
85
|
-
| STMT_OPEN UNLESS logical_expression STMT_CLOSE { open_scope!; result = BooleanInverseNode.new(val[2]) }
|
86
|
-
;
|
87
|
-
|
88
|
-
else_tag
|
89
|
-
: STMT_OPEN ELSE STMT_CLOSE { result = close_scope!; open_scope! }
|
90
|
-
;
|
91
|
-
|
92
|
-
end_if_tag
|
93
|
-
: STMT_OPEN ENDIF STMT_CLOSE { result = close_scope! }
|
94
|
-
| STMT_OPEN ENDUNLESS STMT_CLOSE { result = close_scope! }
|
95
|
-
;
|
96
|
-
|
97
|
-
if_block
|
98
|
-
: if_tag end_if_tag { result = IfNode.new(val[0], val[1]) }
|
99
|
-
| if_tag document end_if_tag { result = IfNode.new(val[0], val[2]) }
|
100
|
-
| if_tag else_tag document end_if_tag { result = IfNode.new(val[0], val[1], val[3]) }
|
101
|
-
| if_tag document else_tag end_if_tag { result = IfNode.new(val[0], val[2], val[3]) }
|
102
|
-
| if_tag document else_tag document end_if_tag { result = IfNode.new(val[0], val[2], val[4]) }
|
103
|
-
;
|
104
|
-
|
105
|
-
for_tag
|
106
|
-
: STMT_OPEN FOR IDENTIFIER IN filtered_expression STMT_CLOSE { open_scope!; result = [val[2].value, val[4]] }
|
107
|
-
;
|
108
|
-
|
109
|
-
end_for_tag
|
110
|
-
: STMT_OPEN ENDFOR STMT_CLOSE { result = close_scope! }
|
111
|
-
;
|
112
|
-
|
113
|
-
/* this has a shift/reduce conflict but since Racc will shift in this case it is the correct behavior */
|
114
|
-
for_block
|
115
|
-
: for_tag end_for_tag { result = ForNode.new(VariableNode.new(val[0].first), val[0].last, val[1]) }
|
116
|
-
| for_tag document end_for_tag { result = ForNode.new(VariableNode.new(val[0].first), val[0].last, val[2]) }
|
117
|
-
;
|
118
|
-
|
119
|
-
block_tag
|
120
|
-
: STMT_OPEN BLOCK IDENTIFIER STMT_CLOSE { result = open_block_scope!(val[2].value) }
|
121
|
-
;
|
122
|
-
|
123
|
-
end_block_tag
|
124
|
-
: STMT_OPEN ENDBLOCK STMT_CLOSE { result = close_block_scope! }
|
125
|
-
;
|
126
|
-
|
127
|
-
/* this has a shift/reduce conflict but since Racc will shift in this case it is the correct behavior */
|
128
|
-
block_block
|
129
|
-
: block_tag end_block_tag { result = BlockNode.new(val[0], val[1]) }
|
130
|
-
| block_tag document end_block_tag { result = BlockNode.new(val[0], val[2]) }
|
131
|
-
;
|
132
|
-
|
133
|
-
generic_block_tag
|
134
|
-
: STMT_OPEN IDENTIFIER STMT_CLOSE { open_scope!; result = [val[1].value, []] }
|
135
|
-
| STMT_OPEN IDENTIFIER parameter_list STMT_CLOSE { open_scope!; result = [val[1].value, val[2]] }
|
136
|
-
;
|
137
|
-
|
138
|
-
end_generic_block_tag
|
139
|
-
: STMT_OPEN END STMT_CLOSE { result = close_scope! }
|
140
|
-
;
|
141
|
-
|
142
|
-
generic_block
|
143
|
-
: generic_block_tag document end_generic_block_tag { result = GenericBlockNode.new(val[0].first, val[2], val[0].last) }
|
144
|
-
;
|
145
|
-
|
146
|
-
extends_statement
|
147
|
-
: STMT_OPEN EXTENDS STRING STMT_CLOSE { result = val[2].value }
|
148
|
-
| STMT_OPEN EXTENDS IDENTIFIER STMT_CLOSE { result = VariableNode.new(val[2].value) }
|
149
|
-
;
|
150
|
-
|
151
|
-
document_component
|
152
|
-
: TEXT_BLOCK { result = TextNode.new(val[0].value) }
|
153
|
-
| inject_statement
|
154
|
-
| if_block
|
155
|
-
| for_block
|
156
|
-
| generic_block
|
157
|
-
| block_block
|
158
|
-
;
|
159
|
-
|
160
|
-
document
|
161
|
-
: document_component { push val[0] }
|
162
|
-
| document document_component { push val[1] }
|
163
|
-
| extends_statement { document.extends = val[0] }
|
164
|
-
| document extends_statement { document.extends = val[1] }
|
165
|
-
;
|
166
|
-
|
167
|
-
---- header ----
|
168
|
-
# racc_parser.rb : generated by racc
|
169
|
-
|
170
|
-
---- inner ----
|