esi_attribute_language 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,36 @@
1
+ begin
2
+ require 'jeweler'
3
+ Jeweler::Tasks.new do |s|
4
+ s.name = "esi_attribute_language"
5
+ s.description = s.summary = "ESI Attribute Language"
6
+ s.email = "joshbuddy@gmail.com"
7
+ s.homepage = "http://github.com/joshbuddy/esi_attribute_language"
8
+ s.authors = ["Joshua Hull"]
9
+ s.files = FileList["[A-Z]*", "{lib,spec}/**/*"]
10
+ end
11
+ Jeweler::GemcutterTasks.new
12
+ rescue LoadError
13
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
14
+ end
15
+
16
+ desc "Build it up"
17
+ task :build do
18
+ sh "rex --independent -o lib/esi_attribute_language/grammar/grammar.rex.rb lib/esi_attribute_language/grammar/grammar.rex"
19
+ sh "racc -v -O parser.output -o lib/esi_attribute_language/grammar/grammar.y.rb lib/esi_attribute_language/grammar/grammar.y"
20
+ sh "rex --independent -o lib/esi_attribute_language/grammar/simple.rex.rb lib/esi_attribute_language/grammar/simple.rex"
21
+ sh "racc -v -O parser.output -o lib/esi_attribute_language/grammar/simple.y.rb lib/esi_attribute_language/grammar/simple.y"
22
+ end
23
+
24
+ require 'spec'
25
+ require 'spec/rake/spectask'
26
+
27
+ task :spec => 'spec:all'
28
+ namespace(:spec) do
29
+ Spec::Rake::SpecTask.new(:all) do |t|
30
+ t.spec_opts ||= []
31
+ t.spec_opts << "-rubygems"
32
+ t.spec_opts << "--options" << "spec/spec.opts"
33
+ t.spec_files = FileList['spec/**/*.rb']
34
+ end
35
+
36
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.3
@@ -0,0 +1,94 @@
1
+ require File.join(File.dirname(__FILE__), 'esi_attribute_language', 'grammar')
2
+
3
+ module EsiAttributeLanguage
4
+
5
+ class VariableLookup
6
+ def initialize(variable_name)
7
+ @variable_name = variable_name.to_sym
8
+ end
9
+
10
+ def execute(context)
11
+ context[@variable_name]
12
+ end
13
+ end
14
+
15
+ class Node
16
+ def self.cleanse_string(string)
17
+ if string[0] == ?' && string[-1] == ?'
18
+ string[1, string.size - 2].gsub('\\\'', '\'')
19
+ else
20
+ string
21
+ end
22
+ end
23
+
24
+ def result_single(var, context)
25
+ var.respond_to?(:execute) ? var.execute(context) : var
26
+ end
27
+
28
+ def result(var, context)
29
+ var.is_a?(Array) ? var.map{|v| result_single(v, context)} : result_single(var, context)
30
+ end
31
+ end
32
+
33
+ class ConcatNode < Node
34
+ def initialize(*parts)
35
+ @parts = parts
36
+ end
37
+
38
+ def execute(context)
39
+ result(@parts, context).join('')
40
+ end
41
+ end
42
+
43
+ class HashLookupNode < Node
44
+ def initialize(variable, key)
45
+
46
+ @variable = variable
47
+ @key = key
48
+ end
49
+
50
+ def execute(context)
51
+ case var = result(@variable, context)
52
+ when Hash
53
+ var[result(@key, context)]
54
+ when Set
55
+ var.include?(result(@key, context))
56
+ end
57
+ end
58
+ end
59
+
60
+ class OrNode < Node
61
+ def initialize(lval, rval)
62
+ @lval = lval
63
+ @rval = rval
64
+ end
65
+
66
+ def execute(context)
67
+ result(@lval, context) || result(@rval, context)
68
+ end
69
+
70
+ end
71
+
72
+ class DummyNode < Node
73
+ def initialize(lit)
74
+ @lit = lit
75
+ end
76
+
77
+ def execute(context)
78
+ @lit
79
+ end
80
+ end
81
+
82
+ class MethodNode < Node
83
+ def initialize(receiver, op, *args)
84
+ @receiver = receiver
85
+ @op = op
86
+ @args = args
87
+ end
88
+
89
+ def execute(context)
90
+ result(@receiver, context).send(@op, *result(@args, context))
91
+ end
92
+ end
93
+
94
+ end
@@ -0,0 +1,56 @@
1
+ require File.join(File.dirname(__FILE__), 'grammar', 'grammar.y')
2
+ require File.join(File.dirname(__FILE__), 'grammar', 'grammar.rex')
3
+ require File.join(File.dirname(__FILE__), 'grammar', 'simple.y')
4
+ require File.join(File.dirname(__FILE__), 'grammar', 'simple.rex')
5
+
6
+ module EsiAttributeLanguage
7
+
8
+ ParseError = Class.new(Exception)
9
+
10
+ class SimpleGrammar
11
+ attr_reader :rules
12
+
13
+ def self.parse(source)
14
+ result = SimpleGrammarParser.new.scan_str(source)
15
+ result.respond_to?(:execute) ? result : DummyNode.new(result)
16
+ rescue Racc::ParseError => e
17
+ raise ParseError, e.message
18
+ end
19
+
20
+ def initialize(rules)
21
+ @root = rules.first.name
22
+ @rules = {}
23
+ rules.each { |r| @rules[r.name] = r }
24
+ end
25
+
26
+ def parse(string)
27
+ index = @rules[@root].call(string, 0, @rules)
28
+ index if index == string.length
29
+ end
30
+ end
31
+
32
+ class Grammar
33
+
34
+ attr_reader :rules
35
+
36
+ def self.parse(source)
37
+ result = GrammarParser.new.scan_str(source)
38
+ result.respond_to?(:execute) ? result : DummyNode.new(result)
39
+ rescue Racc::ParseError => e
40
+ raise ParseError, e.message
41
+ end
42
+
43
+ def initialize(rules)
44
+ @root = rules.first.name
45
+ @rules = {}
46
+ rules.each { |r| @rules[r.name] = r }
47
+ end
48
+
49
+ def parse(string)
50
+ index = @rules[@root].call(string, 0, @rules)
51
+ index if index == string.length
52
+ end
53
+
54
+ end
55
+
56
+ end
@@ -0,0 +1,33 @@
1
+ class EsiAttributeLanguage::GrammarParser
2
+
3
+ rule
4
+ '(\\'|[^'])*' { [:STRING, text] }
5
+ == { [:EQ, text] }
6
+ != { [:NE, text] }
7
+ <= { [:LTE, text] }
8
+ >= { [:GTE, text] }
9
+ < { [:LT, text] }
10
+ > { [:GT, text] }
11
+ \$ { [:DOLLAR, text] }
12
+ \| { [:PIPE, text] }
13
+ \[ { [:LSQUARE, text] }
14
+ \] { [:RSQUARE, text] }
15
+ \{ { [:LBRACE, text] }
16
+ \} { [:RBRACE, text] }
17
+ \( { [:LPAREN, text] }
18
+ \) { [:RPAREN, text] }
19
+ \\ { [:BSLASH, text] }
20
+ \+ { [:PLUS, text] }
21
+ \* { [:STAR, text] }
22
+ \/ { [:SLASH, text] }
23
+ \' { [:QUOTE, text] }
24
+ \? { [:QMARK, text] }
25
+ \. { [:DOT, text] }
26
+ \^ { [:CARROT, text] }
27
+ \- { [:MINUS, text] }
28
+ & { [:AMP, text] }
29
+ ! { [:BANG, text] }
30
+ [0-9]+ { [:NUMBER, text] }
31
+ [A-Za-z_-]+ { [:VARIABLE, text] }
32
+ . nil
33
+ end
@@ -0,0 +1,154 @@
1
+ #--
2
+ # DO NOT MODIFY!!!!
3
+ # This file is automatically generated by rex 1.0.3
4
+ # from lexical definition file "lib/esi_attribute_language/grammar/grammar.rex".
5
+ #++
6
+
7
+ module EsiAttributeLanguage
8
+ class GrammarParser
9
+ require 'strscan'
10
+
11
+ class ScanError < StandardError ; end
12
+
13
+ attr_reader :lineno
14
+ attr_reader :filename
15
+
16
+ def scan_setup ; end
17
+
18
+ def action &block
19
+ yield
20
+ end
21
+
22
+ def scan_str( str )
23
+ scan_evaluate str
24
+ do_parse
25
+ end
26
+
27
+ def load_file( filename )
28
+ @filename = filename
29
+ open(filename, "r") do |f|
30
+ scan_evaluate f.read
31
+ end
32
+ end
33
+
34
+ def scan_file( filename )
35
+ load_file filename
36
+ do_parse
37
+ end
38
+
39
+ def next_token
40
+ @rex_tokens.shift
41
+ end
42
+
43
+ def scan_evaluate( str )
44
+ scan_setup
45
+ @rex_tokens = []
46
+ @lineno = 1
47
+ ss = StringScanner.new(str)
48
+ state = nil
49
+ until ss.eos?
50
+ text = ss.peek(1)
51
+ @lineno += 1 if text == "\n"
52
+ case state
53
+ when nil
54
+ case
55
+ when (text = ss.scan(/'(\\'|[^'])*'/))
56
+ @rex_tokens.push action { [:STRING, text] }
57
+
58
+ when (text = ss.scan(/==/))
59
+ @rex_tokens.push action { [:EQ, text] }
60
+
61
+ when (text = ss.scan(/!=/))
62
+ @rex_tokens.push action { [:NE, text] }
63
+
64
+ when (text = ss.scan(/<=/))
65
+ @rex_tokens.push action { [:LTE, text] }
66
+
67
+ when (text = ss.scan(/>=/))
68
+ @rex_tokens.push action { [:GTE, text] }
69
+
70
+ when (text = ss.scan(/</))
71
+ @rex_tokens.push action { [:LT, text] }
72
+
73
+ when (text = ss.scan(/>/))
74
+ @rex_tokens.push action { [:GT, text] }
75
+
76
+ when (text = ss.scan(/\$/))
77
+ @rex_tokens.push action { [:DOLLAR, text] }
78
+
79
+ when (text = ss.scan(/\|/))
80
+ @rex_tokens.push action { [:PIPE, text] }
81
+
82
+ when (text = ss.scan(/\[/))
83
+ @rex_tokens.push action { [:LSQUARE, text] }
84
+
85
+ when (text = ss.scan(/\]/))
86
+ @rex_tokens.push action { [:RSQUARE, text] }
87
+
88
+ when (text = ss.scan(/\{/))
89
+ @rex_tokens.push action { [:LBRACE, text] }
90
+
91
+ when (text = ss.scan(/\}/))
92
+ @rex_tokens.push action { [:RBRACE, text] }
93
+
94
+ when (text = ss.scan(/\(/))
95
+ @rex_tokens.push action { [:LPAREN, text] }
96
+
97
+ when (text = ss.scan(/\)/))
98
+ @rex_tokens.push action { [:RPAREN, text] }
99
+
100
+ when (text = ss.scan(/\\/))
101
+ @rex_tokens.push action { [:BSLASH, text] }
102
+
103
+ when (text = ss.scan(/\+/))
104
+ @rex_tokens.push action { [:PLUS, text] }
105
+
106
+ when (text = ss.scan(/\*/))
107
+ @rex_tokens.push action { [:STAR, text] }
108
+
109
+ when (text = ss.scan(/\//))
110
+ @rex_tokens.push action { [:SLASH, text] }
111
+
112
+ when (text = ss.scan(/\'/))
113
+ @rex_tokens.push action { [:QUOTE, text] }
114
+
115
+ when (text = ss.scan(/\?/))
116
+ @rex_tokens.push action { [:QMARK, text] }
117
+
118
+ when (text = ss.scan(/\./))
119
+ @rex_tokens.push action { [:DOT, text] }
120
+
121
+ when (text = ss.scan(/\^/))
122
+ @rex_tokens.push action { [:CARROT, text] }
123
+
124
+ when (text = ss.scan(/\-/))
125
+ @rex_tokens.push action { [:MINUS, text] }
126
+
127
+ when (text = ss.scan(/&/))
128
+ @rex_tokens.push action { [:AMP, text] }
129
+
130
+ when (text = ss.scan(/!/))
131
+ @rex_tokens.push action { [:BANG, text] }
132
+
133
+ when (text = ss.scan(/[0-9]+/))
134
+ @rex_tokens.push action { [:NUMBER, text] }
135
+
136
+ when (text = ss.scan(/[A-Za-z_-]+/))
137
+ @rex_tokens.push action { [:VARIABLE, text] }
138
+
139
+ when (text = ss.scan(/./))
140
+ ;
141
+
142
+ else
143
+ text = ss.string[ss.pos .. -1]
144
+ raise ScanError, "can not match: '" + text + "'"
145
+ end # if
146
+
147
+ else
148
+ raise ScanError, "undefined state: '" + state.to_s + "'"
149
+ end # case state
150
+ end # until ss
151
+ end # def scan_evaluate
152
+
153
+ end # class
154
+ end # module
@@ -0,0 +1,39 @@
1
+ class EsiAttributeLanguage::GrammarParser
2
+
3
+ token DOLLAR LSQUARE RSQUARE LPAREN RPAREN LBRACE RBRACE BSLASH PIPE
4
+ token PLUS NUMBER MINUS STAR SLASH VARIABLE STRING EQ NE LTE GTE LT GT BANG AMP
5
+
6
+ rule
7
+ expression:
8
+ NUMBER { result = Integer(val[0]) }
9
+ | STRING { result = Node.cleanse_string(val[0]) }
10
+ | expression EQ expression { result = MethodNode.new(val[0], :'==', val[2]) }
11
+ | expression NE expression { result = MethodNode.new(MethodNode.new(val[0], :'==', val[2]), :'^', true) }
12
+ | expression LTE expression { result = MethodNode.new(val[0], :'<=', val[2]) }
13
+ | expression GTE expression { result = MethodNode.new(val[0], :'>=', val[2]) }
14
+ | expression LT expression { result = MethodNode.new(val[0], :'<' , val[2]) }
15
+ | expression GT expression { result = MethodNode.new(val[0], :'>' , val[2]) }
16
+ | expression AMP expression { result = MethodNode.new(val[0], :'&' , val[2]) }
17
+ | expression PIPE expression { result = MethodNode.new(val[0], :'|' , val[2]) }
18
+ | expression PLUS expression { result = MethodNode.new(val[0], :+ , val[2]) }
19
+ | expression MINUS expression { result = MethodNode.new(val[0], :- , val[2]) }
20
+ | expression STAR expression { result = MethodNode.new(val[0], :'*' , val[2]) }
21
+ | expression SLASH expression { result = MethodNode.new(val[0], :'/' , val[2]) }
22
+ | BANG expression { result = MethodNode.new(val[1], :'^', true) }
23
+ | LPAREN expression RPAREN { result = val[1] }
24
+ | DOLLAR LPAREN variable RPAREN { result = val[2] } # $(...)
25
+ ;
26
+
27
+ variable:
28
+ STRING { result = Node.cleanse_string(val[0]) }
29
+ | variable PIPE variable { result = OrNode.new(val[0], val[2]) }
30
+ | variable LBRACE hash_lookup RBRACE { result = HashLookupNode.new(val[0], val[2]) }
31
+ | VARIABLE { result = VariableLookup.new(val[0]) }
32
+ ;
33
+
34
+ hash_lookup:
35
+ STRING { result = Node.cleanse_string(val[0]) }
36
+ | VARIABLE { result = val[0] }
37
+ ;
38
+
39
+ end
@@ -0,0 +1,398 @@
1
+ #
2
+ # DO NOT MODIFY!!!!
3
+ # This file is automatically generated by Racc 1.4.6
4
+ # from Racc grammer file "".
5
+ #
6
+
7
+ require 'racc/parser.rb'
8
+ module EsiAttributeLanguage
9
+ class GrammarParser < Racc::Parser
10
+ ##### State transition tables begin ###
11
+
12
+ racc_action_table = [
13
+ 12, 7, 2, 40, 41, 4, 41, 42, 47, 42,
14
+ 21, 10, 1, 14, 15, 17, 29, 6, 18, 19,
15
+ 20, 22, 11, 13, 3, 16, 2, 2, 2, 4,
16
+ 4, 4, 23, 24, 23, 24, 1, 1, 1, 43,
17
+ 44, 6, 6, 6, 2, nil, nil, 4, 3, 3,
18
+ 3, nil, 2, 2, 1, 4, 4, nil, nil, 6,
19
+ nil, 2, 1, 1, 4, nil, 3, 6, 6, 2,
20
+ 2, 1, 4, 4, 3, 3, 6, nil, 2, 1,
21
+ 1, 4, nil, 3, 6, 6, 2, 2, 1, 4,
22
+ 4, 3, 3, 6, nil, 2, 1, 1, 4, nil,
23
+ 3, 6, 6, 2, nil, 1, 4, 26, 3, 3,
24
+ 6, 21, 10, 1, 14, 15, 17, 3, 6, 18,
25
+ 19, 20, 22, 11, 13, 3, 16, 21, 10, nil,
26
+ 14, 15, 17, nil, nil, 18, 19, 20, 22, 11,
27
+ 13, nil, 16, 21, 10, nil, 14, 15, 17, nil,
28
+ nil, 18, 19, 20, 22, 11, 13, nil, 16, 21,
29
+ 10, nil, 14, 15, 17, nil, nil, 18, 19, 20,
30
+ 22, 11, 13, nil, 16, 21, 10, nil, 14, 15,
31
+ 17, nil, nil, 18, 19, 20, 22, 11, 13, nil,
32
+ 16, 21, 10, nil, 14, 15, 17, nil, nil, 18,
33
+ 19, 20, 22, 11, 13, nil, 16, 21, 10, nil,
34
+ 14, 15, 17, nil, nil, 18, 19, 20, 22, 11,
35
+ 13, nil, 16, 21, 10, nil, 14, 15, 17, nil,
36
+ nil, 18, 19, 20, 22, 11, 13, nil, 16, 21,
37
+ 10, nil, 14, 15, 17, nil, nil, 18, 19, 20,
38
+ 22, 11, 13, nil, 16, 21, 10, nil, 14, 15,
39
+ 17, nil, nil, 18, 19, 20, 22, 11, 13, nil,
40
+ 16, 21, 10, nil, 14, 15, 17, nil, nil, 18,
41
+ 19, 20, 22, 11, 13, nil, 16, 21, 10, nil,
42
+ 14, 15, 17, nil, nil, 18, 19, 20, 22, 11,
43
+ 13, nil, 16, 21, 10, nil, 14, 15, 17, nil,
44
+ nil, 18, 19, 20, 22, 11, 13, nil, 16, 21,
45
+ 10, nil, 14, 15, 17, nil, nil, 18, 19, 20,
46
+ 22, 11, 13, nil, 16 ]
47
+
48
+ racc_action_check = [
49
+ 5, 2, 19, 25, 25, 19, 46, 25, 45, 46,
50
+ 5, 5, 19, 5, 5, 5, 12, 19, 5, 5,
51
+ 5, 5, 5, 5, 19, 5, 3, 4, 0, 3,
52
+ 4, 0, 42, 42, 7, 7, 3, 4, 0, 41,
53
+ 41, 3, 4, 0, 17, nil, nil, 17, 3, 4,
54
+ 0, nil, 20, 22, 17, 20, 22, nil, nil, 17,
55
+ nil, 10, 20, 22, 10, nil, 17, 20, 22, 11,
56
+ 18, 10, 11, 18, 20, 22, 10, nil, 13, 11,
57
+ 18, 13, nil, 10, 11, 18, 14, 15, 13, 14,
58
+ 15, 11, 18, 13, nil, 16, 14, 15, 16, nil,
59
+ 13, 14, 15, 21, nil, 16, 21, 9, 14, 15,
60
+ 16, 9, 9, 21, 9, 9, 9, 16, 21, 9,
61
+ 9, 9, 9, 9, 9, 21, 9, 28, 28, nil,
62
+ 28, 28, 28, nil, nil, 28, 28, 28, 28, 28,
63
+ 28, nil, 28, 8, 8, nil, 8, 8, 8, nil,
64
+ nil, 8, 8, 8, 8, 8, 8, nil, 8, 39,
65
+ 39, nil, 39, 39, 39, nil, nil, 39, 39, 39,
66
+ 39, 39, 39, nil, 39, 38, 38, nil, 38, 38,
67
+ 38, nil, nil, 38, 38, 38, 38, 38, 38, nil,
68
+ 38, 36, 36, nil, 36, 36, 36, nil, nil, 36,
69
+ 36, 36, 36, 36, 36, nil, 36, 27, 27, nil,
70
+ 27, 27, 27, nil, nil, 27, 27, 27, 27, 27,
71
+ 27, nil, 27, 33, 33, nil, 33, 33, 33, nil,
72
+ nil, 33, 33, 33, 33, 33, 33, nil, 33, 35,
73
+ 35, nil, 35, 35, 35, nil, nil, 35, 35, 35,
74
+ 35, 35, 35, nil, 35, 31, 31, nil, 31, 31,
75
+ 31, nil, nil, 31, 31, 31, 31, 31, 31, nil,
76
+ 31, 32, 32, nil, 32, 32, 32, nil, nil, 32,
77
+ 32, 32, 32, 32, 32, nil, 32, 37, 37, nil,
78
+ 37, 37, 37, nil, nil, 37, 37, 37, 37, 37,
79
+ 37, nil, 37, 34, 34, nil, 34, 34, 34, nil,
80
+ nil, 34, 34, 34, 34, 34, 34, nil, 34, 30,
81
+ 30, nil, 30, 30, 30, nil, nil, 30, 30, 30,
82
+ 30, 30, 30, nil, 30 ]
83
+
84
+ racc_action_pointer = [
85
+ 26, nil, -4, 24, 25, 0, nil, 18, 133, 101,
86
+ 59, 67, 16, 76, 84, 85, 93, 42, 68, 0,
87
+ 50, 101, 51, nil, nil, -3, nil, 197, 117, nil,
88
+ 309, 245, 261, 213, 293, 229, 181, 277, 165, 149,
89
+ nil, 23, 16, nil, nil, 0, -1, nil ]
90
+
91
+ racc_action_default = [
92
+ -24, -1, -24, -24, -24, -24, -2, -24, -15, -24,
93
+ -24, -24, -24, -24, -24, -24, -24, -24, -24, -24,
94
+ -24, -24, -24, -21, -18, -24, -16, -11, -7, 48,
95
+ -8, -12, -13, -9, -14, -3, -4, -5, -10, -6,
96
+ -17, -24, -24, -23, -22, -24, -19, -20 ]
97
+
98
+ racc_goto_table = [
99
+ 25, 5, 45, nil, 8, 9, nil, nil, nil, nil,
100
+ nil, 27, 28, nil, 30, 31, 32, 33, 34, 35,
101
+ 36, 37, 38, 39, nil, nil, nil, nil, nil, nil,
102
+ nil, nil, nil, nil, nil, 46 ]
103
+
104
+ racc_goto_check = [
105
+ 2, 1, 3, nil, 1, 1, nil, nil, nil, nil,
106
+ nil, 1, 1, nil, 1, 1, 1, 1, 1, 1,
107
+ 1, 1, 1, 1, nil, nil, nil, nil, nil, nil,
108
+ nil, nil, nil, nil, nil, 2 ]
109
+
110
+ racc_goto_pointer = [
111
+ nil, 1, -7, -39 ]
112
+
113
+ racc_goto_default = [
114
+ nil, nil, nil, nil ]
115
+
116
+ racc_reduce_table = [
117
+ 0, 0, :racc_error,
118
+ 1, 27, :_reduce_1,
119
+ 1, 27, :_reduce_2,
120
+ 3, 27, :_reduce_3,
121
+ 3, 27, :_reduce_4,
122
+ 3, 27, :_reduce_5,
123
+ 3, 27, :_reduce_6,
124
+ 3, 27, :_reduce_7,
125
+ 3, 27, :_reduce_8,
126
+ 3, 27, :_reduce_9,
127
+ 3, 27, :_reduce_10,
128
+ 3, 27, :_reduce_11,
129
+ 3, 27, :_reduce_12,
130
+ 3, 27, :_reduce_13,
131
+ 3, 27, :_reduce_14,
132
+ 2, 27, :_reduce_15,
133
+ 3, 27, :_reduce_16,
134
+ 4, 27, :_reduce_17,
135
+ 1, 28, :_reduce_18,
136
+ 3, 28, :_reduce_19,
137
+ 4, 28, :_reduce_20,
138
+ 1, 28, :_reduce_21,
139
+ 1, 29, :_reduce_22,
140
+ 1, 29, :_reduce_23 ]
141
+
142
+ racc_reduce_n = 24
143
+
144
+ racc_shift_n = 48
145
+
146
+ racc_token_table = {
147
+ false => 0,
148
+ :error => 1,
149
+ :DOLLAR => 2,
150
+ :LSQUARE => 3,
151
+ :RSQUARE => 4,
152
+ :LPAREN => 5,
153
+ :RPAREN => 6,
154
+ :LBRACE => 7,
155
+ :RBRACE => 8,
156
+ :BSLASH => 9,
157
+ :PIPE => 10,
158
+ :PLUS => 11,
159
+ :NUMBER => 12,
160
+ :MINUS => 13,
161
+ :STAR => 14,
162
+ :SLASH => 15,
163
+ :VARIABLE => 16,
164
+ :STRING => 17,
165
+ :EQ => 18,
166
+ :NE => 19,
167
+ :LTE => 20,
168
+ :GTE => 21,
169
+ :LT => 22,
170
+ :GT => 23,
171
+ :BANG => 24,
172
+ :AMP => 25 }
173
+
174
+ racc_nt_base = 26
175
+
176
+ racc_use_result_var = true
177
+
178
+ Racc_arg = [
179
+ racc_action_table,
180
+ racc_action_check,
181
+ racc_action_default,
182
+ racc_action_pointer,
183
+ racc_goto_table,
184
+ racc_goto_check,
185
+ racc_goto_default,
186
+ racc_goto_pointer,
187
+ racc_nt_base,
188
+ racc_reduce_table,
189
+ racc_token_table,
190
+ racc_shift_n,
191
+ racc_reduce_n,
192
+ racc_use_result_var ]
193
+
194
+ Racc_token_to_s_table = [
195
+ "$end",
196
+ "error",
197
+ "DOLLAR",
198
+ "LSQUARE",
199
+ "RSQUARE",
200
+ "LPAREN",
201
+ "RPAREN",
202
+ "LBRACE",
203
+ "RBRACE",
204
+ "BSLASH",
205
+ "PIPE",
206
+ "PLUS",
207
+ "NUMBER",
208
+ "MINUS",
209
+ "STAR",
210
+ "SLASH",
211
+ "VARIABLE",
212
+ "STRING",
213
+ "EQ",
214
+ "NE",
215
+ "LTE",
216
+ "GTE",
217
+ "LT",
218
+ "GT",
219
+ "BANG",
220
+ "AMP",
221
+ "$start",
222
+ "expression",
223
+ "variable",
224
+ "hash_lookup" ]
225
+
226
+ Racc_debug_parser = false
227
+
228
+ ##### State transition tables end #####
229
+
230
+ # reduce 0 omitted
231
+
232
+ module_eval(<<'.,.,', 'grammar.y', 7)
233
+ def _reduce_1(val, _values, result)
234
+ result = Integer(val[0])
235
+ result
236
+ end
237
+ .,.,
238
+
239
+ module_eval(<<'.,.,', 'grammar.y', 8)
240
+ def _reduce_2(val, _values, result)
241
+ result = Node.cleanse_string(val[0])
242
+ result
243
+ end
244
+ .,.,
245
+
246
+ module_eval(<<'.,.,', 'grammar.y', 9)
247
+ def _reduce_3(val, _values, result)
248
+ result = MethodNode.new(val[0], :'==', val[2])
249
+ result
250
+ end
251
+ .,.,
252
+
253
+ module_eval(<<'.,.,', 'grammar.y', 10)
254
+ def _reduce_4(val, _values, result)
255
+ result = MethodNode.new(MethodNode.new(val[0], :'==', val[2]), :'^', true)
256
+ result
257
+ end
258
+ .,.,
259
+
260
+ module_eval(<<'.,.,', 'grammar.y', 11)
261
+ def _reduce_5(val, _values, result)
262
+ result = MethodNode.new(val[0], :'<=', val[2])
263
+ result
264
+ end
265
+ .,.,
266
+
267
+ module_eval(<<'.,.,', 'grammar.y', 12)
268
+ def _reduce_6(val, _values, result)
269
+ result = MethodNode.new(val[0], :'>=', val[2])
270
+ result
271
+ end
272
+ .,.,
273
+
274
+ module_eval(<<'.,.,', 'grammar.y', 13)
275
+ def _reduce_7(val, _values, result)
276
+ result = MethodNode.new(val[0], :'<' , val[2])
277
+ result
278
+ end
279
+ .,.,
280
+
281
+ module_eval(<<'.,.,', 'grammar.y', 14)
282
+ def _reduce_8(val, _values, result)
283
+ result = MethodNode.new(val[0], :'>' , val[2])
284
+ result
285
+ end
286
+ .,.,
287
+
288
+ module_eval(<<'.,.,', 'grammar.y', 15)
289
+ def _reduce_9(val, _values, result)
290
+ result = MethodNode.new(val[0], :'&' , val[2])
291
+ result
292
+ end
293
+ .,.,
294
+
295
+ module_eval(<<'.,.,', 'grammar.y', 16)
296
+ def _reduce_10(val, _values, result)
297
+ result = MethodNode.new(val[0], :'|' , val[2])
298
+ result
299
+ end
300
+ .,.,
301
+
302
+ module_eval(<<'.,.,', 'grammar.y', 17)
303
+ def _reduce_11(val, _values, result)
304
+ result = MethodNode.new(val[0], :+ , val[2])
305
+ result
306
+ end
307
+ .,.,
308
+
309
+ module_eval(<<'.,.,', 'grammar.y', 18)
310
+ def _reduce_12(val, _values, result)
311
+ result = MethodNode.new(val[0], :- , val[2])
312
+ result
313
+ end
314
+ .,.,
315
+
316
+ module_eval(<<'.,.,', 'grammar.y', 19)
317
+ def _reduce_13(val, _values, result)
318
+ result = MethodNode.new(val[0], :'*' , val[2])
319
+ result
320
+ end
321
+ .,.,
322
+
323
+ module_eval(<<'.,.,', 'grammar.y', 20)
324
+ def _reduce_14(val, _values, result)
325
+ result = MethodNode.new(val[0], :'/' , val[2])
326
+ result
327
+ end
328
+ .,.,
329
+
330
+ module_eval(<<'.,.,', 'grammar.y', 21)
331
+ def _reduce_15(val, _values, result)
332
+ result = MethodNode.new(val[1], :'^', true)
333
+ result
334
+ end
335
+ .,.,
336
+
337
+ module_eval(<<'.,.,', 'grammar.y', 22)
338
+ def _reduce_16(val, _values, result)
339
+ result = val[1]
340
+ result
341
+ end
342
+ .,.,
343
+
344
+ module_eval(<<'.,.,', 'grammar.y', 23)
345
+ def _reduce_17(val, _values, result)
346
+ result = val[2]
347
+ result
348
+ end
349
+ .,.,
350
+
351
+ module_eval(<<'.,.,', 'grammar.y', 27)
352
+ def _reduce_18(val, _values, result)
353
+ result = Node.cleanse_string(val[0])
354
+ result
355
+ end
356
+ .,.,
357
+
358
+ module_eval(<<'.,.,', 'grammar.y', 28)
359
+ def _reduce_19(val, _values, result)
360
+ result = OrNode.new(val[0], val[2])
361
+ result
362
+ end
363
+ .,.,
364
+
365
+ module_eval(<<'.,.,', 'grammar.y', 29)
366
+ def _reduce_20(val, _values, result)
367
+ result = HashLookupNode.new(val[0], val[2])
368
+ result
369
+ end
370
+ .,.,
371
+
372
+ module_eval(<<'.,.,', 'grammar.y', 30)
373
+ def _reduce_21(val, _values, result)
374
+ result = VariableLookup.new(val[0])
375
+ result
376
+ end
377
+ .,.,
378
+
379
+ module_eval(<<'.,.,', 'grammar.y', 34)
380
+ def _reduce_22(val, _values, result)
381
+ result = Node.cleanse_string(val[0])
382
+ result
383
+ end
384
+ .,.,
385
+
386
+ module_eval(<<'.,.,', 'grammar.y', 35)
387
+ def _reduce_23(val, _values, result)
388
+ result = val[0]
389
+ result
390
+ end
391
+ .,.,
392
+
393
+ def _reduce_none(val, _values, result)
394
+ val[0]
395
+ end
396
+
397
+ end # class GrammarParser
398
+ end # module EsiAttributeLanguage