eggshell 1.0.3 → 1.1.1

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,45 @@
1
+ module Eggshell; class ExpressionEvaluator;
2
+ class Evaluator
3
+ def initialize(vtable, ftable)
4
+ @vtable = vtable
5
+ @ftable = ftable
6
+ end
7
+
8
+ def evaluate(struct)
9
+ ret = nil
10
+ struct.each do |frag|
11
+ if frag.is_a?(Array)
12
+ if frag[0] == :op
13
+
14
+ elsif frag[0] == :op_tern
15
+
16
+ elsif frag[0] == :func
17
+ buff << frag[1] + '('
18
+ buff << reassemble(frag[2], ',')
19
+ buff << ')'
20
+ elsif frag[0] == :group
21
+
22
+ elsif frag[0] == :var
23
+
24
+ elsif frag[0] == :index_access
25
+
26
+ end
27
+ else
28
+ buff << s
29
+ buff << (frag.is_a?(String) ? '"' + frag.gsub('"', '\\"') + '"' : frag)
30
+ s = sep
31
+ end
32
+ end
33
+ end
34
+
35
+ # @param String|Array var If `var` is a string and contains only alphanumeric/dot characters,
36
+ # an attempt will be made to match an exact var name with that, otherwise, it will be decomposed
37
+ # and each part will be looked up successively.
38
+ def get_var(var, do_ptr = false)
39
+
40
+ end
41
+
42
+ def set_var(var, val)
43
+ end
44
+ end
45
+ end; end;
@@ -0,0 +1,473 @@
1
+
2
+ # line 1 "lexer.ragel"
3
+
4
+ # line 71 "lexer.ragel"
5
+
6
+ # %
7
+
8
+ module Eggshell; class ExpressionEvaluator
9
+ class Eggshell::ExpressionEvaluator::Lexer
10
+
11
+ def initialize(parser)
12
+ @parser = parser
13
+
14
+ # line 15 "lexer.rb"
15
+ class << self
16
+ attr_accessor :_eggshell_actions
17
+ private :_eggshell_actions, :_eggshell_actions=
18
+ end
19
+ self._eggshell_actions = [
20
+ 0, 1, 0, 1, 1, 1, 2, 1,
21
+ 3, 1, 4, 1, 5, 1, 6, 1,
22
+ 7, 1, 8, 1, 9, 1, 10, 1,
23
+ 11, 1, 12, 1, 13, 1, 14, 1,
24
+ 15, 1, 16, 1, 17, 1, 18, 1,
25
+ 19
26
+ ]
27
+
28
+ class << self
29
+ attr_accessor :_eggshell_key_offsets
30
+ private :_eggshell_key_offsets, :_eggshell_key_offsets=
31
+ end
32
+ self._eggshell_key_offsets = [
33
+ 0, 2, 38, 43, 44, 46, 49, 51,
34
+ 52, 54, 55, 56, 58, 68
35
+ ]
36
+
37
+ class << self
38
+ attr_accessor :_eggshell_trans_keys
39
+ private :_eggshell_trans_keys, :_eggshell_trans_keys=
40
+ end
41
+ self._eggshell_trans_keys = [
42
+ 48, 57, 13, 32, 34, 36, 38, 39,
43
+ 43, 44, 45, 46, 58, 59, 60, 61,
44
+ 62, 63, 64, 91, 92, 93, 94, 124,
45
+ 9, 10, 40, 41, 42, 47, 48, 57,
46
+ 65, 95, 97, 122, 123, 125, 95, 65,
47
+ 90, 97, 122, 38, 48, 57, 46, 48,
48
+ 57, 48, 57, 58, 60, 61, 61, 61,
49
+ 61, 62, 34, 91, 93, 110, 114, 116,
50
+ 123, 125, 39, 41, 124, 0
51
+ ]
52
+
53
+ class << self
54
+ attr_accessor :_eggshell_single_lengths
55
+ private :_eggshell_single_lengths, :_eggshell_single_lengths=
56
+ end
57
+ self._eggshell_single_lengths = [
58
+ 0, 22, 1, 1, 0, 1, 0, 1,
59
+ 0, 1, 1, 0, 8, 1
60
+ ]
61
+
62
+ class << self
63
+ attr_accessor :_eggshell_range_lengths
64
+ private :_eggshell_range_lengths, :_eggshell_range_lengths=
65
+ end
66
+ self._eggshell_range_lengths = [
67
+ 1, 7, 2, 0, 1, 1, 1, 0,
68
+ 1, 0, 0, 1, 1, 0
69
+ ]
70
+
71
+ class << self
72
+ attr_accessor :_eggshell_index_offsets
73
+ private :_eggshell_index_offsets, :_eggshell_index_offsets=
74
+ end
75
+ self._eggshell_index_offsets = [
76
+ 0, 2, 32, 36, 38, 40, 43, 45,
77
+ 47, 49, 51, 53, 55, 65
78
+ ]
79
+
80
+ class << self
81
+ attr_accessor :_eggshell_indicies
82
+ private :_eggshell_indicies, :_eggshell_indicies=
83
+ end
84
+ self._eggshell_indicies = [
85
+ 1, 0, 3, 3, 4, 5, 6, 4,
86
+ 9, 10, 9, 10, 12, 10, 13, 14,
87
+ 15, 8, 16, 17, 18, 17, 8, 20,
88
+ 3, 7, 8, 11, 5, 5, 19, 2,
89
+ 5, 5, 5, 21, 8, 22, 11, 23,
90
+ 25, 11, 24, 1, 26, 16, 27, 8,
91
+ 23, 28, 23, 8, 23, 8, 23, 29,
92
+ 29, 29, 29, 29, 29, 29, 29, 29,
93
+ 22, 8, 22, 0
94
+ ]
95
+
96
+ class << self
97
+ attr_accessor :_eggshell_trans_targs
98
+ private :_eggshell_trans_targs, :_eggshell_trans_targs=
99
+ end
100
+ self._eggshell_trans_targs = [
101
+ 1, 6, 1, 1, 1, 2, 3, 1,
102
+ 1, 4, 1, 5, 7, 8, 9, 11,
103
+ 1, 1, 12, 1, 13, 1, 1, 1,
104
+ 1, 0, 1, 1, 10, 1
105
+ ]
106
+
107
+ class << self
108
+ attr_accessor :_eggshell_trans_actions
109
+ private :_eggshell_trans_actions, :_eggshell_trans_actions=
110
+ end
111
+ self._eggshell_trans_actions = [
112
+ 39, 0, 25, 23, 15, 0, 0, 13,
113
+ 7, 0, 19, 5, 0, 0, 0, 0,
114
+ 17, 9, 0, 11, 0, 31, 37, 33,
115
+ 27, 0, 29, 35, 0, 21
116
+ ]
117
+
118
+ class << self
119
+ attr_accessor :_eggshell_to_state_actions
120
+ private :_eggshell_to_state_actions, :_eggshell_to_state_actions=
121
+ end
122
+ self._eggshell_to_state_actions = [
123
+ 0, 1, 0, 0, 0, 0, 0, 0,
124
+ 0, 0, 0, 0, 0, 0
125
+ ]
126
+
127
+ class << self
128
+ attr_accessor :_eggshell_from_state_actions
129
+ private :_eggshell_from_state_actions, :_eggshell_from_state_actions=
130
+ end
131
+ self._eggshell_from_state_actions = [
132
+ 0, 3, 0, 0, 0, 0, 0, 0,
133
+ 0, 0, 0, 0, 0, 0
134
+ ]
135
+
136
+ class << self
137
+ attr_accessor :_eggshell_eof_trans
138
+ private :_eggshell_eof_trans, :_eggshell_eof_trans=
139
+ end
140
+ self._eggshell_eof_trans = [
141
+ 1, 0, 22, 23, 24, 25, 27, 28,
142
+ 24, 24, 24, 24, 23, 23
143
+ ]
144
+
145
+ class << self
146
+ attr_accessor :eggshell_start
147
+ end
148
+ self.eggshell_start = 1;
149
+ class << self
150
+ attr_accessor :eggshell_first_final
151
+ end
152
+ self.eggshell_first_final = 1;
153
+ class << self
154
+ attr_accessor :eggshell_error
155
+ end
156
+ self.eggshell_error = -1;
157
+
158
+ class << self
159
+ attr_accessor :eggshell_en_main
160
+ end
161
+ self.eggshell_en_main = 1;
162
+
163
+
164
+ # line 80 "lexer.ragel"
165
+ # %
166
+ end
167
+
168
+ def process(source)
169
+ data = source.is_a?(String) ? source.unpack("c*") : source
170
+ eof = data.length
171
+
172
+ # line 173 "lexer.rb"
173
+ begin
174
+ p ||= 0
175
+ pe ||= data.length
176
+ cs = eggshell_start
177
+ ts = nil
178
+ te = nil
179
+ act = 0
180
+ end
181
+
182
+ # line 87 "lexer.ragel"
183
+
184
+ # line 185 "lexer.rb"
185
+ begin
186
+ _klen, _trans, _keys, _acts, _nacts = nil
187
+ _goto_level = 0
188
+ _resume = 10
189
+ _eof_trans = 15
190
+ _again = 20
191
+ _test_eof = 30
192
+ _out = 40
193
+ while true
194
+ _trigger_goto = false
195
+ if _goto_level <= 0
196
+ if p == pe
197
+ _goto_level = _test_eof
198
+ next
199
+ end
200
+ end
201
+ if _goto_level <= _resume
202
+ _acts = _eggshell_from_state_actions[cs]
203
+ _nacts = _eggshell_actions[_acts]
204
+ _acts += 1
205
+ while _nacts > 0
206
+ _nacts -= 1
207
+ _acts += 1
208
+ case _eggshell_actions[_acts - 1]
209
+ when 1 then
210
+ # line 1 "NONE"
211
+ begin
212
+ ts = p
213
+ end
214
+ # line 215 "lexer.rb"
215
+ end # from state action switch
216
+ end
217
+ if _trigger_goto
218
+ next
219
+ end
220
+ _keys = _eggshell_key_offsets[cs]
221
+ _trans = _eggshell_index_offsets[cs]
222
+ _klen = _eggshell_single_lengths[cs]
223
+ _break_match = false
224
+
225
+ begin
226
+ if _klen > 0
227
+ _lower = _keys
228
+ _upper = _keys + _klen - 1
229
+
230
+ loop do
231
+ break if _upper < _lower
232
+ _mid = _lower + ( (_upper - _lower) >> 1 )
233
+
234
+ if data[p].ord < _eggshell_trans_keys[_mid]
235
+ _upper = _mid - 1
236
+ elsif data[p].ord > _eggshell_trans_keys[_mid]
237
+ _lower = _mid + 1
238
+ else
239
+ _trans += (_mid - _keys)
240
+ _break_match = true
241
+ break
242
+ end
243
+ end # loop
244
+ break if _break_match
245
+ _keys += _klen
246
+ _trans += _klen
247
+ end
248
+ _klen = _eggshell_range_lengths[cs]
249
+ if _klen > 0
250
+ _lower = _keys
251
+ _upper = _keys + (_klen << 1) - 2
252
+ loop do
253
+ break if _upper < _lower
254
+ _mid = _lower + (((_upper-_lower) >> 1) & ~1)
255
+ if data[p].ord < _eggshell_trans_keys[_mid]
256
+ _upper = _mid - 2
257
+ elsif data[p].ord > _eggshell_trans_keys[_mid+1]
258
+ _lower = _mid + 2
259
+ else
260
+ _trans += ((_mid - _keys) >> 1)
261
+ _break_match = true
262
+ break
263
+ end
264
+ end # loop
265
+ break if _break_match
266
+ _trans += _klen
267
+ end
268
+ end while false
269
+ _trans = _eggshell_indicies[_trans]
270
+ end
271
+ if _goto_level <= _eof_trans
272
+ cs = _eggshell_trans_targs[_trans]
273
+ if _eggshell_trans_actions[_trans] != 0
274
+ _acts = _eggshell_trans_actions[_trans]
275
+ _nacts = _eggshell_actions[_acts]
276
+ _acts += 1
277
+ while _nacts > 0
278
+ _nacts -= 1
279
+ _acts += 1
280
+ case _eggshell_actions[_acts - 1]
281
+ when 2 then
282
+ # line 1 "NONE"
283
+ begin
284
+ te = p+1
285
+ end
286
+ when 3 then
287
+ # line 31 "lexer.ragel"
288
+ begin
289
+ te = p+1
290
+ begin
291
+ @parser.emit(:logical_op, data, ts, te)
292
+ end
293
+ end
294
+ when 4 then
295
+ # line 35 "lexer.ragel"
296
+ begin
297
+ te = p+1
298
+ begin
299
+ @parser.emit(:index_group, data, ts, te);
300
+ end
301
+ end
302
+ when 5 then
303
+ # line 39 "lexer.ragel"
304
+ begin
305
+ te = p+1
306
+ begin
307
+ @parser.emit(:brace_group, data, ts, te);
308
+ end
309
+ end
310
+ when 6 then
311
+ # line 43 "lexer.ragel"
312
+ begin
313
+ te = p+1
314
+ begin
315
+ @parser.emit(:paren_group, data, ts, te);
316
+ end
317
+ end
318
+ when 7 then
319
+ # line 47 "lexer.ragel"
320
+ begin
321
+ te = p+1
322
+ begin
323
+ @parser.emit(:str_delim, data, ts, te);
324
+ end
325
+ end
326
+ when 8 then
327
+ # line 51 "lexer.ragel"
328
+ begin
329
+ te = p+1
330
+ begin
331
+ @parser.emit(:modifier, data, ts, te);
332
+ end
333
+ end
334
+ when 9 then
335
+ # line 55 "lexer.ragel"
336
+ begin
337
+ te = p+1
338
+ begin
339
+ @parser.emit(:separator, data, ts, te);
340
+ end
341
+ end
342
+ when 10 then
343
+ # line 59 "lexer.ragel"
344
+ begin
345
+ te = p+1
346
+ begin
347
+ @parser.emit(:escape, data, ts, te);
348
+ end
349
+ end
350
+ when 11 then
351
+ # line 63 "lexer.ragel"
352
+ begin
353
+ te = p+1
354
+ begin
355
+ @parser.emit(:space, data, ts, te)
356
+ end
357
+ end
358
+ when 12 then
359
+ # line 67 "lexer.ragel"
360
+ begin
361
+ te = p+1
362
+ begin
363
+ @parser.emit(:string, data, ts, te)
364
+ end
365
+ end
366
+ when 13 then
367
+ # line 19 "lexer.ragel"
368
+ begin
369
+ te = p
370
+ p = p - 1; begin
371
+ @parser.emit(:number_literal, data, ts, te)
372
+ end
373
+ end
374
+ when 14 then
375
+ # line 23 "lexer.ragel"
376
+ begin
377
+ te = p
378
+ p = p - 1; begin
379
+ @parser.emit(:number_literal, data, ts, te)
380
+ end
381
+ end
382
+ when 15 then
383
+ # line 27 "lexer.ragel"
384
+ begin
385
+ te = p
386
+ p = p - 1; begin
387
+ @parser.emit(:identifier, data, ts, te)
388
+ end
389
+ end
390
+ when 16 then
391
+ # line 31 "lexer.ragel"
392
+ begin
393
+ te = p
394
+ p = p - 1; begin
395
+ @parser.emit(:logical_op, data, ts, te)
396
+ end
397
+ end
398
+ when 17 then
399
+ # line 51 "lexer.ragel"
400
+ begin
401
+ te = p
402
+ p = p - 1; begin
403
+ @parser.emit(:modifier, data, ts, te);
404
+ end
405
+ end
406
+ when 18 then
407
+ # line 67 "lexer.ragel"
408
+ begin
409
+ te = p
410
+ p = p - 1; begin
411
+ @parser.emit(:string, data, ts, te)
412
+ end
413
+ end
414
+ when 19 then
415
+ # line 19 "lexer.ragel"
416
+ begin
417
+ begin p = ((te))-1; end
418
+ begin
419
+ @parser.emit(:number_literal, data, ts, te)
420
+ end
421
+ end
422
+ # line 423 "lexer.rb"
423
+ end # action switch
424
+ end
425
+ end
426
+ if _trigger_goto
427
+ next
428
+ end
429
+ end
430
+ if _goto_level <= _again
431
+ _acts = _eggshell_to_state_actions[cs]
432
+ _nacts = _eggshell_actions[_acts]
433
+ _acts += 1
434
+ while _nacts > 0
435
+ _nacts -= 1
436
+ _acts += 1
437
+ case _eggshell_actions[_acts - 1]
438
+ when 0 then
439
+ # line 1 "NONE"
440
+ begin
441
+ ts = nil; end
442
+ # line 443 "lexer.rb"
443
+ end # to state action switch
444
+ end
445
+ if _trigger_goto
446
+ next
447
+ end
448
+ p += 1
449
+ if p != pe
450
+ _goto_level = _resume
451
+ next
452
+ end
453
+ end
454
+ if _goto_level <= _test_eof
455
+ if p == eof
456
+ if _eggshell_eof_trans[cs] > 0
457
+ _trans = _eggshell_eof_trans[cs] - 1;
458
+ _goto_level = _eof_trans
459
+ next;
460
+ end
461
+ end
462
+ end
463
+ if _goto_level <= _out
464
+ break
465
+ end
466
+ end
467
+ end
468
+
469
+ # line 88 "lexer.ragel"
470
+ # %
471
+ end
472
+ end
473
+ end; end