cadenza 0.7.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,20 @@
1
+ module Cadenza
2
+
3
+ class BlockNode
4
+ attr_accessor :name, :children
5
+
6
+ def initialize(name, children)
7
+ @name = name
8
+ @children = children
9
+ end
10
+
11
+ def implied_globals
12
+ @children.map(&:implied_globals).flatten.uniq
13
+ end
14
+
15
+ def ==(rhs)
16
+ @name == rhs.name and
17
+ @children == rhs.children
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,17 @@
1
+ module Cadenza
2
+ class BooleanInverseNode
3
+ attr_accessor :expression
4
+
5
+ def initialize(expression)
6
+ @expression = expression
7
+ end
8
+
9
+ def ==(rhs)
10
+ @expression == rhs.expression
11
+ end
12
+
13
+ def eval(context)
14
+ !@expression.eval(context)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,21 @@
1
+ module Cadenza
2
+ class ConstantNode
3
+ attr_accessor :value
4
+
5
+ def initialize(value)
6
+ @value = value
7
+ end
8
+
9
+ def implied_globals
10
+ []
11
+ end
12
+
13
+ def eval(context)
14
+ @value
15
+ end
16
+
17
+ def ==(rhs)
18
+ @value == rhs.value
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,27 @@
1
+ module Cadenza
2
+ class DocumentNode
3
+ attr_accessor :extends
4
+ attr_accessor :children
5
+ attr_accessor :blocks
6
+
7
+ def initialize(children=[])
8
+ @children = children
9
+ @blocks = {}
10
+ end
11
+
12
+ def ==(rhs)
13
+ @children == rhs.children and
14
+ @extends == rhs.extends and
15
+ @blocks == rhs.blocks
16
+ end
17
+
18
+ def add_block(block)
19
+ @blocks[block.name] = block
20
+ end
21
+
22
+ def implied_globals
23
+ @children.map(&:implied_globals).flatten.uniq
24
+ end
25
+
26
+ end
27
+ end
@@ -0,0 +1,25 @@
1
+
2
+ module Cadenza
3
+ class FilterNode
4
+ attr_accessor :identifier, :parameters
5
+
6
+ def initialize(identifier, parameters=[])
7
+ @identifier = identifier
8
+ @parameters = parameters
9
+ end
10
+
11
+ def ==(rhs)
12
+ @identifier == rhs.identifier and
13
+ @parameters == rhs.parameters
14
+ end
15
+
16
+ def implied_globals
17
+ @parameters.map(&:implied_globals).flatten.uniq
18
+ end
19
+
20
+ def evaluate(context, value)
21
+ params = [value] + @parameters.map {|x| x.eval(context) }
22
+ context.evaluate_filter(@identifier, params)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,37 @@
1
+ module Cadenza
2
+ class ForNode
3
+ attr_accessor :iterator, :iterable, :children
4
+
5
+ MAGIC_LOCALS = %w(forloop.counter forloop.counter0 forloop.first forloop.last)
6
+
7
+ def initialize(iterator, iterable, children)
8
+ @iterator = iterator
9
+ @iterable = iterable
10
+ @children = children
11
+ end
12
+
13
+ def implied_globals
14
+ iterable_globals = @iterable.implied_globals
15
+ iterator_globals = @iterator.implied_globals
16
+
17
+ iterator_regex = Regexp.new("^#{@iterator.identifier}[\.](.+)$")
18
+
19
+ all_children_globals = @children.map(&:implied_globals).flatten
20
+
21
+ children_globals = all_children_globals.reject {|x| x =~ iterator_regex }
22
+
23
+ iterator_children_globals = all_children_globals.select {|x| x =~ iterator_regex }.map do |identifier|
24
+ "#{iterable.identifier}.#{iterator_regex.match(identifier)[1]}"
25
+ end
26
+
27
+ (iterable_globals | children_globals | iterator_children_globals) - MAGIC_LOCALS - iterator_globals
28
+ end
29
+
30
+ def ==(rhs)
31
+ @iterator == rhs.iterator and
32
+ @iterable == rhs.iterable and
33
+ @children == rhs.children
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,21 @@
1
+ module Cadenza
2
+ class GenericBlockNode
3
+ attr_accessor :identifier, :children, :parameters
4
+
5
+ def initialize(identifier, children, parameters=[])
6
+ @identifier = identifier
7
+ @children = children
8
+ @parameters = parameters
9
+ end
10
+
11
+ def implied_globals
12
+ []
13
+ end
14
+
15
+ def ==(rhs)
16
+ @identifier == rhs.identifier and
17
+ @children == rhs.children and
18
+ @parameters == rhs.parameters
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,42 @@
1
+ module Cadenza
2
+ class IfNode
3
+ attr_accessor :expression, :true_children, :false_children
4
+
5
+ def initialize(expression, true_children=[], false_children=[])
6
+ @expression = expression
7
+ @true_children = true_children
8
+ @false_children = false_children
9
+ end
10
+
11
+ def implied_globals
12
+ (@expression.implied_globals + true_children.map(&:implied_globals).flatten + false_children.map(&:implied_globals).flatten).uniq
13
+ end
14
+
15
+ def evaluate_expression_for_children(context)
16
+ value = @expression.eval(context)
17
+
18
+ if value == true
19
+ return @true_children
20
+
21
+ elsif value == false
22
+ return @false_children
23
+
24
+ elsif value.is_a?(String)
25
+ return value.length == 0 || value =~ /\s+/ ? @false_children : @true_children
26
+
27
+ elsif value.is_a?(Float) or value.is_a?(Fixnum)
28
+ return value == 0 ? @false_children : @true_children
29
+
30
+ else
31
+ return !!value ? @true_children : @false_children
32
+
33
+ end
34
+ end
35
+
36
+ def ==(rhs)
37
+ @expression == rhs.expression and
38
+ @true_children == rhs.true_children and
39
+ @false_children == rhs.false_children
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,34 @@
1
+ module Cadenza
2
+ class InjectNode
3
+ attr_accessor :value, :filters, :parameters
4
+
5
+ def initialize(value, filters=[], parameters=[])
6
+ @value = value
7
+ @filters = filters
8
+ @parameters = parameters
9
+ end
10
+
11
+ def ==(rhs)
12
+ self.value == rhs.value and
13
+ self.filters == rhs.filters and
14
+ self.parameters == rhs.parameters
15
+ end
16
+
17
+ def implied_globals
18
+ (@value.implied_globals + @filters.map(&:implied_globals).flatten).uniq
19
+ end
20
+
21
+ def evaluate(context)
22
+ value = @value.eval(context)
23
+
24
+ if value.is_a? Proc
25
+ args = parameters.map {|p| p.eval(context) }
26
+ value = value.call(context, *args)
27
+ end
28
+
29
+ @filters.each {|filter| value = filter.evaluate(context, value) }
30
+
31
+ value
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,66 @@
1
+ module Cadenza
2
+ class OperationNode
3
+ attr_accessor :left, :right, :operator
4
+
5
+ def initialize(left, operator, right)
6
+ @left = left
7
+ @right = right
8
+ @operator = operator
9
+ end
10
+
11
+ def implied_globals
12
+ @left.implied_globals | @right.implied_globals
13
+ end
14
+
15
+ def eval(context)
16
+ l = @left.eval(context)
17
+ r = @right.eval(context)
18
+
19
+ case @operator
20
+ when '=='
21
+ return l == r
22
+
23
+ when '!='
24
+ return l != r
25
+
26
+ when '>='
27
+ return l >= r
28
+
29
+ when '<='
30
+ return l <= r
31
+
32
+ when '>'
33
+ return l > r
34
+
35
+ when '<'
36
+ return l < r
37
+
38
+ when 'and'
39
+ return l && r
40
+
41
+ when 'or'
42
+ return l || r
43
+
44
+ when '+'
45
+ return l + r
46
+
47
+ when '-'
48
+ return l - r
49
+
50
+ when '*'
51
+ return l * r
52
+
53
+ when '/'
54
+ return l / r
55
+
56
+ else throw "undefined operator: #{@operator}"
57
+ end
58
+ end
59
+
60
+ def ==(rhs)
61
+ @operator == rhs.operator and
62
+ @left == rhs.left and
63
+ @right == rhs.right
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,17 @@
1
+ module Cadenza
2
+ class TextNode
3
+ attr_accessor :text
4
+
5
+ def initialize(text)
6
+ @text = text
7
+ end
8
+
9
+ def implied_globals
10
+ []
11
+ end
12
+
13
+ def ==(rhs)
14
+ @text == rhs.text
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,21 @@
1
+ module Cadenza
2
+ class VariableNode
3
+ attr_accessor :identifier
4
+
5
+ def initialize(identifier)
6
+ @identifier = identifier
7
+ end
8
+
9
+ def implied_globals
10
+ [self.identifier]
11
+ end
12
+
13
+ def eval(context)
14
+ context.lookup(@identifier)
15
+ end
16
+
17
+ def ==(rhs)
18
+ self.identifier == rhs.identifier
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,942 @@
1
+ #
2
+ # DO NOT MODIFY!!!!
3
+ # This file is automatically generated by Racc 1.4.7
4
+ # from Racc grammer file "".
5
+ #
6
+
7
+ require 'racc/parser.rb'
8
+
9
+ # parser.rb : generated by racc
10
+
11
+ module Cadenza
12
+ class Parser < Racc::Parser
13
+
14
+ module_eval(<<'...end cadenza.y/module_eval...', 'cadenza.y', 229)
15
+ attr_reader :lexer
16
+
17
+ def initialize(options={})
18
+ @lexer = options.fetch(:lexer, Cadenza::Lexer.new)
19
+
20
+ raise "Lexers passed to the parser must define next_token" unless @lexer.respond_to?(:next_token)
21
+
22
+ raise "Lexers passed to the parser must define source=" unless @lexer.respond_to?(:source=)
23
+ end
24
+
25
+ def parse(source)
26
+ @lexer.source = source
27
+
28
+ @stack = [DocumentNode.new]
29
+
30
+ do_parse
31
+
32
+ @stack.first
33
+ end
34
+
35
+ def push_child(node)
36
+ @stack.last.children.push(node)
37
+ end
38
+
39
+ def push_block(block_node)
40
+ @stack.first.add_block(block_node)
41
+ push_child(block_node)
42
+ end
43
+
44
+ def next_token
45
+ @lexer.next_token
46
+ end
47
+ ...end cadenza.y/module_eval...
48
+ ##### State transition tables begin ###
49
+
50
+ racc_action_table = [
51
+ 38, 3, 111, 4, 3, 38, 4, 55, 23, 24,
52
+ 25, 26, 3, 38, 154, 70, 71, 9, 38, 95,
53
+ 9, 70, 71, 31, 115, 34, 118, 35, 9, 38,
54
+ 34, 36, 35, 79, 37, 93, 36, 39, 34, 37,
55
+ 35, 157, 39, 34, 36, 35, 82, 37, 87, 36,
56
+ 39, 38, 37, 93, 34, 39, 35, 82, 83, 3,
57
+ 36, 155, 38, 37, 136, 3, 39, 129, 70, 71,
58
+ 38, 81, 70, 71, 80, 9, 34, 114, 35, 59,
59
+ 60, 9, 36, 38, 91, 37, 141, 34, 39, 35,
60
+ 61, 62, 87, 36, 133, 34, 37, 35, 144, 39,
61
+ 3, 36, 44, 3, 37, 124, 156, 39, 34, 95,
62
+ 35, 97, 83, 96, 36, 91, 9, 37, 128, 9,
63
+ 39, 55, 23, 24, 25, 26, 55, 23, 24, 25,
64
+ 26, 55, 23, 24, 25, 26, 142, 31, 143, 142,
65
+ 77, 149, 31, 3, 3, 40, 40, 31, 55, 23,
66
+ 24, 25, 26, 55, 23, 24, 25, 26, 76, 9,
67
+ 9, 3, 123, 4, 31, 3, 3, 4, 4, 31,
68
+ 22, 23, 24, 25, 26, 122, 3, 9, 4, 61,
69
+ 62, 9, 9, 3, 121, 4, 31, 55, 23, 24,
70
+ 25, 26, 9, 55, 23, 24, 25, 26, 3, 9,
71
+ 4, 120, 3, 31, 137, 3, 117, 134, 116, 31,
72
+ 111, 3, 152, 129, 9, 3, 111, 129, 9, 61,
73
+ 62, 9, 55, 23, 24, 25, 26, 9, 3, 98,
74
+ 124, 9, 3, 3, 124, 44, 61, 62, 31, 70,
75
+ 71, 70, 71, 73, 9, 72, 59, 60, 9, 9,
76
+ 63, 64, 65, 66, 67, 68, 63, 64, 65, 66,
77
+ 67, 68, 55, 23, 24, 25, 26, 55, 23, 24,
78
+ 25, 26, 55, 23, 24, 25, 26, 55, 23, 24,
79
+ 25, 26, 55, 23, 24, 25, 26, 55, 23, 24,
80
+ 25, 26, 55, 23, 24, 25, 26, 55, 23, 24,
81
+ 25, 26, 55, 23, 24, 25, 26, 55, 23, 24,
82
+ 25, 26, 55, 23, 24, 25, 26, 59, 60, 61,
83
+ 62, 61, 62, 61, 62, 54, 95, 51, 48, 18,
84
+ 158, 159 ]
85
+
86
+ racc_action_check = [
87
+ 137, 0, 97, 0, 145, 155, 145, 38, 38, 38,
88
+ 38, 38, 146, 4, 146, 75, 75, 0, 44, 78,
89
+ 145, 56, 56, 38, 75, 137, 78, 137, 146, 40,
90
+ 155, 137, 155, 38, 137, 137, 155, 137, 4, 155,
91
+ 4, 155, 155, 44, 4, 44, 44, 4, 44, 44,
92
+ 4, 134, 44, 51, 40, 44, 40, 40, 40, 153,
93
+ 40, 153, 129, 40, 93, 131, 40, 131, 74, 74,
94
+ 154, 39, 139, 139, 39, 153, 134, 74, 134, 28,
95
+ 28, 131, 134, 124, 134, 134, 111, 129, 134, 129,
96
+ 108, 108, 129, 129, 91, 154, 129, 154, 116, 129,
97
+ 6, 154, 6, 126, 154, 126, 154, 154, 124, 57,
98
+ 124, 57, 124, 57, 124, 48, 6, 124, 87, 126,
99
+ 124, 26, 26, 26, 26, 26, 141, 141, 141, 141,
100
+ 141, 34, 34, 34, 34, 34, 113, 26, 113, 140,
101
+ 37, 140, 141, 5, 42, 5, 42, 34, 35, 35,
102
+ 35, 35, 35, 22, 22, 22, 22, 22, 36, 5,
103
+ 42, 43, 83, 43, 35, 2, 47, 2, 47, 22,
104
+ 3, 3, 3, 3, 3, 82, 119, 43, 119, 29,
105
+ 29, 2, 47, 50, 81, 50, 3, 70, 70, 70,
106
+ 70, 70, 119, 95, 95, 95, 95, 95, 53, 50,
107
+ 53, 80, 94, 70, 94, 92, 77, 92, 76, 95,
108
+ 142, 90, 144, 90, 53, 89, 73, 89, 94, 107,
109
+ 107, 92, 71, 71, 71, 71, 71, 90, 86, 58,
110
+ 86, 89, 85, 46, 85, 46, 106, 106, 71, 33,
111
+ 33, 58, 58, 33, 86, 33, 101, 101, 85, 46,
112
+ 30, 30, 30, 30, 30, 30, 69, 69, 69, 69,
113
+ 69, 69, 63, 63, 63, 63, 63, 64, 64, 64,
114
+ 64, 64, 65, 65, 65, 65, 65, 59, 59, 59,
115
+ 59, 59, 60, 60, 60, 60, 60, 66, 66, 66,
116
+ 66, 66, 61, 61, 61, 61, 61, 68, 68, 68,
117
+ 68, 68, 31, 31, 31, 31, 31, 67, 67, 67,
118
+ 67, 67, 62, 62, 62, 62, 62, 102, 102, 105,
119
+ 105, 104, 104, 103, 103, 18, 150, 8, 7, 1,
120
+ 156, 157 ]
121
+
122
+ racc_action_pointer = [
123
+ -23, 329, 141, 168, 11, 119, 76, 302, 301, nil,
124
+ nil, nil, nil, nil, nil, nil, nil, nil, 325, nil,
125
+ nil, nil, 151, nil, nil, nil, 119, nil, 71, 169,
126
+ 238, 300, nil, 220, 129, 146, 156, 138, 5, 69,
127
+ 27, nil, 120, 137, 16, nil, 209, 142, 80, nil,
128
+ 159, 16, nil, 174, nil, nil, 2, 88, 222, 275,
129
+ 280, 290, 310, 260, 265, 270, 285, 305, 295, 244,
130
+ 185, 220, nil, 214, 49, -4, 174, 178, -2, nil,
131
+ 173, 156, 147, 134, nil, 208, 204, 90, nil, 191,
132
+ 187, 66, 181, 36, 178, 191, nil, 0, nil, nil,
133
+ nil, 238, 309, 313, 311, 309, 226, 209, 80, nil,
134
+ nil, 64, nil, 113, nil, nil, 96, nil, nil, 152,
135
+ nil, nil, nil, nil, 81, nil, 79, nil, nil, 60,
136
+ nil, 41, nil, nil, 49, nil, nil, -2, nil, 53,
137
+ 116, 124, 208, nil, 184, -20, -12, nil, nil, nil,
138
+ 305, nil, nil, 35, 68, 3, 302, 303, nil, nil ]
139
+
140
+ racc_action_default = [
141
+ -2, -79, -1, -79, -79, -79, -79, -54, -59, -67,
142
+ -68, -69, -70, -71, -72, -73, -75, -77, -79, -74,
143
+ -76, -78, -3, -4, -5, -6, -79, -8, -11, -14,
144
+ -21, -79, -23, -79, -79, -79, -79, -79, -79, -79,
145
+ -79, -41, -79, -79, -79, -46, -79, -79, -79, -53,
146
+ -79, -79, -58, -79, 160, -3, -26, -79, -79, -79,
147
+ -79, -79, -79, -79, -79, -79, -79, -79, -79, -22,
148
+ -79, -79, -32, -79, -79, -79, -79, -79, -79, -61,
149
+ -79, -79, -79, -79, -42, -79, -79, -79, -47, -79,
150
+ -79, -79, -79, -79, -79, -79, -34, -79, -7, -9,
151
+ -10, -12, -13, -15, -16, -17, -18, -19, -20, -24,
152
+ -25, -28, -30, -79, -36, -37, -79, -56, -63, -79,
153
+ -65, -66, -38, -39, -79, -44, -79, -43, -40, -79,
154
+ -49, -79, -48, -52, -79, -55, -57, -79, -60, -27,
155
+ -79, -79, -79, -33, -79, -79, -79, -45, -50, -35,
156
+ -29, -31, -51, -79, -79, -79, -79, -79, -62, -64 ]
157
+
158
+ racc_goto_table = [
159
+ 19, 21, 41, 45, 33, 43, 47, 57, 113, 52,
160
+ 20, 50, 2, 69, 49, 99, 100, 42, 46, 109,
161
+ 110, 101, 102, 78, 53, 119, 145, 58, 151, 1,
162
+ nil, nil, 140, nil, nil, 74, 75, nil, nil, 84,
163
+ 19, 21, 85, 88, 19, 21, 89, nil, nil, nil,
164
+ 20, nil, nil, nil, 20, 86, nil, nil, nil, 90,
165
+ nil, nil, 92, nil, nil, 94, 103, 104, 105, 106,
166
+ 107, 108, nil, nil, nil, nil, nil, nil, nil, nil,
167
+ nil, nil, 125, 127, 19, 21, 130, 132, 19, 21,
168
+ 19, 21, 19, 21, 20, 138, 139, 126, 20, 135,
169
+ 20, 131, 20, nil, nil, nil, nil, nil, nil, nil,
170
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
171
+ nil, nil, nil, 147, 19, 21, 150, nil, 148, 19,
172
+ 21, 146, nil, nil, 20, nil, nil, nil, nil, 20,
173
+ nil, nil, nil, nil, 19, 21, nil, nil, nil, nil,
174
+ nil, 19, 21, nil, 20, nil, nil, 153, nil, nil,
175
+ nil, 20 ]
176
+
177
+ racc_goto_check = [
178
+ 32, 26, 16, 17, 4, 15, 15, 9, 11, 25,
179
+ 31, 23, 2, 7, 21, 3, 3, 2, 2, 8,
180
+ 8, 5, 5, 9, 27, 29, 30, 4, 10, 1,
181
+ nil, nil, 11, nil, nil, 4, 4, nil, nil, 16,
182
+ 32, 26, 15, 17, 32, 26, 15, nil, nil, nil,
183
+ 31, nil, nil, nil, 31, 2, nil, nil, nil, 2,
184
+ nil, nil, 2, nil, nil, 2, 6, 6, 6, 6,
185
+ 6, 6, nil, nil, nil, nil, nil, nil, nil, nil,
186
+ nil, nil, 16, 16, 32, 26, 17, 17, 32, 26,
187
+ 32, 26, 32, 26, 31, 25, 4, 2, 31, 21,
188
+ 31, 2, 31, nil, nil, nil, nil, nil, nil, nil,
189
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
190
+ nil, nil, nil, 16, 32, 26, 9, nil, 17, 32,
191
+ 26, 2, nil, nil, 31, nil, nil, nil, nil, 31,
192
+ nil, nil, nil, nil, 32, 26, nil, nil, nil, nil,
193
+ nil, 32, 26, nil, 31, nil, nil, 2, nil, nil,
194
+ nil, 31 ]
195
+
196
+ racc_goto_pointer = [
197
+ nil, 29, 12, -44, 1, -40, 3, -18, -51, -15,
198
+ -114, -65, nil, nil, nil, 0, -3, -3, nil, nil,
199
+ nil, 7, nil, 4, nil, 1, -1, 16, nil, -54,
200
+ -92, 8, -2 ]
201
+
202
+ racc_goto_default = [
203
+ nil, nil, nil, 27, 56, 28, 29, 30, 32, nil,
204
+ 112, nil, 10, 5, 6, nil, nil, nil, 11, 12,
205
+ 7, nil, 13, nil, 8, nil, 17, nil, 14, nil,
206
+ nil, 16, 15 ]
207
+
208
+ racc_reduce_table = [
209
+ 0, 0, :racc_error,
210
+ 1, 42, :_reduce_none,
211
+ 0, 42, :_reduce_2,
212
+ 1, 44, :_reduce_3,
213
+ 1, 44, :_reduce_4,
214
+ 1, 44, :_reduce_5,
215
+ 1, 44, :_reduce_6,
216
+ 3, 44, :_reduce_7,
217
+ 1, 46, :_reduce_none,
218
+ 3, 46, :_reduce_9,
219
+ 3, 46, :_reduce_10,
220
+ 1, 47, :_reduce_none,
221
+ 3, 47, :_reduce_12,
222
+ 3, 47, :_reduce_13,
223
+ 1, 48, :_reduce_none,
224
+ 3, 48, :_reduce_15,
225
+ 3, 48, :_reduce_16,
226
+ 3, 48, :_reduce_17,
227
+ 3, 48, :_reduce_18,
228
+ 3, 48, :_reduce_19,
229
+ 3, 48, :_reduce_20,
230
+ 1, 49, :_reduce_none,
231
+ 2, 49, :_reduce_22,
232
+ 1, 45, :_reduce_none,
233
+ 3, 45, :_reduce_24,
234
+ 3, 45, :_reduce_25,
235
+ 1, 50, :_reduce_26,
236
+ 3, 50, :_reduce_27,
237
+ 1, 51, :_reduce_28,
238
+ 3, 51, :_reduce_29,
239
+ 1, 52, :_reduce_30,
240
+ 3, 52, :_reduce_31,
241
+ 3, 53, :_reduce_32,
242
+ 5, 53, :_reduce_33,
243
+ 4, 53, :_reduce_34,
244
+ 6, 53, :_reduce_35,
245
+ 4, 54, :_reduce_36,
246
+ 4, 55, :_reduce_37,
247
+ 3, 56, :_reduce_38,
248
+ 3, 57, :_reduce_none,
249
+ 3, 58, :_reduce_none,
250
+ 2, 59, :_reduce_41,
251
+ 3, 59, :_reduce_42,
252
+ 4, 59, :_reduce_43,
253
+ 4, 59, :_reduce_44,
254
+ 5, 59, :_reduce_45,
255
+ 2, 60, :_reduce_46,
256
+ 3, 60, :_reduce_47,
257
+ 4, 60, :_reduce_48,
258
+ 4, 60, :_reduce_49,
259
+ 5, 60, :_reduce_50,
260
+ 6, 61, :_reduce_51,
261
+ 3, 62, :_reduce_none,
262
+ 2, 63, :_reduce_53,
263
+ 0, 64, :_reduce_54,
264
+ 4, 63, :_reduce_55,
265
+ 4, 65, :_reduce_56,
266
+ 3, 66, :_reduce_none,
267
+ 2, 67, :_reduce_58,
268
+ 0, 68, :_reduce_59,
269
+ 4, 67, :_reduce_60,
270
+ 0, 70, :_reduce_61,
271
+ 8, 69, :_reduce_62,
272
+ 0, 71, :_reduce_63,
273
+ 9, 69, :_reduce_64,
274
+ 4, 72, :_reduce_65,
275
+ 4, 72, :_reduce_66,
276
+ 1, 73, :_reduce_67,
277
+ 1, 73, :_reduce_none,
278
+ 1, 73, :_reduce_none,
279
+ 1, 73, :_reduce_none,
280
+ 1, 73, :_reduce_none,
281
+ 1, 73, :_reduce_none,
282
+ 1, 43, :_reduce_73,
283
+ 2, 43, :_reduce_74,
284
+ 1, 43, :_reduce_75,
285
+ 2, 43, :_reduce_76,
286
+ 1, 43, :_reduce_77,
287
+ 2, 43, :_reduce_78 ]
288
+
289
+ racc_reduce_n = 79
290
+
291
+ racc_shift_n = 160
292
+
293
+ racc_token_table = {
294
+ false => 0,
295
+ :error => 1,
296
+ :IDENTIFIER => 2,
297
+ :INTEGER => 3,
298
+ :REAL => 4,
299
+ :STRING => 5,
300
+ "(" => 6,
301
+ ")" => 7,
302
+ "*" => 8,
303
+ "/" => 9,
304
+ "+" => 10,
305
+ "-" => 11,
306
+ :OP_EQ => 12,
307
+ :OP_NEQ => 13,
308
+ :OP_LEQ => 14,
309
+ :OP_GEQ => 15,
310
+ ">" => 16,
311
+ "<" => 17,
312
+ :NOT => 18,
313
+ :AND => 19,
314
+ :OR => 20,
315
+ "," => 21,
316
+ ":" => 22,
317
+ "|" => 23,
318
+ :VAR_OPEN => 24,
319
+ :VAR_CLOSE => 25,
320
+ :STMT_OPEN => 26,
321
+ :IF => 27,
322
+ :STMT_CLOSE => 28,
323
+ :UNLESS => 29,
324
+ :ELSE => 30,
325
+ :ENDIF => 31,
326
+ :ENDUNLESS => 32,
327
+ :FOR => 33,
328
+ :IN => 34,
329
+ :ENDFOR => 35,
330
+ :BLOCK => 36,
331
+ :ENDBLOCK => 37,
332
+ :END => 38,
333
+ :EXTENDS => 39,
334
+ :TEXT_BLOCK => 40 }
335
+
336
+ racc_nt_base = 41
337
+
338
+ racc_use_result_var = true
339
+
340
+ Racc_arg = [
341
+ racc_action_table,
342
+ racc_action_check,
343
+ racc_action_default,
344
+ racc_action_pointer,
345
+ racc_goto_table,
346
+ racc_goto_check,
347
+ racc_goto_default,
348
+ racc_goto_pointer,
349
+ racc_nt_base,
350
+ racc_reduce_table,
351
+ racc_token_table,
352
+ racc_shift_n,
353
+ racc_reduce_n,
354
+ racc_use_result_var ]
355
+
356
+ Racc_token_to_s_table = [
357
+ "$end",
358
+ "error",
359
+ "IDENTIFIER",
360
+ "INTEGER",
361
+ "REAL",
362
+ "STRING",
363
+ "\"(\"",
364
+ "\")\"",
365
+ "\"*\"",
366
+ "\"/\"",
367
+ "\"+\"",
368
+ "\"-\"",
369
+ "OP_EQ",
370
+ "OP_NEQ",
371
+ "OP_LEQ",
372
+ "OP_GEQ",
373
+ "\">\"",
374
+ "\"<\"",
375
+ "NOT",
376
+ "AND",
377
+ "OR",
378
+ "\",\"",
379
+ "\":\"",
380
+ "\"|\"",
381
+ "VAR_OPEN",
382
+ "VAR_CLOSE",
383
+ "STMT_OPEN",
384
+ "IF",
385
+ "STMT_CLOSE",
386
+ "UNLESS",
387
+ "ELSE",
388
+ "ENDIF",
389
+ "ENDUNLESS",
390
+ "FOR",
391
+ "IN",
392
+ "ENDFOR",
393
+ "BLOCK",
394
+ "ENDBLOCK",
395
+ "END",
396
+ "EXTENDS",
397
+ "TEXT_BLOCK",
398
+ "$start",
399
+ "target",
400
+ "document",
401
+ "primary_expression",
402
+ "logical_expression",
403
+ "multiplicative_expression",
404
+ "additive_expression",
405
+ "boolean_expression",
406
+ "inverse_expression",
407
+ "parameter_list",
408
+ "filter",
409
+ "filter_list",
410
+ "inject_statement",
411
+ "if_tag",
412
+ "unless_tag",
413
+ "else_tag",
414
+ "end_if_tag",
415
+ "end_unless_tag",
416
+ "if_block",
417
+ "unless_block",
418
+ "for_tag",
419
+ "end_for_tag",
420
+ "for_block",
421
+ "@1",
422
+ "block_tag",
423
+ "end_block_tag",
424
+ "block_block",
425
+ "@2",
426
+ "generic_block",
427
+ "@3",
428
+ "@4",
429
+ "extends_statement",
430
+ "document_component" ]
431
+
432
+ Racc_debug_parser = false
433
+
434
+ ##### State transition tables end #####
435
+
436
+ # reduce 0 omitted
437
+
438
+ # reduce 1 omitted
439
+
440
+ module_eval(<<'.,.,', 'cadenza.y', 8)
441
+ def _reduce_2(val, _values, result)
442
+ result = nil
443
+ result
444
+ end
445
+ .,.,
446
+
447
+ module_eval(<<'.,.,', 'cadenza.y', 12)
448
+ def _reduce_3(val, _values, result)
449
+ result = VariableNode.new(val[0].value)
450
+ result
451
+ end
452
+ .,.,
453
+
454
+ module_eval(<<'.,.,', 'cadenza.y', 13)
455
+ def _reduce_4(val, _values, result)
456
+ result = ConstantNode.new(val[0].value)
457
+ result
458
+ end
459
+ .,.,
460
+
461
+ module_eval(<<'.,.,', 'cadenza.y', 14)
462
+ def _reduce_5(val, _values, result)
463
+ result = ConstantNode.new(val[0].value)
464
+ result
465
+ end
466
+ .,.,
467
+
468
+ module_eval(<<'.,.,', 'cadenza.y', 15)
469
+ def _reduce_6(val, _values, result)
470
+ result = ConstantNode.new(val[0].value)
471
+ result
472
+ end
473
+ .,.,
474
+
475
+ module_eval(<<'.,.,', 'cadenza.y', 16)
476
+ def _reduce_7(val, _values, result)
477
+ result = val[1]
478
+ result
479
+ end
480
+ .,.,
481
+
482
+ # reduce 8 omitted
483
+
484
+ module_eval(<<'.,.,', 'cadenza.y', 21)
485
+ def _reduce_9(val, _values, result)
486
+ result = OperationNode.new(val[0], "*", val[2])
487
+ result
488
+ end
489
+ .,.,
490
+
491
+ module_eval(<<'.,.,', 'cadenza.y', 22)
492
+ def _reduce_10(val, _values, result)
493
+ result = OperationNode.new(val[0], "/", val[2])
494
+ result
495
+ end
496
+ .,.,
497
+
498
+ # reduce 11 omitted
499
+
500
+ module_eval(<<'.,.,', 'cadenza.y', 27)
501
+ def _reduce_12(val, _values, result)
502
+ result = OperationNode.new(val[0], "+", val[2])
503
+ result
504
+ end
505
+ .,.,
506
+
507
+ module_eval(<<'.,.,', 'cadenza.y', 28)
508
+ def _reduce_13(val, _values, result)
509
+ result = OperationNode.new(val[0], "-", val[2])
510
+ result
511
+ end
512
+ .,.,
513
+
514
+ # reduce 14 omitted
515
+
516
+ module_eval(<<'.,.,', 'cadenza.y', 33)
517
+ def _reduce_15(val, _values, result)
518
+ result = OperationNode.new(val[0], "==", val[2])
519
+ result
520
+ end
521
+ .,.,
522
+
523
+ module_eval(<<'.,.,', 'cadenza.y', 34)
524
+ def _reduce_16(val, _values, result)
525
+ result = OperationNode.new(val[0], "!=", val[2])
526
+ result
527
+ end
528
+ .,.,
529
+
530
+ module_eval(<<'.,.,', 'cadenza.y', 35)
531
+ def _reduce_17(val, _values, result)
532
+ result = OperationNode.new(val[0], "<=", val[2])
533
+ result
534
+ end
535
+ .,.,
536
+
537
+ module_eval(<<'.,.,', 'cadenza.y', 36)
538
+ def _reduce_18(val, _values, result)
539
+ result = OperationNode.new(val[0], ">=", val[2])
540
+ result
541
+ end
542
+ .,.,
543
+
544
+ module_eval(<<'.,.,', 'cadenza.y', 37)
545
+ def _reduce_19(val, _values, result)
546
+ result = OperationNode.new(val[0], ">", val[2])
547
+ result
548
+ end
549
+ .,.,
550
+
551
+ module_eval(<<'.,.,', 'cadenza.y', 38)
552
+ def _reduce_20(val, _values, result)
553
+ result = OperationNode.new(val[0], "<", val[2])
554
+ result
555
+ end
556
+ .,.,
557
+
558
+ # reduce 21 omitted
559
+
560
+ module_eval(<<'.,.,', 'cadenza.y', 43)
561
+ def _reduce_22(val, _values, result)
562
+ result = BooleanInverseNode.new(val[1])
563
+ result
564
+ end
565
+ .,.,
566
+
567
+ # reduce 23 omitted
568
+
569
+ module_eval(<<'.,.,', 'cadenza.y', 48)
570
+ def _reduce_24(val, _values, result)
571
+ result = OperationNode.new(val[0], "and", val[2])
572
+ result
573
+ end
574
+ .,.,
575
+
576
+ module_eval(<<'.,.,', 'cadenza.y', 49)
577
+ def _reduce_25(val, _values, result)
578
+ result = OperationNode.new(val[0], "or", val[2])
579
+ result
580
+ end
581
+ .,.,
582
+
583
+ module_eval(<<'.,.,', 'cadenza.y', 53)
584
+ def _reduce_26(val, _values, result)
585
+ result = [val[0]]
586
+ result
587
+ end
588
+ .,.,
589
+
590
+ module_eval(<<'.,.,', 'cadenza.y', 54)
591
+ def _reduce_27(val, _values, result)
592
+ result = val[0].push(val[2])
593
+ result
594
+ end
595
+ .,.,
596
+
597
+ module_eval(<<'.,.,', 'cadenza.y', 58)
598
+ def _reduce_28(val, _values, result)
599
+ result = FilterNode.new(val[0].value)
600
+ result
601
+ end
602
+ .,.,
603
+
604
+ module_eval(<<'.,.,', 'cadenza.y', 59)
605
+ def _reduce_29(val, _values, result)
606
+ result = FilterNode.new(val[0].value, val[2])
607
+ result
608
+ end
609
+ .,.,
610
+
611
+ module_eval(<<'.,.,', 'cadenza.y', 63)
612
+ def _reduce_30(val, _values, result)
613
+ result = [val[0]]
614
+ result
615
+ end
616
+ .,.,
617
+
618
+ module_eval(<<'.,.,', 'cadenza.y', 64)
619
+ def _reduce_31(val, _values, result)
620
+ result = val[0].push(val[2])
621
+ result
622
+ end
623
+ .,.,
624
+
625
+ module_eval(<<'.,.,', 'cadenza.y', 69)
626
+ def _reduce_32(val, _values, result)
627
+ result = InjectNode.new(val[1])
628
+ result
629
+ end
630
+ .,.,
631
+
632
+ module_eval(<<'.,.,', 'cadenza.y', 71)
633
+ def _reduce_33(val, _values, result)
634
+ result = InjectNode.new(val[1], val[3])
635
+ result
636
+ end
637
+ .,.,
638
+
639
+ module_eval(<<'.,.,', 'cadenza.y', 74)
640
+ def _reduce_34(val, _values, result)
641
+ variable = VariableNode.new(val[1].value)
642
+ result = InjectNode.new(variable, [], val[2])
643
+
644
+ result
645
+ end
646
+ .,.,
647
+
648
+ module_eval(<<'.,.,', 'cadenza.y', 79)
649
+ def _reduce_35(val, _values, result)
650
+ variable = VariableNode.new(val[1].value)
651
+ result = InjectNode.new(variable, val[4], val[2])
652
+
653
+ result
654
+ end
655
+ .,.,
656
+
657
+ module_eval(<<'.,.,', 'cadenza.y', 87)
658
+ def _reduce_36(val, _values, result)
659
+ @stack.push DocumentNode.new
660
+ result = val[2]
661
+
662
+ result
663
+ end
664
+ .,.,
665
+
666
+ module_eval(<<'.,.,', 'cadenza.y', 95)
667
+ def _reduce_37(val, _values, result)
668
+ @stack.push DocumentNode.new
669
+ result = BooleanInverseNode.new(val[2])
670
+
671
+ result
672
+ end
673
+ .,.,
674
+
675
+ module_eval(<<'.,.,', 'cadenza.y', 101)
676
+ def _reduce_38(val, _values, result)
677
+ @stack.push DocumentNode.new
678
+ result
679
+ end
680
+ .,.,
681
+
682
+ # reduce 39 omitted
683
+
684
+ # reduce 40 omitted
685
+
686
+ module_eval(<<'.,.,', 'cadenza.y', 113)
687
+ def _reduce_41(val, _values, result)
688
+ @stack.pop; result = IfNode.new(val[0])
689
+ result
690
+ end
691
+ .,.,
692
+
693
+ module_eval(<<'.,.,', 'cadenza.y', 114)
694
+ def _reduce_42(val, _values, result)
695
+ result = IfNode.new(val[0], @stack.pop.children)
696
+ result
697
+ end
698
+ .,.,
699
+
700
+ module_eval(<<'.,.,', 'cadenza.y', 117)
701
+ def _reduce_43(val, _values, result)
702
+ false_children, true_children = @stack.pop.children, @stack.pop.children
703
+ result = IfNode.new(val[0], true_children, false_children)
704
+
705
+ result
706
+ end
707
+ .,.,
708
+
709
+ module_eval(<<'.,.,', 'cadenza.y', 122)
710
+ def _reduce_44(val, _values, result)
711
+ false_children, true_children = @stack.pop.children, @stack.pop.children
712
+ result = IfNode.new(val[0], true_children, false_children)
713
+
714
+ result
715
+ end
716
+ .,.,
717
+
718
+ module_eval(<<'.,.,', 'cadenza.y', 127)
719
+ def _reduce_45(val, _values, result)
720
+ false_children, true_children = @stack.pop.children, @stack.pop.children
721
+ result = IfNode.new(val[0], true_children, false_children)
722
+
723
+ result
724
+ end
725
+ .,.,
726
+
727
+ module_eval(<<'.,.,', 'cadenza.y', 133)
728
+ def _reduce_46(val, _values, result)
729
+ @stack.pop; result = IfNode.new(val[0])
730
+ result
731
+ end
732
+ .,.,
733
+
734
+ module_eval(<<'.,.,', 'cadenza.y', 134)
735
+ def _reduce_47(val, _values, result)
736
+ result = IfNode.new(val[0], @stack.pop.children)
737
+ result
738
+ end
739
+ .,.,
740
+
741
+ module_eval(<<'.,.,', 'cadenza.y', 137)
742
+ def _reduce_48(val, _values, result)
743
+ false_children, true_children = @stack.pop.children, @stack.pop.children
744
+ result = IfNode.new(val[0], true_children, false_children)
745
+
746
+ result
747
+ end
748
+ .,.,
749
+
750
+ module_eval(<<'.,.,', 'cadenza.y', 142)
751
+ def _reduce_49(val, _values, result)
752
+ false_children, true_children = @stack.pop.children, @stack.pop.children
753
+ result = IfNode.new(val[0], true_children, false_children)
754
+
755
+ result
756
+ end
757
+ .,.,
758
+
759
+ module_eval(<<'.,.,', 'cadenza.y', 147)
760
+ def _reduce_50(val, _values, result)
761
+ false_children, true_children = @stack.pop.children, @stack.pop.children
762
+ result = IfNode.new(val[0], true_children, false_children)
763
+
764
+ result
765
+ end
766
+ .,.,
767
+
768
+ module_eval(<<'.,.,', 'cadenza.y', 153)
769
+ def _reduce_51(val, _values, result)
770
+ result = [val[2].value, val[4].value]
771
+ result
772
+ end
773
+ .,.,
774
+
775
+ # reduce 52 omitted
776
+
777
+ module_eval(<<'.,.,', 'cadenza.y', 164)
778
+ def _reduce_53(val, _values, result)
779
+ iterator = VariableNode.new(val[0][0])
780
+ iterable = VariableNode.new(val[0][1])
781
+
782
+ result = ForNode.new(iterator, iterable, [])
783
+
784
+ result
785
+ end
786
+ .,.,
787
+
788
+ module_eval(<<'.,.,', 'cadenza.y', 169)
789
+ def _reduce_54(val, _values, result)
790
+ @stack.push DocumentNode.new
791
+ result
792
+ end
793
+ .,.,
794
+
795
+ module_eval(<<'.,.,', 'cadenza.y', 171)
796
+ def _reduce_55(val, _values, result)
797
+ iterator = VariableNode.new(val[0][0])
798
+ iterable = VariableNode.new(val[0][1])
799
+
800
+ result = ForNode.new(iterator, iterable, @stack.pop.children)
801
+
802
+ result
803
+ end
804
+ .,.,
805
+
806
+ module_eval(<<'.,.,', 'cadenza.y', 179)
807
+ def _reduce_56(val, _values, result)
808
+ result = val[2].value
809
+ result
810
+ end
811
+ .,.,
812
+
813
+ # reduce 57 omitted
814
+
815
+ module_eval(<<'.,.,', 'cadenza.y', 188)
816
+ def _reduce_58(val, _values, result)
817
+ result = BlockNode.new(val[0], [])
818
+ result
819
+ end
820
+ .,.,
821
+
822
+ module_eval(<<'.,.,', 'cadenza.y', 189)
823
+ def _reduce_59(val, _values, result)
824
+ @stack.push DocumentNode.new
825
+ result
826
+ end
827
+ .,.,
828
+
829
+ module_eval(<<'.,.,', 'cadenza.y', 189)
830
+ def _reduce_60(val, _values, result)
831
+ result = BlockNode.new(val[0], @stack.pop.children)
832
+ result
833
+ end
834
+ .,.,
835
+
836
+ module_eval(<<'.,.,', 'cadenza.y', 193)
837
+ def _reduce_61(val, _values, result)
838
+ @stack.push DocumentNode.new
839
+ result
840
+ end
841
+ .,.,
842
+
843
+ module_eval(<<'.,.,', 'cadenza.y', 195)
844
+ def _reduce_62(val, _values, result)
845
+ result = GenericBlockNode.new(val[1].value, @stack.pop.children)
846
+ result
847
+ end
848
+ .,.,
849
+
850
+ module_eval(<<'.,.,', 'cadenza.y', 196)
851
+ def _reduce_63(val, _values, result)
852
+ @stack.push DocumentNode.new
853
+ result
854
+ end
855
+ .,.,
856
+
857
+ module_eval(<<'.,.,', 'cadenza.y', 198)
858
+ def _reduce_64(val, _values, result)
859
+ result = GenericBlockNode.new(val[1].value, @stack.pop.children, val[2])
860
+ result
861
+ end
862
+ .,.,
863
+
864
+ module_eval(<<'.,.,', 'cadenza.y', 202)
865
+ def _reduce_65(val, _values, result)
866
+ result = val[2].value
867
+ result
868
+ end
869
+ .,.,
870
+
871
+ module_eval(<<'.,.,', 'cadenza.y', 203)
872
+ def _reduce_66(val, _values, result)
873
+ result = VariableNode.new(val[2].value)
874
+ result
875
+ end
876
+ .,.,
877
+
878
+ module_eval(<<'.,.,', 'cadenza.y', 207)
879
+ def _reduce_67(val, _values, result)
880
+ result = TextNode.new(val[0].value)
881
+ result
882
+ end
883
+ .,.,
884
+
885
+ # reduce 68 omitted
886
+
887
+ # reduce 69 omitted
888
+
889
+ # reduce 70 omitted
890
+
891
+ # reduce 71 omitted
892
+
893
+ # reduce 72 omitted
894
+
895
+ module_eval(<<'.,.,', 'cadenza.y', 216)
896
+ def _reduce_73(val, _values, result)
897
+ push_child val[0]
898
+ result
899
+ end
900
+ .,.,
901
+
902
+ module_eval(<<'.,.,', 'cadenza.y', 217)
903
+ def _reduce_74(val, _values, result)
904
+ push_child val[1]
905
+ result
906
+ end
907
+ .,.,
908
+
909
+ module_eval(<<'.,.,', 'cadenza.y', 218)
910
+ def _reduce_75(val, _values, result)
911
+ @stack.first.extends = val[0]
912
+ result
913
+ end
914
+ .,.,
915
+
916
+ module_eval(<<'.,.,', 'cadenza.y', 219)
917
+ def _reduce_76(val, _values, result)
918
+ @stack.first.extends = val[1]
919
+ result
920
+ end
921
+ .,.,
922
+
923
+ module_eval(<<'.,.,', 'cadenza.y', 220)
924
+ def _reduce_77(val, _values, result)
925
+ push_block(val[0])
926
+ result
927
+ end
928
+ .,.,
929
+
930
+ module_eval(<<'.,.,', 'cadenza.y', 221)
931
+ def _reduce_78(val, _values, result)
932
+ push_block(val[1])
933
+ result
934
+ end
935
+ .,.,
936
+
937
+ def _reduce_none(val, _values, result)
938
+ val[0]
939
+ end
940
+
941
+ end # class Parser
942
+ end # module Cadenza