esi_attribute_language 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,121 @@
1
+ #--
2
+ # DO NOT MODIFY!!!!
3
+ # This file is automatically generated by rex 1.0.3
4
+ # from lexical definition file "lib/esi_attribute_lang/grammar/lexer.rex".
5
+ #++
6
+
7
+ module EsiAttributeLanguageibute
8
+ class Parser
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 { [:DOLLAR, text] }
57
+
58
+ when (text = ss.scan(/\|/))
59
+ @rex_tokens.push action { [:PIPE, text] }
60
+
61
+ when (text = ss.scan(/\[/))
62
+ @rex_tokens.push action { [:LSQUARE, text] }
63
+
64
+ when (text = ss.scan(/\]/))
65
+ @rex_tokens.push action { [:RSQUARE, text] }
66
+
67
+ when (text = ss.scan(/\{/))
68
+ @rex_tokens.push action { [:LBRACE, text] }
69
+
70
+ when (text = ss.scan(/\}/))
71
+ @rex_tokens.push action { [:RBRACE, text] }
72
+
73
+ when (text = ss.scan(/\(/))
74
+ @rex_tokens.push action { [:LPAREN, text] }
75
+
76
+ when (text = ss.scan(/\)/))
77
+ @rex_tokens.push action { [:RPAREN, text] }
78
+
79
+ when (text = ss.scan(/\\/))
80
+ @rex_tokens.push action { [:BSLASH, text] }
81
+
82
+ when (text = ss.scan(/\+/))
83
+ @rex_tokens.push action { [:PLUS, text] }
84
+
85
+ when (text = ss.scan(/\*/))
86
+ @rex_tokens.push action { [:STAR, text] }
87
+
88
+ when (text = ss.scan(/\?/))
89
+ @rex_tokens.push action { [:QMARK, text] }
90
+
91
+ when (text = ss.scan(/\./))
92
+ @rex_tokens.push action { [:DOT, text] }
93
+
94
+ when (text = ss.scan(/\^/))
95
+ @rex_tokens.push action { [:CARROT, text] }
96
+
97
+ when (text = ss.scan(/-/))
98
+ @rex_tokens.push action { [:MINUS, text] }
99
+
100
+ when (text = ss.scan(/&/))
101
+ @rex_tokens.push action { [:AMP, text] }
102
+
103
+ when (text = ss.scan(/!/))
104
+ @rex_tokens.push action { [:BANG, text] }
105
+
106
+ when (text = ss.scan(/./))
107
+ @rex_tokens.push action { [:CHAR, text] }
108
+
109
+ else
110
+ text = ss.string[ss.pos .. -1]
111
+ raise ScanError, "can not match: '" + text + "'"
112
+ end # if
113
+
114
+ else
115
+ raise ScanError, "undefined state: '" + state.to_s + "'"
116
+ end # case state
117
+ end # until ss
118
+ end # def scan_evaluate
119
+
120
+ end # class
121
+ end # module
@@ -0,0 +1,148 @@
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 EsiAttributeLanguageibute
9
+ class Parser < Racc::Parser
10
+ ##### State transition tables begin ###
11
+
12
+ racc_action_table = [
13
+ 7, 7, 8, 10, 7, 5, 5, 11, 9, 5,
14
+ 7, 15, 4, 11, 9, 5, 11, 9, 11, 9,
15
+ 3, 1 ]
16
+
17
+ racc_action_check = [
18
+ 7, 9, 4, 6, 11, 7, 9, 6, 6, 11,
19
+ 3, 12, 2, 12, 12, 3, 13, 13, 14, 14,
20
+ 1, 0 ]
21
+
22
+ racc_action_pointer = [
23
+ 19, 15, 12, 3, 2, nil, -3, -7, nil, -6,
24
+ nil, -3, 3, 6, 8, nil ]
25
+
26
+ racc_action_default = [
27
+ -6, -6, -6, -6, -6, -5, -6, -6, 16, -6,
28
+ -1, -6, -6, -4, -2, -3 ]
29
+
30
+ racc_goto_table = [
31
+ 6, 2, nil, nil, 12, nil, 13, nil, 14 ]
32
+
33
+ racc_goto_check = [
34
+ 2, 1, nil, nil, 2, nil, 2, nil, 2 ]
35
+
36
+ racc_goto_pointer = [
37
+ nil, 1, -3 ]
38
+
39
+ racc_goto_default = [
40
+ nil, nil, nil ]
41
+
42
+ racc_reduce_table = [
43
+ 0, 0, :racc_error,
44
+ 4, 14, :_reduce_none,
45
+ 3, 15, :_reduce_2,
46
+ 3, 15, :_reduce_3,
47
+ 3, 15, :_reduce_4,
48
+ 1, 15, :_reduce_5 ]
49
+
50
+ racc_reduce_n = 6
51
+
52
+ racc_shift_n = 16
53
+
54
+ racc_token_table = {
55
+ false => 0,
56
+ :error => 1,
57
+ :DOLLAR => 2,
58
+ :LSQUARE => 3,
59
+ :RSQUARE => 4,
60
+ :LPAREN => 5,
61
+ :RPAREN => 6,
62
+ :LBRACE => 7,
63
+ :RBRACE => 8,
64
+ :BSLASH => 9,
65
+ :PIPE => 10,
66
+ :PLUS => 11,
67
+ :NUMBER => 12 }
68
+
69
+ racc_nt_base = 13
70
+
71
+ racc_use_result_var = true
72
+
73
+ Racc_arg = [
74
+ racc_action_table,
75
+ racc_action_check,
76
+ racc_action_default,
77
+ racc_action_pointer,
78
+ racc_goto_table,
79
+ racc_goto_check,
80
+ racc_goto_default,
81
+ racc_goto_pointer,
82
+ racc_nt_base,
83
+ racc_reduce_table,
84
+ racc_token_table,
85
+ racc_shift_n,
86
+ racc_reduce_n,
87
+ racc_use_result_var ]
88
+
89
+ Racc_token_to_s_table = [
90
+ "$end",
91
+ "error",
92
+ "DOLLAR",
93
+ "LSQUARE",
94
+ "RSQUARE",
95
+ "LPAREN",
96
+ "RPAREN",
97
+ "LBRACE",
98
+ "RBRACE",
99
+ "BSLASH",
100
+ "PIPE",
101
+ "PLUS",
102
+ "NUMBER",
103
+ "$start",
104
+ "varaible",
105
+ "expression" ]
106
+
107
+ Racc_debug_parser = false
108
+
109
+ ##### State transition tables end #####
110
+
111
+ # reduce 0 omitted
112
+
113
+ # reduce 1 omitted
114
+
115
+ module_eval(<<'.,.,', 'parser.y', 10)
116
+ def _reduce_2(val, _values, result)
117
+ result = val[0] rescue val[1]
118
+ result
119
+ end
120
+ .,.,
121
+
122
+ module_eval(<<'.,.,', 'parser.y', 11)
123
+ def _reduce_3(val, _values, result)
124
+ result = val[0]
125
+ result
126
+ end
127
+ .,.,
128
+
129
+ module_eval(<<'.,.,', 'parser.y', 12)
130
+ def _reduce_4(val, _values, result)
131
+ result = val[0] + val[1]
132
+ result
133
+ end
134
+ .,.,
135
+
136
+ module_eval(<<'.,.,', 'parser.y', 13)
137
+ def _reduce_5(val, _values, result)
138
+ result = val[0].to_i
139
+ result
140
+ end
141
+ .,.,
142
+
143
+ def _reduce_none(val, _values, result)
144
+ val[0]
145
+ end
146
+
147
+ end # class Parser
148
+ end # module EsiAttributeLanguageibute
@@ -0,0 +1,13 @@
1
+ class EsiAttributeLanguage::SimpleGrammarParser
2
+
3
+ rule
4
+ \{ { [:LBRACE, text] }
5
+ \} { [:RBRACE, text] }
6
+ \$ { [:DOLLAR, text] }
7
+ \| { [:PIPE, text] }
8
+ \( { [:LPAREN, text] }
9
+ \) { [:RPAREN, text] }
10
+ [0-9]+ { [:NUMBER, text] }
11
+ '(\\'|[^'])*' { [:OTHER, text] }
12
+ (\\\|\\\$|\\\[|\\\]|\\\)|[^\|\(\)\$\{\}]{1})* { [:OTHER, text] }
13
+ end
@@ -0,0 +1,94 @@
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/simple.rex".
5
+ #++
6
+
7
+ module EsiAttributeLanguage
8
+ class SimpleGrammarParser
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 { [:LBRACE, text] }
57
+
58
+ when (text = ss.scan(/\}/))
59
+ @rex_tokens.push action { [:RBRACE, text] }
60
+
61
+ when (text = ss.scan(/\$/))
62
+ @rex_tokens.push action { [:DOLLAR, text] }
63
+
64
+ when (text = ss.scan(/\|/))
65
+ @rex_tokens.push action { [:PIPE, text] }
66
+
67
+ when (text = ss.scan(/\(/))
68
+ @rex_tokens.push action { [:LPAREN, text] }
69
+
70
+ when (text = ss.scan(/\)/))
71
+ @rex_tokens.push action { [:RPAREN, text] }
72
+
73
+ when (text = ss.scan(/[0-9]+/))
74
+ @rex_tokens.push action { [:NUMBER, text] }
75
+
76
+ when (text = ss.scan(/'(\\'|[^'])*'/))
77
+ @rex_tokens.push action { [:OTHER, text] }
78
+
79
+ when (text = ss.scan(/(\\\|\\\$|\\\[|\\\]|\\\)|[^\|\(\)\$\{\}]{1})*/))
80
+ @rex_tokens.push action { [:OTHER, text] }
81
+
82
+ else
83
+ text = ss.string[ss.pos .. -1]
84
+ raise ScanError, "can not match: '" + text + "'"
85
+ end # if
86
+
87
+ else
88
+ raise ScanError, "undefined state: '" + state.to_s + "'"
89
+ end # case state
90
+ end # until ss
91
+ end # def scan_evaluate
92
+
93
+ end # class
94
+ end # module
@@ -0,0 +1,19 @@
1
+ class EsiAttributeLanguage::SimpleGrammarParser
2
+
3
+ token DOLLAR LPAREN RPAREN STRING VARIABLE OTHER PIPE LBRACE RBRACE QUOTE
4
+
5
+ rule
6
+ expression:
7
+ DOLLAR LPAREN variable RPAREN { result = val[2] } # $(...)
8
+ | OTHER { result = val[0] }
9
+ | DOLLAR LPAREN variable RPAREN expression { result = ConcatNode.new(val[2], val[4]) } # $(...)
10
+ | OTHER expression { result = ConcatNode.new(val[0], val[1]) }
11
+ ;
12
+
13
+ variable:
14
+ variable PIPE variable { result = OrNode.new(val[0], val[2]) }
15
+ | variable LBRACE OTHER RBRACE { result = HashLookupNode.new(val[0], Node.cleanse_string(val[2])) }
16
+ | OTHER { result = VariableLookup.new(val[0]) }
17
+ ;
18
+
19
+ end
@@ -0,0 +1,167 @@
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 SimpleGrammarParser < Racc::Parser
10
+ ##### State transition tables begin ###
11
+
12
+ racc_action_table = [
13
+ 1, 1, 1, 8, 10, 3, 3, 3, 11, 12,
14
+ 11, 12, 5, 4, 9, 15, 8, 16 ]
15
+
16
+ racc_action_check = [
17
+ 0, 10, 3, 11, 7, 0, 10, 3, 7, 7,
18
+ 14, 14, 2, 1, 5, 12, 4, 15 ]
19
+
20
+ racc_action_pointer = [
21
+ -2, 10, 12, 0, 9, 14, nil, 0, nil, nil,
22
+ -1, -4, 8, nil, 2, 7, nil ]
23
+
24
+ racc_action_default = [
25
+ -8, -8, -8, -2, -8, -8, -4, -8, -7, 17,
26
+ -1, -8, -8, -3, -5, -8, -6 ]
27
+
28
+ racc_goto_table = [
29
+ 2, 7, nil, 6, nil, nil, nil, nil, 14, nil,
30
+ 13 ]
31
+
32
+ racc_goto_check = [
33
+ 1, 2, nil, 1, nil, nil, nil, nil, 2, nil,
34
+ 1 ]
35
+
36
+ racc_goto_pointer = [
37
+ nil, 0, -3 ]
38
+
39
+ racc_goto_default = [
40
+ nil, nil, nil ]
41
+
42
+ racc_reduce_table = [
43
+ 0, 0, :racc_error,
44
+ 4, 13, :_reduce_1,
45
+ 1, 13, :_reduce_2,
46
+ 5, 13, :_reduce_3,
47
+ 2, 13, :_reduce_4,
48
+ 3, 14, :_reduce_5,
49
+ 4, 14, :_reduce_6,
50
+ 1, 14, :_reduce_7 ]
51
+
52
+ racc_reduce_n = 8
53
+
54
+ racc_shift_n = 17
55
+
56
+ racc_token_table = {
57
+ false => 0,
58
+ :error => 1,
59
+ :DOLLAR => 2,
60
+ :LPAREN => 3,
61
+ :RPAREN => 4,
62
+ :STRING => 5,
63
+ :VARIABLE => 6,
64
+ :OTHER => 7,
65
+ :PIPE => 8,
66
+ :LBRACE => 9,
67
+ :RBRACE => 10,
68
+ :QUOTE => 11 }
69
+
70
+ racc_nt_base = 12
71
+
72
+ racc_use_result_var = true
73
+
74
+ Racc_arg = [
75
+ racc_action_table,
76
+ racc_action_check,
77
+ racc_action_default,
78
+ racc_action_pointer,
79
+ racc_goto_table,
80
+ racc_goto_check,
81
+ racc_goto_default,
82
+ racc_goto_pointer,
83
+ racc_nt_base,
84
+ racc_reduce_table,
85
+ racc_token_table,
86
+ racc_shift_n,
87
+ racc_reduce_n,
88
+ racc_use_result_var ]
89
+
90
+ Racc_token_to_s_table = [
91
+ "$end",
92
+ "error",
93
+ "DOLLAR",
94
+ "LPAREN",
95
+ "RPAREN",
96
+ "STRING",
97
+ "VARIABLE",
98
+ "OTHER",
99
+ "PIPE",
100
+ "LBRACE",
101
+ "RBRACE",
102
+ "QUOTE",
103
+ "$start",
104
+ "expression",
105
+ "variable" ]
106
+
107
+ Racc_debug_parser = false
108
+
109
+ ##### State transition tables end #####
110
+
111
+ # reduce 0 omitted
112
+
113
+ module_eval(<<'.,.,', 'simple.y', 6)
114
+ def _reduce_1(val, _values, result)
115
+ result = val[2]
116
+ result
117
+ end
118
+ .,.,
119
+
120
+ module_eval(<<'.,.,', 'simple.y', 7)
121
+ def _reduce_2(val, _values, result)
122
+ result = val[0]
123
+ result
124
+ end
125
+ .,.,
126
+
127
+ module_eval(<<'.,.,', 'simple.y', 8)
128
+ def _reduce_3(val, _values, result)
129
+ result = ConcatNode.new(val[2], val[4])
130
+ result
131
+ end
132
+ .,.,
133
+
134
+ module_eval(<<'.,.,', 'simple.y', 9)
135
+ def _reduce_4(val, _values, result)
136
+ result = ConcatNode.new(val[0], val[1])
137
+ result
138
+ end
139
+ .,.,
140
+
141
+ module_eval(<<'.,.,', 'simple.y', 13)
142
+ def _reduce_5(val, _values, result)
143
+ result = OrNode.new(val[0], val[2])
144
+ result
145
+ end
146
+ .,.,
147
+
148
+ module_eval(<<'.,.,', 'simple.y', 14)
149
+ def _reduce_6(val, _values, result)
150
+ result = HashLookupNode.new(val[0], Node.cleanse_string(val[2]))
151
+ result
152
+ end
153
+ .,.,
154
+
155
+ module_eval(<<'.,.,', 'simple.y', 15)
156
+ def _reduce_7(val, _values, result)
157
+ result = VariableLookup.new(val[0])
158
+ result
159
+ end
160
+ .,.,
161
+
162
+ def _reduce_none(val, _values, result)
163
+ val[0]
164
+ end
165
+
166
+ end # class SimpleGrammarParser
167
+ end # module EsiAttributeLanguage