hotcell 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +19 -0
- data/.rspec +2 -0
- data/.rvmrc +1 -0
- data/Gemfile +15 -0
- data/Guardfile +24 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +17 -0
- data/hotcell.gemspec +22 -0
- data/lib/hotcell/.DS_Store +0 -0
- data/lib/hotcell/config.rb +31 -0
- data/lib/hotcell/context.rb +36 -0
- data/lib/hotcell/errors.rb +43 -0
- data/lib/hotcell/extensions.rb +42 -0
- data/lib/hotcell/lexer.rb +783 -0
- data/lib/hotcell/lexer.rl +299 -0
- data/lib/hotcell/manipulator.rb +31 -0
- data/lib/hotcell/node/arrayer.rb +7 -0
- data/lib/hotcell/node/assigner.rb +11 -0
- data/lib/hotcell/node/block.rb +58 -0
- data/lib/hotcell/node/calculator.rb +35 -0
- data/lib/hotcell/node/command.rb +41 -0
- data/lib/hotcell/node/hasher.rb +7 -0
- data/lib/hotcell/node/joiner.rb +7 -0
- data/lib/hotcell/node/sequencer.rb +7 -0
- data/lib/hotcell/node/summoner.rb +11 -0
- data/lib/hotcell/node/tag.rb +26 -0
- data/lib/hotcell/node.rb +55 -0
- data/lib/hotcell/parser.rb +1186 -0
- data/lib/hotcell/parser.y +231 -0
- data/lib/hotcell/scope.rb +57 -0
- data/lib/hotcell/template.rb +29 -0
- data/lib/hotcell/version.rb +3 -0
- data/lib/hotcell.rb +19 -0
- data/misc/rage.rl +1999 -0
- data/misc/unicode2ragel.rb +305 -0
- data/spec/data/dstrings +8 -0
- data/spec/data/sstrings +6 -0
- data/spec/lib/hotcell/config_spec.rb +57 -0
- data/spec/lib/hotcell/context_spec.rb +53 -0
- data/spec/lib/hotcell/lexer_spec.rb +340 -0
- data/spec/lib/hotcell/manipulator_spec.rb +64 -0
- data/spec/lib/hotcell/node/block_spec.rb +188 -0
- data/spec/lib/hotcell/node/command_spec.rb +71 -0
- data/spec/lib/hotcell/parser_spec.rb +382 -0
- data/spec/lib/hotcell/scope_spec.rb +160 -0
- data/spec/lib/hotcell/template_spec.rb +41 -0
- data/spec/lib/hotcell_spec.rb +8 -0
- data/spec/spec_helper.rb +44 -0
- metadata +139 -0
@@ -0,0 +1,783 @@
|
|
1
|
+
|
2
|
+
# line 1 "lib/hotcell/lexer.rl"
|
3
|
+
|
4
|
+
# line 97 "lib/hotcell/lexer.rl"
|
5
|
+
|
6
|
+
#%
|
7
|
+
|
8
|
+
module Hotcell
|
9
|
+
class Lexer
|
10
|
+
OPERATIONS = {
|
11
|
+
'+' => :PLUS, '-' => :MINUS, '*' => :MULTIPLY, '**' => :POWER, '/' => :DIVIDE, '%' => :MODULO,
|
12
|
+
|
13
|
+
'&&' => :AND, '||' => :OR, '!' => :NOT, '==' => :EQUAL, '!=' => :INEQUAL,
|
14
|
+
'>' => :GT, '>=' => :GTE, '<' => :LT, '<=' => :LTE,
|
15
|
+
|
16
|
+
'=' => :ASSIGN, ',' => :COMMA, '.' => :PERIOD, ':' => :COLON, '?' => :QUESTION,
|
17
|
+
';' => :SEMICOLON
|
18
|
+
}
|
19
|
+
|
20
|
+
BOPEN = { '[' => :AOPEN, '{' => :HOPEN, '(' => :POPEN }
|
21
|
+
BCLOSE = { ']' => :ACLOSE, '}' => :HCLOSE, ')' => :PCLOSE }
|
22
|
+
BRACKETS = BOPEN.merge(BCLOSE)
|
23
|
+
|
24
|
+
OPERATORS = OPERATIONS.merge(BRACKETS).merge("\n" => :NEWLINE)
|
25
|
+
|
26
|
+
CONSTANTS = {
|
27
|
+
'nil' => [:NIL, nil], 'null' => [:NIL, nil],
|
28
|
+
'false' => [:FALSE, false], 'true' => [:TRUE, true]
|
29
|
+
}
|
30
|
+
|
31
|
+
SSTRING_ESCAPE_REGEXP = /\\\'|\\\\/
|
32
|
+
SSTRING_ESCAPE_MAP = { "\\'" => "'", "\\\\" => "\\" }
|
33
|
+
|
34
|
+
DSTRING_ESCAPE_REGEXP = /\\./
|
35
|
+
DSTRING_ESCAPE_MAP = {
|
36
|
+
'\\"' => '"', "\\\\" => "\\", '\n' => "\n",
|
37
|
+
'\s' => "\s", '\r' => "\r", '\t' => "\t"
|
38
|
+
}
|
39
|
+
|
40
|
+
TAGS = {
|
41
|
+
'{{' => :TOPEN, '{{!' => :TOPEN,
|
42
|
+
'}}' => :TCLOSE
|
43
|
+
}
|
44
|
+
|
45
|
+
PREREGEXP = Set.new [
|
46
|
+
:TOPEN, :NEWLINE, :SEMICOLON,
|
47
|
+
:COLON, :COMMA, :PERIOD,
|
48
|
+
:POPEN, :AOPEN, :HOPEN
|
49
|
+
]
|
50
|
+
|
51
|
+
def initialize source
|
52
|
+
@source = source
|
53
|
+
@data = @source.unpack 'c*'
|
54
|
+
|
55
|
+
|
56
|
+
# line 57 "lib/hotcell/lexer.rb"
|
57
|
+
class << self
|
58
|
+
attr_accessor :_puffer_lexer_actions
|
59
|
+
private :_puffer_lexer_actions, :_puffer_lexer_actions=
|
60
|
+
end
|
61
|
+
self._puffer_lexer_actions = [
|
62
|
+
0, 1, 0, 1, 1, 1, 3, 1,
|
63
|
+
4, 1, 5, 1, 8, 1, 9, 1,
|
64
|
+
10, 1, 11, 1, 12, 1, 13, 1,
|
65
|
+
14, 1, 15, 1, 16, 1, 17, 1,
|
66
|
+
18, 1, 19, 1, 20, 1, 21, 1,
|
67
|
+
22, 1, 23, 1, 24, 1, 25, 1,
|
68
|
+
26, 1, 27, 1, 28, 2, 5, 2,
|
69
|
+
2, 5, 6, 2, 5, 7
|
70
|
+
]
|
71
|
+
|
72
|
+
class << self
|
73
|
+
attr_accessor :_puffer_lexer_key_offsets
|
74
|
+
private :_puffer_lexer_key_offsets, :_puffer_lexer_key_offsets=
|
75
|
+
end
|
76
|
+
self._puffer_lexer_key_offsets = [
|
77
|
+
0, 0, 2, 2, 3, 4, 6, 6,
|
78
|
+
8, 8, 10, 11, 12, 13, 14, 15,
|
79
|
+
17, 48, 49, 51, 52, 54, 56, 60,
|
80
|
+
63, 72, 73, 74, 75
|
81
|
+
]
|
82
|
+
|
83
|
+
class << self
|
84
|
+
attr_accessor :_puffer_lexer_trans_keys
|
85
|
+
private :_puffer_lexer_trans_keys, :_puffer_lexer_trans_keys=
|
86
|
+
end
|
87
|
+
self._puffer_lexer_trans_keys = [
|
88
|
+
34, 92, 125, 38, 39, 92, 47, 92,
|
89
|
+
48, 57, 124, 125, 123, 123, 123, 33,
|
90
|
+
35, 10, 32, 33, 34, 35, 38, 39,
|
91
|
+
42, 46, 47, 63, 91, 93, 95, 123,
|
92
|
+
124, 125, 9, 13, 37, 45, 48, 57,
|
93
|
+
58, 59, 60, 62, 65, 90, 97, 122,
|
94
|
+
61, 10, 125, 42, 48, 57, 47, 92,
|
95
|
+
65, 90, 97, 122, 46, 48, 57, 33,
|
96
|
+
63, 95, 48, 57, 65, 90, 97, 122,
|
97
|
+
125, 35, 35, 125, 0
|
98
|
+
]
|
99
|
+
|
100
|
+
class << self
|
101
|
+
attr_accessor :_puffer_lexer_single_lengths
|
102
|
+
private :_puffer_lexer_single_lengths, :_puffer_lexer_single_lengths=
|
103
|
+
end
|
104
|
+
self._puffer_lexer_single_lengths = [
|
105
|
+
0, 2, 0, 1, 1, 2, 0, 2,
|
106
|
+
0, 0, 1, 1, 1, 1, 1, 2,
|
107
|
+
17, 1, 2, 1, 0, 2, 0, 1,
|
108
|
+
3, 1, 1, 1, 1
|
109
|
+
]
|
110
|
+
|
111
|
+
class << self
|
112
|
+
attr_accessor :_puffer_lexer_range_lengths
|
113
|
+
private :_puffer_lexer_range_lengths, :_puffer_lexer_range_lengths=
|
114
|
+
end
|
115
|
+
self._puffer_lexer_range_lengths = [
|
116
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
117
|
+
0, 1, 0, 0, 0, 0, 0, 0,
|
118
|
+
7, 0, 0, 0, 1, 0, 2, 1,
|
119
|
+
3, 0, 0, 0, 0
|
120
|
+
]
|
121
|
+
|
122
|
+
class << self
|
123
|
+
attr_accessor :_puffer_lexer_index_offsets
|
124
|
+
private :_puffer_lexer_index_offsets, :_puffer_lexer_index_offsets=
|
125
|
+
end
|
126
|
+
self._puffer_lexer_index_offsets = [
|
127
|
+
0, 0, 3, 4, 6, 8, 11, 12,
|
128
|
+
15, 16, 18, 20, 22, 24, 26, 28,
|
129
|
+
31, 56, 58, 61, 63, 65, 68, 71,
|
130
|
+
74, 81, 83, 85, 87
|
131
|
+
]
|
132
|
+
|
133
|
+
class << self
|
134
|
+
attr_accessor :_puffer_lexer_trans_targs
|
135
|
+
private :_puffer_lexer_trans_targs, :_puffer_lexer_trans_targs=
|
136
|
+
end
|
137
|
+
self._puffer_lexer_trans_targs = [
|
138
|
+
16, 2, 1, 1, 16, 18, 16, 0,
|
139
|
+
16, 6, 5, 5, 22, 8, 7, 7,
|
140
|
+
20, 16, 16, 0, 26, 26, 14, 13,
|
141
|
+
12, 13, 15, 12, 12, 12, 12, 16,
|
142
|
+
16, 17, 1, 18, 4, 5, 19, 20,
|
143
|
+
21, 16, 16, 16, 24, 16, 10, 25,
|
144
|
+
16, 16, 23, 16, 17, 24, 24, 0,
|
145
|
+
16, 16, 16, 3, 18, 16, 16, 20,
|
146
|
+
16, 22, 8, 7, 22, 22, 16, 9,
|
147
|
+
23, 16, 16, 16, 24, 24, 24, 24,
|
148
|
+
16, 16, 16, 28, 27, 26, 27, 11,
|
149
|
+
26, 16, 16, 16, 16, 26, 12, 12,
|
150
|
+
12, 16, 16, 16, 16, 16, 16, 16,
|
151
|
+
16, 16, 26, 26, 0
|
152
|
+
]
|
153
|
+
|
154
|
+
class << self
|
155
|
+
attr_accessor :_puffer_lexer_trans_actions
|
156
|
+
private :_puffer_lexer_trans_actions, :_puffer_lexer_trans_actions=
|
157
|
+
end
|
158
|
+
self._puffer_lexer_trans_actions = [
|
159
|
+
19, 0, 0, 0, 37, 9, 13, 0,
|
160
|
+
17, 0, 0, 0, 0, 0, 0, 0,
|
161
|
+
59, 35, 13, 0, 41, 45, 0, 0,
|
162
|
+
51, 0, 0, 51, 47, 47, 49, 13,
|
163
|
+
21, 0, 0, 9, 0, 0, 0, 56,
|
164
|
+
53, 13, 13, 13, 0, 13, 0, 0,
|
165
|
+
21, 13, 9, 13, 0, 0, 0, 0,
|
166
|
+
13, 23, 31, 0, 9, 13, 23, 59,
|
167
|
+
39, 0, 0, 0, 0, 0, 29, 0,
|
168
|
+
9, 25, 15, 15, 0, 0, 0, 0,
|
169
|
+
27, 11, 23, 9, 0, 43, 0, 0,
|
170
|
+
43, 37, 33, 33, 35, 45, 51, 51,
|
171
|
+
49, 23, 31, 23, 39, 23, 29, 25,
|
172
|
+
27, 23, 43, 43, 0
|
173
|
+
]
|
174
|
+
|
175
|
+
class << self
|
176
|
+
attr_accessor :_puffer_lexer_to_state_actions
|
177
|
+
private :_puffer_lexer_to_state_actions, :_puffer_lexer_to_state_actions=
|
178
|
+
end
|
179
|
+
self._puffer_lexer_to_state_actions = [
|
180
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
181
|
+
0, 0, 0, 0, 5, 0, 0, 0,
|
182
|
+
5, 0, 0, 0, 0, 0, 0, 0,
|
183
|
+
0, 0, 5, 0, 0
|
184
|
+
]
|
185
|
+
|
186
|
+
class << self
|
187
|
+
attr_accessor :_puffer_lexer_from_state_actions
|
188
|
+
private :_puffer_lexer_from_state_actions, :_puffer_lexer_from_state_actions=
|
189
|
+
end
|
190
|
+
self._puffer_lexer_from_state_actions = [
|
191
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
192
|
+
0, 0, 0, 0, 7, 0, 0, 0,
|
193
|
+
7, 0, 0, 0, 0, 0, 0, 0,
|
194
|
+
0, 0, 7, 0, 0
|
195
|
+
]
|
196
|
+
|
197
|
+
class << self
|
198
|
+
attr_accessor :_puffer_lexer_eof_actions
|
199
|
+
private :_puffer_lexer_eof_actions, :_puffer_lexer_eof_actions=
|
200
|
+
end
|
201
|
+
self._puffer_lexer_eof_actions = [
|
202
|
+
0, 3, 0, 0, 0, 1, 0, 0,
|
203
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
204
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
205
|
+
0, 0, 0, 0, 0
|
206
|
+
]
|
207
|
+
|
208
|
+
class << self
|
209
|
+
attr_accessor :_puffer_lexer_eof_trans
|
210
|
+
private :_puffer_lexer_eof_trans, :_puffer_lexer_eof_trans=
|
211
|
+
end
|
212
|
+
self._puffer_lexer_eof_trans = [
|
213
|
+
0, 0, 0, 90, 0, 0, 0, 92,
|
214
|
+
92, 93, 0, 94, 0, 96, 96, 97,
|
215
|
+
0, 106, 99, 106, 101, 106, 103, 104,
|
216
|
+
105, 106, 0, 108, 108
|
217
|
+
]
|
218
|
+
|
219
|
+
class << self
|
220
|
+
attr_accessor :puffer_lexer_start
|
221
|
+
end
|
222
|
+
self.puffer_lexer_start = 12;
|
223
|
+
class << self
|
224
|
+
attr_accessor :puffer_lexer_first_final
|
225
|
+
end
|
226
|
+
self.puffer_lexer_first_final = 12;
|
227
|
+
class << self
|
228
|
+
attr_accessor :puffer_lexer_error
|
229
|
+
end
|
230
|
+
self.puffer_lexer_error = 0;
|
231
|
+
|
232
|
+
class << self
|
233
|
+
attr_accessor :puffer_lexer_en_expression
|
234
|
+
end
|
235
|
+
self.puffer_lexer_en_expression = 16;
|
236
|
+
class << self
|
237
|
+
attr_accessor :puffer_lexer_en_template_comment
|
238
|
+
end
|
239
|
+
self.puffer_lexer_en_template_comment = 26;
|
240
|
+
class << self
|
241
|
+
attr_accessor :puffer_lexer_en_main
|
242
|
+
end
|
243
|
+
self.puffer_lexer_en_main = 12;
|
244
|
+
|
245
|
+
|
246
|
+
# line 148 "lib/hotcell/lexer.rl"
|
247
|
+
#%
|
248
|
+
end
|
249
|
+
|
250
|
+
def emit symbol, value
|
251
|
+
@token_array << [symbol, value]
|
252
|
+
end
|
253
|
+
|
254
|
+
def current_value
|
255
|
+
@data[@ts...@te].pack('c*').force_encoding('UTF-8')
|
256
|
+
end
|
257
|
+
|
258
|
+
def emit_operator
|
259
|
+
value = current_value
|
260
|
+
emit OPERATORS[value], value
|
261
|
+
end
|
262
|
+
|
263
|
+
def emit_numeric
|
264
|
+
# last = @token_array[-1]
|
265
|
+
# pre_last = @token_array[-2]
|
266
|
+
# # This need to give unary minus with numeric higher precedence then unari minus with
|
267
|
+
# last[0] = :NEGATIVE if last && last[0] == :MINUS &&
|
268
|
+
# (!pre_last || pre_last[0].in?())
|
269
|
+
|
270
|
+
value = current_value
|
271
|
+
if value =~ /\./
|
272
|
+
emit :FLOAT, Float(value)
|
273
|
+
else
|
274
|
+
emit :INTEGER, Integer(value)
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
278
|
+
def emit_identifer
|
279
|
+
value = current_value
|
280
|
+
if args = CONSTANTS[value]
|
281
|
+
emit *args
|
282
|
+
else
|
283
|
+
emit :IDENTIFER, value
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
def emit_sstring
|
288
|
+
emit :STRING, current_value[1..-2].gsub(SSTRING_ESCAPE_REGEXP) { |match|
|
289
|
+
SSTRING_ESCAPE_MAP[match] }.force_encoding('UTF-8')
|
290
|
+
end
|
291
|
+
|
292
|
+
def emit_dstring
|
293
|
+
emit :STRING, current_value[1..-2].gsub(DSTRING_ESCAPE_REGEXP) { |match|
|
294
|
+
DSTRING_ESCAPE_MAP[match] || match[1] }
|
295
|
+
end
|
296
|
+
|
297
|
+
def regexp_ambiguity
|
298
|
+
unless regexp_possible?
|
299
|
+
emit_operator
|
300
|
+
yield
|
301
|
+
end
|
302
|
+
end
|
303
|
+
|
304
|
+
def regexp_possible?
|
305
|
+
last = @token_array[-1]
|
306
|
+
# Need more rules!
|
307
|
+
!last || PREREGEXP.include?(last[0])
|
308
|
+
end
|
309
|
+
|
310
|
+
def emit_regexp
|
311
|
+
value = current_value
|
312
|
+
finish = value.rindex('/')
|
313
|
+
|
314
|
+
options_string = value[finish+1..-1]
|
315
|
+
options = 0
|
316
|
+
options |= Regexp::EXTENDED if options_string.include?('x')
|
317
|
+
options |= Regexp::IGNORECASE if options_string.include?('i')
|
318
|
+
options |= Regexp::MULTILINE if options_string.include?('m')
|
319
|
+
|
320
|
+
emit :REGEXP, Regexp.new(value[1..finish-1], options)
|
321
|
+
end
|
322
|
+
|
323
|
+
def emit_template
|
324
|
+
# Hack this to glue templates going straight
|
325
|
+
last = @token_array[-1]
|
326
|
+
if last && last[0] == :TEMPLATE
|
327
|
+
last[1] += current_value
|
328
|
+
else
|
329
|
+
emit :TEMPLATE, current_value
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
333
|
+
def emit_tag_or_comment if_tag, if_comment
|
334
|
+
value = current_value
|
335
|
+
if value == '{{#'
|
336
|
+
emit_comment
|
337
|
+
if_comment.call
|
338
|
+
else
|
339
|
+
emit_tag
|
340
|
+
if_tag.call
|
341
|
+
end
|
342
|
+
end
|
343
|
+
|
344
|
+
def emit_tag
|
345
|
+
value = current_value
|
346
|
+
emit TAGS[value], value
|
347
|
+
end
|
348
|
+
|
349
|
+
def emit_comment
|
350
|
+
last = @token_array[-1]
|
351
|
+
if last && last[0] == :COMMENT
|
352
|
+
last[1] += current_value
|
353
|
+
else
|
354
|
+
emit :COMMENT, current_value
|
355
|
+
end
|
356
|
+
end
|
357
|
+
|
358
|
+
def current_position
|
359
|
+
parsed = @data[0..@ts].pack('c*').force_encoding('UTF-8')
|
360
|
+
line = parsed.count("\n") + 1
|
361
|
+
column = parsed.size - 1 - (parsed.rindex("\n") || -1)
|
362
|
+
[line, column]
|
363
|
+
end
|
364
|
+
|
365
|
+
def raise_unexpected_symbol
|
366
|
+
raise Hotcell::Errors::UnexpectedSymbol.new *current_position
|
367
|
+
end
|
368
|
+
|
369
|
+
def raise_unterminated_string
|
370
|
+
raise Hotcell::Errors::UnterminatedString.new *current_position
|
371
|
+
end
|
372
|
+
|
373
|
+
def raise_unterminated_regexp
|
374
|
+
raise Hotcell::Errors::UnterminatedRegexp.new *current_position
|
375
|
+
end
|
376
|
+
|
377
|
+
def tokens
|
378
|
+
@tokens ||= tokenize
|
379
|
+
end
|
380
|
+
|
381
|
+
def tokenize
|
382
|
+
@token_array = []
|
383
|
+
|
384
|
+
|
385
|
+
# line 386 "lib/hotcell/lexer.rb"
|
386
|
+
begin
|
387
|
+
p ||= 0
|
388
|
+
pe ||= @data.length
|
389
|
+
cs = puffer_lexer_start
|
390
|
+
top = 0
|
391
|
+
@ts = nil
|
392
|
+
@te = nil
|
393
|
+
act = 0
|
394
|
+
end
|
395
|
+
|
396
|
+
# line 286 "lib/hotcell/lexer.rl"
|
397
|
+
#%
|
398
|
+
|
399
|
+
eof = pe
|
400
|
+
stack = []
|
401
|
+
|
402
|
+
|
403
|
+
# line 404 "lib/hotcell/lexer.rb"
|
404
|
+
begin
|
405
|
+
_klen, _trans, _keys, _acts, _nacts = nil
|
406
|
+
_goto_level = 0
|
407
|
+
_resume = 10
|
408
|
+
_eof_trans = 15
|
409
|
+
_again = 20
|
410
|
+
_test_eof = 30
|
411
|
+
_out = 40
|
412
|
+
while true
|
413
|
+
_trigger_goto = false
|
414
|
+
if _goto_level <= 0
|
415
|
+
if p == pe
|
416
|
+
_goto_level = _test_eof
|
417
|
+
next
|
418
|
+
end
|
419
|
+
if cs == 0
|
420
|
+
_goto_level = _out
|
421
|
+
next
|
422
|
+
end
|
423
|
+
end
|
424
|
+
if _goto_level <= _resume
|
425
|
+
_acts = _puffer_lexer_from_state_actions[cs]
|
426
|
+
_nacts = _puffer_lexer_actions[_acts]
|
427
|
+
_acts += 1
|
428
|
+
while _nacts > 0
|
429
|
+
_nacts -= 1
|
430
|
+
_acts += 1
|
431
|
+
case _puffer_lexer_actions[_acts - 1]
|
432
|
+
when 4 then
|
433
|
+
# line 1 "NONE"
|
434
|
+
begin
|
435
|
+
@ts = p
|
436
|
+
end
|
437
|
+
# line 438 "lib/hotcell/lexer.rb"
|
438
|
+
end # from state action switch
|
439
|
+
end
|
440
|
+
if _trigger_goto
|
441
|
+
next
|
442
|
+
end
|
443
|
+
_keys = _puffer_lexer_key_offsets[cs]
|
444
|
+
_trans = _puffer_lexer_index_offsets[cs]
|
445
|
+
_klen = _puffer_lexer_single_lengths[cs]
|
446
|
+
_break_match = false
|
447
|
+
|
448
|
+
begin
|
449
|
+
if _klen > 0
|
450
|
+
_lower = _keys
|
451
|
+
_upper = _keys + _klen - 1
|
452
|
+
|
453
|
+
loop do
|
454
|
+
break if _upper < _lower
|
455
|
+
_mid = _lower + ( (_upper - _lower) >> 1 )
|
456
|
+
|
457
|
+
if @data[p].ord < _puffer_lexer_trans_keys[_mid]
|
458
|
+
_upper = _mid - 1
|
459
|
+
elsif @data[p].ord > _puffer_lexer_trans_keys[_mid]
|
460
|
+
_lower = _mid + 1
|
461
|
+
else
|
462
|
+
_trans += (_mid - _keys)
|
463
|
+
_break_match = true
|
464
|
+
break
|
465
|
+
end
|
466
|
+
end # loop
|
467
|
+
break if _break_match
|
468
|
+
_keys += _klen
|
469
|
+
_trans += _klen
|
470
|
+
end
|
471
|
+
_klen = _puffer_lexer_range_lengths[cs]
|
472
|
+
if _klen > 0
|
473
|
+
_lower = _keys
|
474
|
+
_upper = _keys + (_klen << 1) - 2
|
475
|
+
loop do
|
476
|
+
break if _upper < _lower
|
477
|
+
_mid = _lower + (((_upper-_lower) >> 1) & ~1)
|
478
|
+
if @data[p].ord < _puffer_lexer_trans_keys[_mid]
|
479
|
+
_upper = _mid - 2
|
480
|
+
elsif @data[p].ord > _puffer_lexer_trans_keys[_mid+1]
|
481
|
+
_lower = _mid + 2
|
482
|
+
else
|
483
|
+
_trans += ((_mid - _keys) >> 1)
|
484
|
+
_break_match = true
|
485
|
+
break
|
486
|
+
end
|
487
|
+
end # loop
|
488
|
+
break if _break_match
|
489
|
+
_trans += _klen
|
490
|
+
end
|
491
|
+
end while false
|
492
|
+
end
|
493
|
+
if _goto_level <= _eof_trans
|
494
|
+
cs = _puffer_lexer_trans_targs[_trans]
|
495
|
+
if _puffer_lexer_trans_actions[_trans] != 0
|
496
|
+
_acts = _puffer_lexer_trans_actions[_trans]
|
497
|
+
_nacts = _puffer_lexer_actions[_acts]
|
498
|
+
_acts += 1
|
499
|
+
while _nacts > 0
|
500
|
+
_nacts -= 1
|
501
|
+
_acts += 1
|
502
|
+
case _puffer_lexer_actions[_acts - 1]
|
503
|
+
when 2 then
|
504
|
+
# line 58 "lib/hotcell/lexer.rl"
|
505
|
+
begin
|
506
|
+
regexp_ambiguity { begin
|
507
|
+
cs = 16
|
508
|
+
_trigger_goto = true
|
509
|
+
_goto_level = _again
|
510
|
+
break
|
511
|
+
end
|
512
|
+
} end
|
513
|
+
when 5 then
|
514
|
+
# line 1 "NONE"
|
515
|
+
begin
|
516
|
+
@te = p+1
|
517
|
+
end
|
518
|
+
when 6 then
|
519
|
+
# line 78 "lib/hotcell/lexer.rl"
|
520
|
+
begin
|
521
|
+
act = 2; end
|
522
|
+
when 7 then
|
523
|
+
# line 79 "lib/hotcell/lexer.rl"
|
524
|
+
begin
|
525
|
+
act = 3; end
|
526
|
+
when 8 then
|
527
|
+
# line 77 "lib/hotcell/lexer.rl"
|
528
|
+
begin
|
529
|
+
@te = p+1
|
530
|
+
begin emit_tag; begin
|
531
|
+
top -= 1
|
532
|
+
cs = stack[top]
|
533
|
+
_trigger_goto = true
|
534
|
+
_goto_level = _again
|
535
|
+
break
|
536
|
+
end
|
537
|
+
end
|
538
|
+
end
|
539
|
+
when 9 then
|
540
|
+
# line 78 "lib/hotcell/lexer.rl"
|
541
|
+
begin
|
542
|
+
@te = p+1
|
543
|
+
begin emit_operator end
|
544
|
+
end
|
545
|
+
when 10 then
|
546
|
+
# line 80 "lib/hotcell/lexer.rl"
|
547
|
+
begin
|
548
|
+
@te = p+1
|
549
|
+
begin emit_identifer end
|
550
|
+
end
|
551
|
+
when 11 then
|
552
|
+
# line 81 "lib/hotcell/lexer.rl"
|
553
|
+
begin
|
554
|
+
@te = p+1
|
555
|
+
begin emit_sstring end
|
556
|
+
end
|
557
|
+
when 12 then
|
558
|
+
# line 82 "lib/hotcell/lexer.rl"
|
559
|
+
begin
|
560
|
+
@te = p+1
|
561
|
+
begin emit_dstring end
|
562
|
+
end
|
563
|
+
when 13 then
|
564
|
+
# line 85 "lib/hotcell/lexer.rl"
|
565
|
+
begin
|
566
|
+
@te = p+1
|
567
|
+
end
|
568
|
+
when 14 then
|
569
|
+
# line 78 "lib/hotcell/lexer.rl"
|
570
|
+
begin
|
571
|
+
@te = p
|
572
|
+
p = p - 1; begin emit_operator end
|
573
|
+
end
|
574
|
+
when 15 then
|
575
|
+
# line 79 "lib/hotcell/lexer.rl"
|
576
|
+
begin
|
577
|
+
@te = p
|
578
|
+
p = p - 1; begin emit_numeric end
|
579
|
+
end
|
580
|
+
when 16 then
|
581
|
+
# line 80 "lib/hotcell/lexer.rl"
|
582
|
+
begin
|
583
|
+
@te = p
|
584
|
+
p = p - 1; begin emit_identifer end
|
585
|
+
end
|
586
|
+
when 17 then
|
587
|
+
# line 83 "lib/hotcell/lexer.rl"
|
588
|
+
begin
|
589
|
+
@te = p
|
590
|
+
p = p - 1; begin emit_regexp end
|
591
|
+
end
|
592
|
+
when 18 then
|
593
|
+
# line 84 "lib/hotcell/lexer.rl"
|
594
|
+
begin
|
595
|
+
@te = p
|
596
|
+
p = p - 1; begin emit_comment end
|
597
|
+
end
|
598
|
+
when 19 then
|
599
|
+
# line 78 "lib/hotcell/lexer.rl"
|
600
|
+
begin
|
601
|
+
begin p = (( @te))-1; end
|
602
|
+
begin emit_operator end
|
603
|
+
end
|
604
|
+
when 20 then
|
605
|
+
# line 79 "lib/hotcell/lexer.rl"
|
606
|
+
begin
|
607
|
+
begin p = (( @te))-1; end
|
608
|
+
begin emit_numeric end
|
609
|
+
end
|
610
|
+
when 21 then
|
611
|
+
# line 84 "lib/hotcell/lexer.rl"
|
612
|
+
begin
|
613
|
+
begin p = (( @te))-1; end
|
614
|
+
begin emit_comment end
|
615
|
+
end
|
616
|
+
when 22 then
|
617
|
+
# line 1 "NONE"
|
618
|
+
begin
|
619
|
+
case act
|
620
|
+
when 2 then
|
621
|
+
begin begin p = (( @te))-1; end
|
622
|
+
emit_operator end
|
623
|
+
when 3 then
|
624
|
+
begin begin p = (( @te))-1; end
|
625
|
+
emit_numeric end
|
626
|
+
end
|
627
|
+
end
|
628
|
+
when 23 then
|
629
|
+
# line 89 "lib/hotcell/lexer.rl"
|
630
|
+
begin
|
631
|
+
@te = p+1
|
632
|
+
begin emit_comment; begin
|
633
|
+
top -= 1
|
634
|
+
cs = stack[top]
|
635
|
+
_trigger_goto = true
|
636
|
+
_goto_level = _again
|
637
|
+
break
|
638
|
+
end
|
639
|
+
end
|
640
|
+
end
|
641
|
+
when 24 then
|
642
|
+
# line 90 "lib/hotcell/lexer.rl"
|
643
|
+
begin
|
644
|
+
@te = p
|
645
|
+
p = p - 1; begin emit_comment end
|
646
|
+
end
|
647
|
+
when 25 then
|
648
|
+
# line 90 "lib/hotcell/lexer.rl"
|
649
|
+
begin
|
650
|
+
begin p = (( @te))-1; end
|
651
|
+
begin emit_comment end
|
652
|
+
end
|
653
|
+
when 26 then
|
654
|
+
# line 94 "lib/hotcell/lexer.rl"
|
655
|
+
begin
|
656
|
+
@te = p+1
|
657
|
+
begin emit_tag_or_comment ->{ begin
|
658
|
+
stack[top] = cs
|
659
|
+
top+= 1
|
660
|
+
cs = 16
|
661
|
+
_trigger_goto = true
|
662
|
+
_goto_level = _again
|
663
|
+
break
|
664
|
+
end
|
665
|
+
}, ->{ begin
|
666
|
+
stack[top] = cs
|
667
|
+
top+= 1
|
668
|
+
cs = 26
|
669
|
+
_trigger_goto = true
|
670
|
+
_goto_level = _again
|
671
|
+
break
|
672
|
+
end
|
673
|
+
} end
|
674
|
+
end
|
675
|
+
when 27 then
|
676
|
+
# line 94 "lib/hotcell/lexer.rl"
|
677
|
+
begin
|
678
|
+
@te = p
|
679
|
+
p = p - 1; begin emit_tag_or_comment ->{ begin
|
680
|
+
stack[top] = cs
|
681
|
+
top+= 1
|
682
|
+
cs = 16
|
683
|
+
_trigger_goto = true
|
684
|
+
_goto_level = _again
|
685
|
+
break
|
686
|
+
end
|
687
|
+
}, ->{ begin
|
688
|
+
stack[top] = cs
|
689
|
+
top+= 1
|
690
|
+
cs = 26
|
691
|
+
_trigger_goto = true
|
692
|
+
_goto_level = _again
|
693
|
+
break
|
694
|
+
end
|
695
|
+
} end
|
696
|
+
end
|
697
|
+
when 28 then
|
698
|
+
# line 95 "lib/hotcell/lexer.rl"
|
699
|
+
begin
|
700
|
+
@te = p
|
701
|
+
p = p - 1; begin emit_template end
|
702
|
+
end
|
703
|
+
# line 704 "lib/hotcell/lexer.rb"
|
704
|
+
end # action switch
|
705
|
+
end
|
706
|
+
end
|
707
|
+
if _trigger_goto
|
708
|
+
next
|
709
|
+
end
|
710
|
+
end
|
711
|
+
if _goto_level <= _again
|
712
|
+
_acts = _puffer_lexer_to_state_actions[cs]
|
713
|
+
_nacts = _puffer_lexer_actions[_acts]
|
714
|
+
_acts += 1
|
715
|
+
while _nacts > 0
|
716
|
+
_nacts -= 1
|
717
|
+
_acts += 1
|
718
|
+
case _puffer_lexer_actions[_acts - 1]
|
719
|
+
when 3 then
|
720
|
+
# line 1 "NONE"
|
721
|
+
begin
|
722
|
+
@ts = nil; end
|
723
|
+
# line 724 "lib/hotcell/lexer.rb"
|
724
|
+
end # to state action switch
|
725
|
+
end
|
726
|
+
if _trigger_goto
|
727
|
+
next
|
728
|
+
end
|
729
|
+
if cs == 0
|
730
|
+
_goto_level = _out
|
731
|
+
next
|
732
|
+
end
|
733
|
+
p += 1
|
734
|
+
if p != pe
|
735
|
+
_goto_level = _resume
|
736
|
+
next
|
737
|
+
end
|
738
|
+
end
|
739
|
+
if _goto_level <= _test_eof
|
740
|
+
if p == eof
|
741
|
+
if _puffer_lexer_eof_trans[cs] > 0
|
742
|
+
_trans = _puffer_lexer_eof_trans[cs] - 1;
|
743
|
+
_goto_level = _eof_trans
|
744
|
+
next;
|
745
|
+
end
|
746
|
+
__acts = _puffer_lexer_eof_actions[cs]
|
747
|
+
__nacts = _puffer_lexer_actions[__acts]
|
748
|
+
__acts += 1
|
749
|
+
while __nacts > 0
|
750
|
+
__nacts -= 1
|
751
|
+
__acts += 1
|
752
|
+
case _puffer_lexer_actions[__acts - 1]
|
753
|
+
when 0 then
|
754
|
+
# line 50 "lib/hotcell/lexer.rl"
|
755
|
+
begin
|
756
|
+
raise_unterminated_string end
|
757
|
+
when 1 then
|
758
|
+
# line 54 "lib/hotcell/lexer.rl"
|
759
|
+
begin
|
760
|
+
raise_unterminated_string end
|
761
|
+
# line 762 "lib/hotcell/lexer.rb"
|
762
|
+
end # eof action switch
|
763
|
+
end
|
764
|
+
if _trigger_goto
|
765
|
+
next
|
766
|
+
end
|
767
|
+
end
|
768
|
+
end
|
769
|
+
if _goto_level <= _out
|
770
|
+
break
|
771
|
+
end
|
772
|
+
end
|
773
|
+
end
|
774
|
+
|
775
|
+
# line 292 "lib/hotcell/lexer.rl"
|
776
|
+
#%
|
777
|
+
|
778
|
+
raise_unexpected_symbol unless @ts.nil?
|
779
|
+
|
780
|
+
@token_array
|
781
|
+
end
|
782
|
+
end
|
783
|
+
end
|