cel 0.2.3 → 0.3.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +28 -0
- data/README.md +62 -8
- data/lib/cel/ast/elements/protobuf.rb +438 -90
- data/lib/cel/ast/elements.rb +367 -121
- data/lib/cel/ast/types.rb +153 -17
- data/lib/cel/checker.rb +133 -30
- data/lib/cel/context.rb +60 -12
- data/lib/cel/encoder.rb +31 -13
- data/lib/cel/environment.rb +63 -13
- data/lib/cel/errors.rb +22 -1
- data/lib/cel/macro.rb +94 -28
- data/lib/cel/parser.rb +603 -387
- data/lib/cel/program.rb +262 -48
- data/lib/cel/version.rb +1 -1
- data/lib/cel.rb +232 -1
- metadata +19 -10
- data/lib/cel/parser.tab.rb +0 -1023
data/lib/cel/parser.rb
CHANGED
@@ -1,20 +1,17 @@
|
|
1
1
|
#
|
2
2
|
# DO NOT MODIFY!!!!
|
3
|
-
# This file is automatically generated by Racc 1.
|
4
|
-
# from Racc grammar file "".
|
3
|
+
# This file is automatically generated by Racc 1.8.1
|
4
|
+
# from Racc grammar file "parser.ry".
|
5
5
|
#
|
6
6
|
|
7
7
|
require 'racc/parser.rb'
|
8
8
|
|
9
9
|
require 'strscan'
|
10
10
|
require 'bigdecimal'
|
11
|
-
require 'cel/ast/elements'
|
12
11
|
module Cel
|
13
12
|
class Parser < Racc::Parser
|
14
13
|
|
15
|
-
module_eval(<<'...end parser.ry/module_eval...', 'parser.ry',
|
16
|
-
|
17
|
-
|
14
|
+
module_eval(<<'...end parser.ry/module_eval...', 'parser.ry', 96)
|
18
15
|
|
19
16
|
OPERATORS = if RUBY_VERSION < "2.7.0"
|
20
17
|
{
|
@@ -37,6 +34,52 @@ end.freeze
|
|
37
34
|
|
38
35
|
OPERATORS_RE = Regexp.union(*OPERATORS.keys)
|
39
36
|
|
37
|
+
BACKSLASH = "\\\\" # Must be literally two backslashes for proper interpolation
|
38
|
+
DIGIT = "[0-9]"
|
39
|
+
EXPONENT = "(?:[eE][+-]?#{DIGIT}+)"
|
40
|
+
HEXDIGIT = "[0-9a-fA-F]"
|
41
|
+
RAW = "(?<raw>[rR])"
|
42
|
+
|
43
|
+
ESC_CHAR_SEQ = "#{BACKSLASH}[abfnrtv\"'#{BACKSLASH}?`]"
|
44
|
+
ESC_OCT_SEQ = "#{BACKSLASH}[0-3][0-7]{2}"
|
45
|
+
ESC_BYTE_SEQ = "#{BACKSLASH}[xX]#{HEXDIGIT}{2}"
|
46
|
+
ESC_UNI_SEQ = "#{BACKSLASH}u#{HEXDIGIT}{4}|#{BACKSLASH}U#{HEXDIGIT}{8}"
|
47
|
+
ESC_SEQ = "#{ESC_CHAR_SEQ}|#{ESC_BYTE_SEQ}|#{ESC_UNI_SEQ}|#{ESC_OCT_SEQ}"
|
48
|
+
|
49
|
+
WHITESPACE_REGEX = /[ \t\r\n\u000C]+/
|
50
|
+
COMMENT_REGEX = %r{//[^\n]*}
|
51
|
+
|
52
|
+
NUM_FLOAT_REGEX = Regexp.union(
|
53
|
+
/#{DIGIT}+\.#{DIGIT}+#{EXPONENT}?/,
|
54
|
+
/#{DIGIT}+#{EXPONENT}/,
|
55
|
+
/\.#{DIGIT}+#{EXPONENT}?/
|
56
|
+
)
|
57
|
+
|
58
|
+
NUM_INT_REGEX = Regexp.union(
|
59
|
+
/0x(?<hex>#{HEXDIGIT}+)/,
|
60
|
+
/(?<dec>#{DIGIT}+)/
|
61
|
+
)
|
62
|
+
|
63
|
+
NUM_UINT_REGEX = Regexp.union(
|
64
|
+
/0x(?<hex>#{HEXDIGIT}+)[uU]/,
|
65
|
+
/(?<dec>#{DIGIT}+)[uU]/
|
66
|
+
)
|
67
|
+
|
68
|
+
STRING_REGEX = Regexp.union(
|
69
|
+
/"""(?<str>(?:#{ESC_SEQ}|[^\\])*)"""/,
|
70
|
+
/'''(?<str>(?:#{ESC_SEQ}|[^\\])*)'''/,
|
71
|
+
/"(?<str>(?:#{ESC_SEQ}|[^\\"\n\r])*)"/,
|
72
|
+
/'(?<str>(?:#{ESC_SEQ}|[^\\'\n\r])*)'/,
|
73
|
+
/#{RAW}"""(?<str>.*?)"""/m,
|
74
|
+
/#{RAW}'''(?<str>.*?)'''/m,
|
75
|
+
/#{RAW}"(?<str>[^"\n\r]*)"/,
|
76
|
+
/#{RAW}'(?<str>[^'\n\r]*)'/,
|
77
|
+
)
|
78
|
+
|
79
|
+
QUOTED_MAP_FIELD_REGEX = /`/
|
80
|
+
|
81
|
+
BYTES_REGEX = /[bB]#{STRING_REGEX}/
|
82
|
+
|
40
83
|
RESERVED = %W[
|
41
84
|
as break const continue else
|
42
85
|
for function if import let
|
@@ -44,20 +87,18 @@ loop package namespace return
|
|
44
87
|
var void while
|
45
88
|
].freeze
|
46
89
|
|
47
|
-
IDENTIFIER_REGEX = /[
|
48
|
-
|
49
|
-
STRING_LIT_REGEX = Regexp.union(
|
50
|
-
/"""(?~""")*"""/,
|
51
|
-
/'''(?~''')*'''/,
|
52
|
-
/"(\\"|[^"])*"/,
|
53
|
-
/'(\\'|[^'])*'/,
|
54
|
-
)
|
90
|
+
IDENTIFIER_REGEX = /[_a-zA-Z][_a-zA-Z0-9]*/
|
55
91
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
92
|
+
def initialize(
|
93
|
+
package = nil,
|
94
|
+
max_recursion_depth: 32,
|
95
|
+
max_nesting_depth: 12,
|
96
|
+
expression_size_limit: 2048
|
60
97
|
)
|
98
|
+
@max_recursion_depth = max_recursion_depth
|
99
|
+
@max_nesting_depth = max_nesting_depth
|
100
|
+
@package = package
|
101
|
+
end
|
61
102
|
|
62
103
|
def parse(str)
|
63
104
|
tokenize(str)
|
@@ -67,12 +108,7 @@ rescue Racc::ParseError => err
|
|
67
108
|
end
|
68
109
|
|
69
110
|
def parse_error(error)
|
70
|
-
parse_error =
|
71
|
-
when /parse error on value "([^"]+)" \(tRESERVED\)/
|
72
|
-
Cel::ParseError.new("invalid usage of the reserved word \"#{$1}\"")
|
73
|
-
else
|
74
|
-
Cel::ParseError.new(error.message)
|
75
|
-
end
|
111
|
+
parse_error = Cel::ParseError.new(error.message)
|
76
112
|
parse_error.set_backtrace(error.backtrace)
|
77
113
|
parse_error
|
78
114
|
end
|
@@ -86,38 +122,22 @@ def tokenize(str)
|
|
86
122
|
|
87
123
|
until scanner.eos?
|
88
124
|
case
|
89
|
-
when scanner.scan(
|
125
|
+
when scanner.scan(WHITESPACE_REGEX)
|
90
126
|
# skip whitespace
|
91
|
-
when scanner.scan(
|
127
|
+
when scanner.scan(COMMENT_REGEX)
|
92
128
|
# skip comment lines
|
93
|
-
when scanner.scan(
|
94
|
-
@q <<
|
95
|
-
when scanner.scan(
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
# when '\\s' then "\s"
|
106
|
-
# when '\\t' then "\t"
|
107
|
-
# when '\\v' then "\v"
|
108
|
-
# when '\\"' then '"'
|
109
|
-
# end
|
110
|
-
# end
|
111
|
-
|
112
|
-
# s = scanner.matched.yield_self {|s| s[1, s.length - 2] }.gsub(/\\'/, "'")
|
113
|
-
|
114
|
-
str = scanner.matched
|
115
|
-
|
116
|
-
@q << if str.start_with?("b")
|
117
|
-
[:tBYTES, convert_to_bytes(str.byteslice(2..-2))]
|
118
|
-
else
|
119
|
-
[:tSTRING, convert_to_string(str)]
|
120
|
-
end
|
129
|
+
when scanner.scan(NUM_FLOAT_REGEX)
|
130
|
+
@q << [:tDOUBLE, Float(scanner.matched)]
|
131
|
+
when scanner.scan(NUM_UINT_REGEX)
|
132
|
+
@q << [:tUINT, scanner[:hex] ? scanner[:hex].to_i(16) : scanner[:dec].to_i]
|
133
|
+
when scanner.scan(NUM_INT_REGEX)
|
134
|
+
@q << [:tINT, scanner[:hex] ? scanner[:hex].to_i(16) : scanner[:dec].to_i]
|
135
|
+
when scanner.scan(STRING_REGEX)
|
136
|
+
str = convert_to_string(scanner[:raw], scanner[:str], true)
|
137
|
+
@q << [:tSTRING, str]
|
138
|
+
when scanner.scan(BYTES_REGEX)
|
139
|
+
str = convert_to_string(scanner[:raw], scanner[:str])
|
140
|
+
@q << [:tBYTES, convert_to_bytes(str)]
|
121
141
|
when scanner.scan(IDENTIFIER_REGEX)
|
122
142
|
word = scanner.matched
|
123
143
|
if word == "null"
|
@@ -126,8 +146,6 @@ def tokenize(str)
|
|
126
146
|
@q << [:tBOOL, true]
|
127
147
|
elsif word == "false"
|
128
148
|
@q << [:tBOOL, false]
|
129
|
-
elsif RESERVED.include?(word)
|
130
|
-
@q << [:tRESERVED, scanner.matched]
|
131
149
|
elsif word == "in"
|
132
150
|
@q << [OPERATORS[scanner.matched], scanner.matched]
|
133
151
|
else
|
@@ -135,6 +153,16 @@ def tokenize(str)
|
|
135
153
|
end
|
136
154
|
when scanner.scan(OPERATORS_RE)
|
137
155
|
@q << [OPERATORS[scanner.matched], scanner.matched]
|
156
|
+
when scanner.scan(QUOTED_MAP_FIELD_REGEX)
|
157
|
+
current_pos = scanner.pos
|
158
|
+
|
159
|
+
raise ParseError, "unexpected value: #{scanner.string}" unless scanner.scan_until(QUOTED_MAP_FIELD_REGEX)
|
160
|
+
|
161
|
+
raise ParseError, "unexpected value: #{scanner.string}" if scanner.post_match.start_with?("(")
|
162
|
+
|
163
|
+
# TODO: ensure that no newline is in the string
|
164
|
+
|
165
|
+
@q << [:tIDENTIFIER, scanner.pre_match[current_pos..-1]]
|
138
166
|
when scanner.scan(/\A.|\n/o)
|
139
167
|
s = scanner.matched
|
140
168
|
@q << [s, s]
|
@@ -149,286 +177,471 @@ def next_token
|
|
149
177
|
@q.shift
|
150
178
|
end
|
151
179
|
|
152
|
-
|
153
|
-
|
154
|
-
|
180
|
+
CHAR_SEQ_MAP = {
|
181
|
+
"\\a" => "\a",
|
182
|
+
"\\b" => "\b",
|
183
|
+
"\\f" => "\f",
|
184
|
+
"\\n" => "\n",
|
185
|
+
"\\r" => "\r",
|
186
|
+
"\\t" => "\t",
|
187
|
+
"\\v" => "\v",
|
188
|
+
"\\\"" => "\"",
|
189
|
+
"\\'" => "'",
|
190
|
+
"\\\\" => "\\",
|
191
|
+
"\\?" => "?",
|
192
|
+
"\\`" => "`",
|
193
|
+
}.freeze
|
194
|
+
ESC_SEQ_REGEX = /#{ESC_SEQ}/
|
195
|
+
def convert_to_string(raw, str, encode_to_utf8 = false)
|
196
|
+
# Raw strings do not interpret escape sequences
|
197
|
+
return str if raw
|
198
|
+
|
199
|
+
# Parse and convert all escape sequences
|
200
|
+
str.gsub(ESC_SEQ_REGEX) do |match|
|
201
|
+
case match[1]
|
202
|
+
when "0", "1", "2", "3"
|
203
|
+
# Octal sequence - ESC_OCT_SEQ
|
204
|
+
fragment = match[1..].to_i(8)
|
205
|
+
encode_to_utf8 ? [fragment].pack("U") : fragment.chr
|
206
|
+
when "x", "X"
|
207
|
+
# Hex sequence - ESC_BYTE_SEQ
|
208
|
+
fragment = match[2..].to_i(16)
|
209
|
+
encode_to_utf8 ? [fragment].pack("U") : fragment.chr
|
210
|
+
when "u", "U"
|
211
|
+
# Unicode escape sequence - ESC_UNI_SEQ
|
212
|
+
[match[2..].to_i(16)].pack('U')
|
213
|
+
else
|
214
|
+
# Char escape sequence - ESC_CHAR_SEQ
|
215
|
+
CHAR_SEQ_MAP.fetch(match)
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
def convert_to_bytes(str)
|
221
|
+
str.unpack("C*")
|
222
|
+
end
|
223
|
+
|
224
|
+
|
225
|
+
def literal_string(str)
|
226
|
+
Cel::String.new(str)
|
227
|
+
end
|
228
|
+
|
229
|
+
def literal_bytes(bytes)
|
230
|
+
Cel::Bytes.new(bytes)
|
231
|
+
end
|
232
|
+
|
233
|
+
def literal_int(int)
|
234
|
+
Cel::Number.new(:int, int)
|
235
|
+
end
|
236
|
+
|
237
|
+
def literal_uint(int)
|
238
|
+
Cel::Number.new(:uint, int)
|
239
|
+
end
|
240
|
+
|
241
|
+
def literal_double(double)
|
242
|
+
Cel::Number.new(:double, double)
|
243
|
+
end
|
244
|
+
|
245
|
+
def literal_bool(bool)
|
246
|
+
Cel::Bool.cast(bool)
|
247
|
+
end
|
248
|
+
|
249
|
+
def literal_null
|
250
|
+
Cel::Null::INSTANCE
|
251
|
+
end
|
155
252
|
|
156
|
-
|
157
|
-
|
253
|
+
def new_map(elements)
|
254
|
+
depth = 1
|
255
|
+
|
256
|
+
if elements.size > @max_recursion_depth
|
257
|
+
raise MaxRecursionDepthExceededError, "max number of map elements exceeded"
|
158
258
|
end
|
159
259
|
|
160
|
-
|
161
|
-
|
260
|
+
depth = elements.filter_map do |_, elem|
|
261
|
+
next unless elem.is_a?(Cel::Map)
|
262
|
+
|
263
|
+
d = depth + elem.depth
|
264
|
+
|
265
|
+
if d > @max_nesting_depth
|
266
|
+
raise MaxNestingDepthExceededError, "max nesting of map literals exceeded"
|
267
|
+
end
|
268
|
+
|
269
|
+
d
|
270
|
+
end.max || depth
|
271
|
+
|
272
|
+
Cel::Map.new(elements, depth: depth)
|
273
|
+
end
|
274
|
+
|
275
|
+
def new_list(val)
|
276
|
+
elements = Array(val)
|
277
|
+
depth = 1
|
278
|
+
|
279
|
+
if elements.size > @max_recursion_depth
|
280
|
+
raise MaxRecursionDepthExceededError, "max number of elements for list literals exceeded"
|
162
281
|
end
|
163
282
|
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
[:tDOUBLE, BigDecimal(matched)]
|
283
|
+
depth = elements.filter_map do |elem|
|
284
|
+
next unless elem.is_a?(Cel::List)
|
285
|
+
|
286
|
+
d = depth + elem.depth
|
287
|
+
|
288
|
+
if d > @max_nesting_depth
|
289
|
+
raise MaxNestingDepthExceededError, "max nesting of list literals exceeded"
|
172
290
|
end
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
291
|
+
|
292
|
+
d
|
293
|
+
end.max || depth
|
294
|
+
|
295
|
+
Cel::List.new(elements, depth: depth)
|
296
|
+
end
|
297
|
+
|
298
|
+
def new_identifier(id)
|
299
|
+
Cel::Identifier.new(id, @package)
|
300
|
+
end
|
301
|
+
|
302
|
+
def new_message(type, struct)
|
303
|
+
depth = 1
|
304
|
+
if struct
|
305
|
+
if struct.size > @max_recursion_depth
|
306
|
+
raise MaxRecursionDepthExceededError, "max number of message elements exceeded"
|
178
307
|
end
|
308
|
+
|
309
|
+
depth = struct.filter_map do |_, elem|
|
310
|
+
next unless elem.is_a?(Cel::Message)
|
311
|
+
|
312
|
+
d = depth + elem.depth
|
313
|
+
|
314
|
+
if d > @max_nesting_depth
|
315
|
+
raise MaxNestingDepthExceededError, "max nesting of map literals exceeded"
|
316
|
+
end
|
317
|
+
|
318
|
+
d
|
319
|
+
end.max || depth
|
179
320
|
end
|
321
|
+
|
322
|
+
Cel::Message.new(type, struct, package: @package, depth: depth)
|
180
323
|
end
|
181
324
|
|
182
|
-
|
183
|
-
|
325
|
+
def global_call(function, args = nil)
|
326
|
+
depth = 1
|
327
|
+
|
328
|
+
if args && args.size > @max_recursion_depth
|
329
|
+
raise MaxRecursionDepthExceededError, "max number of function call arguments exceeded"
|
330
|
+
end
|
331
|
+
|
332
|
+
depth = args.filter_map do |arg|
|
333
|
+
next unless arg.is_a?(Cel::Invoke)
|
184
334
|
|
185
|
-
|
335
|
+
d = depth + arg.depth
|
186
336
|
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
337
|
+
if d > @max_nesting_depth
|
338
|
+
raise MaxNestingDepthExceededError, "max nesting of function calls exceeded"
|
339
|
+
end
|
340
|
+
|
341
|
+
d
|
342
|
+
end.max || depth
|
343
|
+
|
344
|
+
Cel::Invoke.new(func: function, var: nil, args: args, package: @package, depth: depth)
|
345
|
+
end
|
346
|
+
|
347
|
+
def indexing_call(target, args)
|
348
|
+
depth = 1
|
349
|
+
|
350
|
+
if target.is_a?(Cel::Invoke)
|
351
|
+
depth += target.depth if target.indexing?
|
352
|
+
|
353
|
+
if depth > @max_nesting_depth
|
354
|
+
raise MaxNestingDepthExceededError, "max nesting of indexing operators exceeded"
|
355
|
+
end
|
192
356
|
end
|
193
357
|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
358
|
+
receiver_call(:[], target, args, package: @package, depth: depth)
|
359
|
+
end
|
360
|
+
|
361
|
+
def selector_call(function, target)
|
362
|
+
depth = 1
|
363
|
+
|
364
|
+
# if selector operator
|
365
|
+
if target.is_a?(Cel::Invoke) && !target.var.nil?
|
366
|
+
depth += target.depth
|
367
|
+
|
368
|
+
if depth > @max_nesting_depth
|
369
|
+
raise MaxNestingDepthExceededError, "max nesting of selection operators exceeded"
|
370
|
+
end
|
200
371
|
end
|
201
372
|
|
202
|
-
|
373
|
+
receiver_call(function, target, package: @package, depth: depth)
|
203
374
|
end
|
204
375
|
|
205
|
-
def
|
206
|
-
|
376
|
+
def receiver_call(function, target, args = nil, **kwargs)
|
377
|
+
Cel::Invoke.new(func: function, var: target, args: args, package: @package, **kwargs)
|
378
|
+
end
|
379
|
+
|
380
|
+
def logical_operation(op, operands)
|
381
|
+
lhs, rhs = operands
|
382
|
+
|
383
|
+
if lhs.is_a?(Cel::Operation) && lhs.op == op
|
384
|
+
# concat them
|
385
|
+
operands = [*lhs.operands, rhs]
|
386
|
+
end
|
387
|
+
|
388
|
+
if operands.size - 1 > @max_recursion_depth
|
389
|
+
raise Cel::MaxRecursionDepthExceededError, "max recursion depth exceeded for #{op} operation"
|
390
|
+
end
|
391
|
+
|
392
|
+
operation(op, operands)
|
393
|
+
end
|
394
|
+
|
395
|
+
def math_operation(op, operands)
|
396
|
+
# 32 binary arithmetic operators of the same precedence in a row
|
397
|
+
lhs, _ = operands
|
398
|
+
depth = 1
|
399
|
+
|
400
|
+
if lhs.is_a?(Cel::Operation)
|
401
|
+
case op
|
402
|
+
when "*", "/", "%"
|
403
|
+
case lhs.op
|
404
|
+
when "*", "/", "%"
|
405
|
+
depth = lhs.depth + 1
|
406
|
+
end
|
407
|
+
when "+", "+"
|
408
|
+
case lhs.op
|
409
|
+
when "+", "+"
|
410
|
+
depth = lhs.depth + 1
|
411
|
+
end
|
412
|
+
end
|
413
|
+
end
|
414
|
+
|
415
|
+
if depth > @max_recursion_depth
|
416
|
+
raise MaxRecursionDepthExceededError, "max number of arithmetic operators with the same precedence exceeded"
|
417
|
+
end
|
418
|
+
|
419
|
+
operation(op, operands, depth: depth)
|
207
420
|
end
|
208
421
|
|
422
|
+
def unary_operation(op, operand)
|
423
|
+
depth = 1
|
424
|
+
|
425
|
+
if operand.is_a?(Cel::Operation) && operand.op == op && operand.unary?
|
426
|
+
depth = depth + operand.depth
|
209
427
|
|
210
|
-
|
211
|
-
|
212
|
-
BPM_ESCAPE = /\\u([0-9a-fA-F]{4})/
|
213
|
-
UNICODE_ESCAPE = /\\u([0-9a-fA-F]{4})/
|
214
|
-
WHITESPACE_ESCAPE = /\\([bfnrt"'\\])/
|
215
|
-
ESCAPE_UNION = Regexp.union(BIN_ESCAPE, HEX_ESCAPE, BPM_ESCAPE, WHITESPACE_ESCAPE)
|
216
|
-
# For the sake of a readable representation, the escape sequences (ESCAPE) are kept
|
217
|
-
# implicit in string tokens. This means that strings without the r or R (raw) prefix
|
218
|
-
# process ESCAPE sequences, while in strings with the raw prefix they stay uninterpreted.
|
219
|
-
# See documentation of string literals below.
|
220
|
-
def cleanup_escape_sequences(str)
|
221
|
-
str.gsub!(ESCAPE_UNION) do |match|
|
222
|
-
case match
|
223
|
-
when /\\"/
|
224
|
-
"\""
|
225
|
-
when BIN_ESCAPE
|
226
|
-
# For strings, it denotes the unicode code point.
|
227
|
-
Regexp.last_match(1).to_i.chr(Encoding::UTF_8)
|
228
|
-
when HEX_ESCAPE
|
229
|
-
# For strings, it denotes the unicode code point.
|
230
|
-
Regexp.last_match(1).hex.chr(Encoding::UTF_8)
|
231
|
-
when BPM_ESCAPE
|
232
|
-
Regexp.last_match(1).hex.chr(Encoding::BPM)
|
233
|
-
when UNICODE_ESCAPE
|
234
|
-
# encoding a Unicode code point. Valid only for string literals.
|
235
|
-
Regexp.last_match(1).hex.chr(Encoding::UTF_8)
|
236
|
-
when WHITESPACE_ESCAPE
|
237
|
-
Regexp.last_match(0)
|
428
|
+
if depth > @max_recursion_depth
|
429
|
+
raise MaxRecursionDepthExceededError, "max number of an unary operator exceeded"
|
238
430
|
end
|
239
431
|
end
|
240
|
-
|
432
|
+
|
433
|
+
operation(op, [operand], depth: depth)
|
434
|
+
end
|
435
|
+
|
436
|
+
def operation(op, operands, **kwargs)
|
437
|
+
Cel::Operation.new(op, operands, **kwargs)
|
438
|
+
end
|
439
|
+
|
440
|
+
def ternary_condition(if_op, *ops)
|
441
|
+
depth = 1
|
442
|
+
|
443
|
+
depth = ops.filter_map do |op|
|
444
|
+
next unless op.is_a?(Cel::Condition)
|
445
|
+
|
446
|
+
d = depth + op.depth
|
447
|
+
|
448
|
+
if d > @max_recursion_depth
|
449
|
+
raise MaxRecursionDepthExceededError, "max number of consecutive ternary operators exceeded"
|
450
|
+
end
|
451
|
+
|
452
|
+
d
|
453
|
+
end.max || depth
|
454
|
+
|
455
|
+
Cel::Condition.new(if_op, *ops, depth: depth)
|
456
|
+
end
|
457
|
+
|
458
|
+
# Checks whether the given identifier token is a reserved word or not. Throws
|
459
|
+
# a ParseError if it's a reserved word.
|
460
|
+
def validated_id!(identifier)
|
461
|
+
return identifier unless RESERVED.include?(identifier)
|
462
|
+
|
463
|
+
raise Cel::ParseError, "invalid usage of the reserved word \"#{identifier}\""
|
241
464
|
end
|
242
465
|
|
243
466
|
...end parser.ry/module_eval...
|
244
467
|
##### State transition tables begin ###
|
245
468
|
|
246
469
|
racc_action_table = [
|
247
|
-
22, 23, 24, 25, 26, 27, 28,
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
nil, nil, nil, nil, nil,
|
265
|
-
nil, 18, 22, 23, 24, 25, 26,
|
266
|
-
20, nil, nil, 13, nil, nil, nil, nil,
|
267
|
-
nil, 12,
|
268
|
-
24, 25, 26, 27, 28,
|
269
|
-
nil, nil, nil, nil, nil, nil, nil, 12,
|
270
|
-
nil,
|
271
|
-
28,
|
272
|
-
nil, nil, nil, 12,
|
273
|
-
22, 23, 24, 25, 26, 27, 28,
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
nil, nil, nil, nil, nil,
|
278
|
-
|
279
|
-
|
280
|
-
nil,
|
281
|
-
|
282
|
-
|
283
|
-
nil,
|
284
|
-
|
285
|
-
nil, nil, nil,
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
nil, nil, nil, nil, nil,
|
291
|
-
nil, 18, 22, 23, 24, 25, 26,
|
292
|
-
20, nil, nil, 13, nil, nil, nil, nil,
|
293
|
-
nil, 12,
|
294
|
-
24, 25, 26, 27, 28,
|
295
|
-
nil, nil, nil, nil, nil, nil, nil, 12,
|
296
|
-
nil,
|
297
|
-
28,
|
298
|
-
nil, nil, nil, 12,
|
299
|
-
22, 23, 24, 25, 26, 27, 28,
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
nil, nil, nil, nil, nil,
|
304
|
-
|
305
|
-
|
306
|
-
nil,
|
307
|
-
24, 25, 26, 27, 28, nil, 20, nil, nil, 13,
|
308
|
-
nil, nil, nil, nil, nil, nil, nil, 12, 21, 16,
|
309
|
-
nil, 17, nil, 18, 22, 23, 24, 25, 26, 27,
|
310
|
-
28, nil, 20, nil, nil, 13, nil, nil, nil, nil,
|
311
|
-
nil, nil, nil, 12, 21, 16, nil, 17, nil, 18 ]
|
470
|
+
22, 23, 24, 25, 26, 27, 28, 20, 32, 38,
|
471
|
+
13, 39, 78, 40, 4, 35, 36, 32, 12, 17,
|
472
|
+
31, 18, 29, 21, 16, 22, 23, 24, 25, 26,
|
473
|
+
27, 28, 20, 35, 36, 22, 23, 24, 25, 26,
|
474
|
+
27, 28, 20, 42, 17, 45, 18, 4, 21, 16,
|
475
|
+
33, 38, 34, 39, 17, 40, 18, 37, 21, 16,
|
476
|
+
22, 23, 24, 25, 26, 27, 28, 20, 47, 38,
|
477
|
+
13, 39, 55, 40, 56, 67, 68, 72, 12, 17,
|
478
|
+
73, 18, 74, 21, 16, 22, 23, 24, 25, 26,
|
479
|
+
27, 28, 20, 75, 76, 13, 77, 33, 34, 37,
|
480
|
+
37, 79, 80, 12, 17, 81, 18, 82, 21, 16,
|
481
|
+
22, 23, 24, 25, 26, 27, 28, 20, 83, 84,
|
482
|
+
13, 89, 92, 93, 94, nil, nil, nil, 12, 17,
|
483
|
+
nil, 18, nil, 21, 16, 22, 23, 24, 25, 26,
|
484
|
+
27, 28, 20, nil, nil, 13, nil, nil, nil, nil,
|
485
|
+
nil, nil, nil, 12, 17, nil, 18, nil, 21, 16,
|
486
|
+
22, 23, 24, 25, 26, 27, 28, 20, nil, nil,
|
487
|
+
13, nil, nil, nil, nil, nil, nil, nil, 12, 17,
|
488
|
+
nil, 18, nil, 21, 16, 22, 23, 24, 25, 26,
|
489
|
+
27, 28, 20, nil, nil, 13, nil, nil, nil, nil,
|
490
|
+
nil, nil, nil, 12, 17, nil, 18, nil, 21, 16,
|
491
|
+
22, 23, 24, 25, 26, 27, 28, 20, nil, nil,
|
492
|
+
13, nil, nil, nil, nil, nil, nil, nil, 12, 17,
|
493
|
+
nil, 18, nil, 21, 16, 22, 23, 24, 25, 26,
|
494
|
+
27, 28, 20, nil, nil, 13, nil, nil, nil, nil,
|
495
|
+
nil, nil, nil, 12, 17, nil, 18, nil, 21, 16,
|
496
|
+
22, 23, 24, 25, 26, 27, 28, 20, nil, nil,
|
497
|
+
13, nil, nil, nil, nil, nil, nil, nil, 12, 17,
|
498
|
+
nil, 18, nil, 21, 16, 22, 23, 24, 25, 26,
|
499
|
+
27, 28, 20, nil, nil, 13, nil, nil, nil, nil,
|
500
|
+
nil, nil, nil, 12, 17, nil, 18, nil, 21, 16,
|
501
|
+
22, 23, 24, 25, 26, 27, 28, 20, nil, nil,
|
502
|
+
13, nil, nil, nil, nil, nil, nil, nil, 12, 17,
|
503
|
+
nil, 18, nil, 21, 16, 22, 23, 24, 25, 26,
|
504
|
+
27, 28, 20, nil, nil, 22, 23, 24, 25, 26,
|
505
|
+
27, 28, 20, 42, 17, 45, 18, nil, 21, 16,
|
506
|
+
nil, nil, nil, nil, 17, nil, 18, nil, 21, 16,
|
507
|
+
22, 23, 24, 25, 26, 27, 28, 20, nil, nil,
|
508
|
+
13, nil, nil, nil, nil, nil, nil, nil, 12, 17,
|
509
|
+
nil, 18, nil, 21, 16, 22, 23, 24, 25, 26,
|
510
|
+
27, 28, 20, nil, nil, 13, nil, nil, nil, nil,
|
511
|
+
nil, nil, nil, 12, 17, nil, 18, nil, 21, 16,
|
512
|
+
22, 23, 24, 25, 26, 27, 28, 20, nil, nil,
|
513
|
+
13, nil, nil, nil, nil, nil, nil, nil, 12, 17,
|
514
|
+
nil, 18, nil, 21, 16, 22, 23, 24, 25, 26,
|
515
|
+
27, 28, 20, nil, nil, 13, nil, nil, nil, nil,
|
516
|
+
nil, nil, nil, 12, 17, nil, 18, nil, 21, 16,
|
517
|
+
22, 23, 24, 25, 26, 27, 28, 20, nil, nil,
|
518
|
+
13, nil, nil, nil, nil, nil, nil, nil, 12, 17,
|
519
|
+
nil, 18, nil, 21, 16, 22, 23, 24, 25, 26,
|
520
|
+
27, 28, 20, nil, nil, 13, nil, nil, nil, nil,
|
521
|
+
nil, nil, nil, 12, 17, nil, 18, nil, 21, 16,
|
522
|
+
22, 23, 24, 25, 26, 27, 28, 20, nil, nil,
|
523
|
+
13, nil, nil, nil, nil, nil, nil, nil, 12, 17,
|
524
|
+
nil, 18, nil, 21, 16, 22, 23, 24, 25, 26,
|
525
|
+
27, 28, 20, nil, nil, 13, nil, nil, nil, nil,
|
526
|
+
nil, nil, nil, 12, 17, nil, 18, nil, 21, 16,
|
527
|
+
22, 23, 24, 25, 26, 27, 28, 20, nil, nil,
|
528
|
+
13, nil, nil, nil, nil, nil, nil, nil, 12, 17,
|
529
|
+
nil, 18, nil, 21, 16 ]
|
312
530
|
|
313
531
|
racc_action_check = [
|
314
|
-
0, 0, 0, 0, 0, 0, 0,
|
315
|
-
|
316
|
-
|
317
|
-
12, 12, 12,
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
18, 18, 18,
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
nil, nil, nil, nil, nil,
|
332
|
-
nil,
|
333
|
-
|
334
|
-
nil,
|
335
|
-
|
336
|
-
nil, nil, nil, nil, nil, nil, nil,
|
337
|
-
nil,
|
338
|
-
|
339
|
-
nil, nil, nil,
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
nil, nil, nil,
|
345
|
-
|
346
|
-
|
347
|
-
nil,
|
348
|
-
|
349
|
-
|
350
|
-
nil,
|
351
|
-
|
352
|
-
nil, nil, nil,
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
nil, nil, nil, nil, nil,
|
358
|
-
nil,
|
359
|
-
|
360
|
-
nil,
|
361
|
-
|
362
|
-
nil, nil, nil, nil, nil, nil, nil,
|
363
|
-
nil,
|
364
|
-
|
365
|
-
nil, nil, nil,
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
nil, nil, nil,
|
371
|
-
|
372
|
-
|
373
|
-
nil,
|
374
|
-
92, 92, 92, 92, 92, nil, 92, nil, nil, 92,
|
375
|
-
nil, nil, nil, nil, nil, nil, nil, 92, 92, 92,
|
376
|
-
nil, 92, nil, 92, 94, 94, 94, 94, 94, 94,
|
377
|
-
94, nil, 94, nil, nil, 94, nil, nil, nil, nil,
|
378
|
-
nil, nil, nil, 94, 94, 94, nil, 94, nil, 94 ]
|
532
|
+
0, 0, 0, 0, 0, 0, 0, 0, 57, 11,
|
533
|
+
0, 11, 57, 11, 0, 8, 8, 5, 0, 0,
|
534
|
+
5, 0, 1, 0, 0, 12, 12, 12, 12, 12,
|
535
|
+
12, 12, 12, 60, 60, 13, 13, 13, 13, 13,
|
536
|
+
13, 13, 13, 12, 12, 13, 12, 2, 12, 12,
|
537
|
+
6, 43, 7, 43, 13, 43, 13, 9, 13, 13,
|
538
|
+
16, 16, 16, 16, 16, 16, 16, 16, 15, 46,
|
539
|
+
16, 46, 21, 46, 29, 39, 40, 48, 16, 16,
|
540
|
+
49, 16, 50, 16, 16, 17, 17, 17, 17, 17,
|
541
|
+
17, 17, 17, 52, 53, 17, 54, 58, 59, 61,
|
542
|
+
62, 64, 65, 17, 17, 66, 17, 67, 17, 17,
|
543
|
+
18, 18, 18, 18, 18, 18, 18, 18, 68, 71,
|
544
|
+
18, 81, 86, 89, 91, nil, nil, nil, 18, 18,
|
545
|
+
nil, 18, nil, 18, 18, 31, 31, 31, 31, 31,
|
546
|
+
31, 31, 31, nil, nil, 31, nil, nil, nil, nil,
|
547
|
+
nil, nil, nil, 31, 31, nil, 31, nil, 31, 31,
|
548
|
+
32, 32, 32, 32, 32, 32, 32, 32, nil, nil,
|
549
|
+
32, nil, nil, nil, nil, nil, nil, nil, 32, 32,
|
550
|
+
nil, 32, nil, 32, 32, 33, 33, 33, 33, 33,
|
551
|
+
33, 33, 33, nil, nil, 33, nil, nil, nil, nil,
|
552
|
+
nil, nil, nil, 33, 33, nil, 33, nil, 33, 33,
|
553
|
+
34, 34, 34, 34, 34, 34, 34, 34, nil, nil,
|
554
|
+
34, nil, nil, nil, nil, nil, nil, nil, 34, 34,
|
555
|
+
nil, 34, nil, 34, 34, 35, 35, 35, 35, 35,
|
556
|
+
35, 35, 35, nil, nil, 35, nil, nil, nil, nil,
|
557
|
+
nil, nil, nil, 35, 35, nil, 35, nil, 35, 35,
|
558
|
+
36, 36, 36, 36, 36, 36, 36, 36, nil, nil,
|
559
|
+
36, nil, nil, nil, nil, nil, nil, nil, 36, 36,
|
560
|
+
nil, 36, nil, 36, 36, 37, 37, 37, 37, 37,
|
561
|
+
37, 37, 37, nil, nil, 37, nil, nil, nil, nil,
|
562
|
+
nil, nil, nil, 37, 37, nil, 37, nil, 37, 37,
|
563
|
+
38, 38, 38, 38, 38, 38, 38, 38, nil, nil,
|
564
|
+
38, nil, nil, nil, nil, nil, nil, nil, 38, 38,
|
565
|
+
nil, 38, nil, 38, 38, 42, 42, 42, 42, 42,
|
566
|
+
42, 42, 42, nil, nil, 45, 45, 45, 45, 45,
|
567
|
+
45, 45, 45, 42, 42, 45, 42, nil, 42, 42,
|
568
|
+
nil, nil, nil, nil, 45, nil, 45, nil, 45, 45,
|
569
|
+
47, 47, 47, 47, 47, 47, 47, 47, nil, nil,
|
570
|
+
47, nil, nil, nil, nil, nil, nil, nil, 47, 47,
|
571
|
+
nil, 47, nil, 47, 47, 74, 74, 74, 74, 74,
|
572
|
+
74, 74, 74, nil, nil, 74, nil, nil, nil, nil,
|
573
|
+
nil, nil, nil, 74, 74, nil, 74, nil, 74, 74,
|
574
|
+
76, 76, 76, 76, 76, 76, 76, 76, nil, nil,
|
575
|
+
76, nil, nil, nil, nil, nil, nil, nil, 76, 76,
|
576
|
+
nil, 76, nil, 76, 76, 77, 77, 77, 77, 77,
|
577
|
+
77, 77, 77, nil, nil, 77, nil, nil, nil, nil,
|
578
|
+
nil, nil, nil, 77, 77, nil, 77, nil, 77, 77,
|
579
|
+
78, 78, 78, 78, 78, 78, 78, 78, nil, nil,
|
580
|
+
78, nil, nil, nil, nil, nil, nil, nil, 78, 78,
|
581
|
+
nil, 78, nil, 78, 78, 82, 82, 82, 82, 82,
|
582
|
+
82, 82, 82, nil, nil, 82, nil, nil, nil, nil,
|
583
|
+
nil, nil, nil, 82, 82, nil, 82, nil, 82, 82,
|
584
|
+
83, 83, 83, 83, 83, 83, 83, 83, nil, nil,
|
585
|
+
83, nil, nil, nil, nil, nil, nil, nil, 83, 83,
|
586
|
+
nil, 83, nil, 83, 83, 92, 92, 92, 92, 92,
|
587
|
+
92, 92, 92, nil, nil, 92, nil, nil, nil, nil,
|
588
|
+
nil, nil, nil, 92, 92, nil, 92, nil, 92, 92,
|
589
|
+
93, 93, 93, 93, 93, 93, 93, 93, nil, nil,
|
590
|
+
93, nil, nil, nil, nil, nil, nil, nil, 93, 93,
|
591
|
+
nil, 93, nil, 93, 93 ]
|
379
592
|
|
380
593
|
racc_action_pointer = [
|
381
|
-
-2,
|
382
|
-
nil, -
|
383
|
-
nil,
|
384
|
-
nil,
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
nil,
|
389
|
-
nil,
|
390
|
-
|
594
|
+
-2, 22, 31, nil, nil, 2, 36, 39, 4, 47,
|
595
|
+
nil, -12, 23, 33, nil, 42, 58, 83, 108, nil,
|
596
|
+
nil, 63, nil, nil, nil, nil, nil, nil, nil, 74,
|
597
|
+
nil, 133, 158, 183, 208, 233, 258, 283, 308, 66,
|
598
|
+
67, nil, 333, 30, nil, 343, 48, 368, 50, 58,
|
599
|
+
54, nil, 69, 66, 77, nil, nil, -7, 83, 85,
|
600
|
+
22, 89, 90, nil, 79, 78, 77, 88, 92, nil,
|
601
|
+
nil, 92, nil, nil, 393, nil, 418, 443, 468, nil,
|
602
|
+
nil, 112, 493, 518, nil, nil, 103, nil, nil, 104,
|
603
|
+
nil, 97, 543, 568, nil, nil, nil ]
|
391
604
|
|
392
605
|
racc_action_default = [
|
393
606
|
-56, -56, -56, -2, -3, -5, -7, -9, -11, -14,
|
394
607
|
-16, -17, -56, -56, -24, -29, -56, -38, -39, -34,
|
395
608
|
-35, -56, -49, -50, -51, -52, -53, -54, -55, -56,
|
396
|
-
-1, -56, -56, -56, -56, -56, -56, -56, -56, -
|
397
|
-
-
|
609
|
+
-1, -56, -56, -56, -56, -56, -56, -56, -56, -43,
|
610
|
+
-56, -18, -56, -21, -19, -56, -23, -38, -56, -56,
|
398
611
|
-37, -42, -56, -40, -56, -36, 97, -56, -6, -8,
|
399
|
-
-10, -12, -13, -15, -
|
400
|
-
-22, -56, -31, -32, -56, -33, -56, -56, -56, -
|
401
|
-
-
|
402
|
-
-
|
612
|
+
-10, -12, -13, -15, -56, -56, -44, -56, -27, -20,
|
613
|
+
-22, -56, -31, -32, -56, -33, -56, -56, -56, -25,
|
614
|
+
-26, -56, -56, -38, -30, -41, -56, -48, -4, -56,
|
615
|
+
-46, -56, -56, -56, -28, -47, -45 ]
|
403
616
|
|
404
617
|
racc_goto_table = [
|
405
618
|
2, 49, 43, 46, 44, 1, 3, 41, 30, 61,
|
406
|
-
62, 57, 58, 59, 60, 63, 48,
|
407
|
-
53,
|
408
|
-
nil, 71, 43, nil, nil, 46, 70, 69, nil,
|
619
|
+
62, 57, 58, 59, 60, 63, 48, 65, 54, 52,
|
620
|
+
53, 66, nil, nil, nil, nil, nil, nil, nil, nil,
|
621
|
+
nil, 71, 43, nil, nil, 46, 70, 69, 64, nil,
|
409
622
|
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
410
623
|
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
411
|
-
nil, nil, nil,
|
624
|
+
nil, nil, nil, nil, nil, nil, nil, 91, nil, nil,
|
412
625
|
nil, nil, nil, nil, 85, nil, 86, 87, 88, nil,
|
413
|
-
nil, nil, nil,
|
414
|
-
nil, nil, 95,
|
626
|
+
nil, nil, 90, nil, nil, nil, nil, nil, nil, nil,
|
627
|
+
nil, nil, 95, 96 ]
|
415
628
|
|
416
629
|
racc_goto_check = [
|
417
|
-
2,
|
418
|
-
8, 4, 5, 6, 7, 9, 2,
|
630
|
+
2, 15, 10, 10, 12, 1, 3, 11, 3, 8,
|
631
|
+
8, 4, 5, 6, 7, 9, 2, 14, 2, 17,
|
419
632
|
20, 21, nil, nil, nil, nil, nil, nil, nil, nil,
|
420
|
-
nil,
|
633
|
+
nil, 15, 10, nil, nil, 10, 12, 11, 2, nil,
|
421
634
|
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
422
635
|
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
423
|
-
nil, nil, nil,
|
636
|
+
nil, nil, nil, nil, nil, nil, nil, 15, nil, nil,
|
424
637
|
nil, nil, nil, nil, 2, nil, 2, 2, 2, nil,
|
425
|
-
nil, nil,
|
426
|
-
nil, nil, 2,
|
638
|
+
nil, nil, 2, nil, nil, nil, nil, nil, nil, nil,
|
639
|
+
nil, nil, 2, 2 ]
|
427
640
|
|
428
641
|
racc_goto_pointer = [
|
429
642
|
nil, 5, 0, 6, -20, -20, -20, -20, -26, -22,
|
430
|
-
-10, -5, -9, nil, -
|
431
|
-
2, -
|
643
|
+
-10, -5, -9, nil, -22, -16, nil, 1, nil, nil,
|
644
|
+
2, -18 ]
|
432
645
|
|
433
646
|
racc_goto_default = [
|
434
647
|
nil, nil, 51, nil, 5, 6, 7, 8, 9, 10,
|
@@ -437,61 +650,61 @@ racc_goto_default = [
|
|
437
650
|
|
438
651
|
racc_reduce_table = [
|
439
652
|
0, 0, :racc_error,
|
440
|
-
2,
|
653
|
+
2, 30, :_reduce_none,
|
654
|
+
1, 30, :_reduce_none,
|
655
|
+
1, 32, :_reduce_none,
|
656
|
+
5, 31, :_reduce_4,
|
441
657
|
1, 31, :_reduce_none,
|
658
|
+
3, 33, :_reduce_6,
|
442
659
|
1, 33, :_reduce_none,
|
443
|
-
|
444
|
-
1, 32, :_reduce_none,
|
445
|
-
3, 34, :_reduce_6,
|
660
|
+
3, 34, :_reduce_8,
|
446
661
|
1, 34, :_reduce_none,
|
447
|
-
3, 35, :
|
662
|
+
3, 35, :_reduce_10,
|
448
663
|
1, 35, :_reduce_none,
|
449
|
-
3, 36, :
|
664
|
+
3, 36, :_reduce_12,
|
665
|
+
3, 36, :_reduce_13,
|
450
666
|
1, 36, :_reduce_none,
|
451
|
-
3, 37, :
|
452
|
-
3, 37, :_reduce_13,
|
667
|
+
3, 37, :_reduce_15,
|
453
668
|
1, 37, :_reduce_none,
|
454
|
-
3, 38, :_reduce_15,
|
455
669
|
1, 38, :_reduce_none,
|
456
|
-
|
457
|
-
2,
|
458
|
-
2,
|
459
|
-
|
670
|
+
2, 38, :_reduce_18,
|
671
|
+
2, 38, :_reduce_19,
|
672
|
+
2, 40, :_reduce_20,
|
673
|
+
1, 40, :_reduce_none,
|
674
|
+
2, 41, :_reduce_22,
|
460
675
|
1, 41, :_reduce_none,
|
461
|
-
|
676
|
+
1, 39, :_reduce_none,
|
677
|
+
4, 39, :_reduce_25,
|
678
|
+
4, 39, :_reduce_26,
|
679
|
+
3, 39, :_reduce_27,
|
680
|
+
6, 39, :_reduce_28,
|
681
|
+
1, 42, :_reduce_29,
|
682
|
+
4, 42, :_reduce_30,
|
683
|
+
3, 42, :_reduce_31,
|
684
|
+
3, 42, :_reduce_32,
|
685
|
+
3, 42, :_reduce_33,
|
462
686
|
1, 42, :_reduce_none,
|
463
|
-
1,
|
464
|
-
|
465
|
-
6, 40, :_reduce_26,
|
466
|
-
4, 40, :_reduce_27,
|
467
|
-
4, 40, :_reduce_28,
|
468
|
-
1, 43, :_reduce_29,
|
469
|
-
4, 43, :_reduce_30,
|
470
|
-
3, 43, :_reduce_31,
|
471
|
-
3, 43, :_reduce_32,
|
472
|
-
3, 43, :_reduce_33,
|
473
|
-
1, 43, :_reduce_none,
|
474
|
-
1, 46, :_reduce_none,
|
475
|
-
2, 46, :_reduce_none,
|
687
|
+
1, 45, :_reduce_none,
|
688
|
+
2, 45, :_reduce_36,
|
476
689
|
1, 44, :_reduce_none,
|
477
690
|
0, 44, :_reduce_38,
|
478
|
-
0,
|
479
|
-
1,
|
480
|
-
3,
|
481
|
-
1,
|
482
|
-
0,
|
483
|
-
1,
|
484
|
-
5,
|
485
|
-
3,
|
486
|
-
5,
|
487
|
-
3,
|
488
|
-
1,
|
489
|
-
1,
|
490
|
-
1,
|
491
|
-
1,
|
492
|
-
1,
|
493
|
-
1,
|
494
|
-
1,
|
691
|
+
0, 46, :_reduce_39,
|
692
|
+
1, 46, :_reduce_none,
|
693
|
+
3, 48, :_reduce_41,
|
694
|
+
1, 48, :_reduce_42,
|
695
|
+
0, 43, :_reduce_43,
|
696
|
+
1, 43, :_reduce_none,
|
697
|
+
5, 50, :_reduce_45,
|
698
|
+
3, 50, :_reduce_46,
|
699
|
+
5, 49, :_reduce_47,
|
700
|
+
3, 49, :_reduce_48,
|
701
|
+
1, 47, :_reduce_49,
|
702
|
+
1, 47, :_reduce_50,
|
703
|
+
1, 47, :_reduce_51,
|
704
|
+
1, 47, :_reduce_52,
|
705
|
+
1, 47, :_reduce_53,
|
706
|
+
1, 47, :_reduce_54,
|
707
|
+
1, 47, :_reduce_55 ]
|
495
708
|
|
496
709
|
racc_reduce_n = 56
|
497
710
|
|
@@ -507,29 +720,28 @@ racc_token_table = {
|
|
507
720
|
:tNULL => 6,
|
508
721
|
:tSTRING => 7,
|
509
722
|
:tBYTES => 8,
|
510
|
-
:
|
511
|
-
:
|
512
|
-
:
|
513
|
-
:
|
514
|
-
:
|
515
|
-
:
|
516
|
-
:
|
517
|
-
:
|
518
|
-
:
|
519
|
-
|
520
|
-
"
|
521
|
-
"
|
522
|
-
"
|
523
|
-
"
|
524
|
-
"
|
525
|
-
"
|
526
|
-
"
|
527
|
-
"
|
528
|
-
"
|
529
|
-
"
|
530
|
-
|
531
|
-
|
532
|
-
racc_nt_base = 30
|
723
|
+
:tIDENTIFIER => 9,
|
724
|
+
:tMULTIOP => 10,
|
725
|
+
:tADDOP => 11,
|
726
|
+
:tSUBOP => 12,
|
727
|
+
:tRELOP => 13,
|
728
|
+
:tANDOP => 14,
|
729
|
+
:tOROP => 15,
|
730
|
+
:tEOF => 16,
|
731
|
+
:UMINUS => 17,
|
732
|
+
"?" => 18,
|
733
|
+
":" => 19,
|
734
|
+
"!" => 20,
|
735
|
+
"[" => 21,
|
736
|
+
"]" => 22,
|
737
|
+
"{" => 23,
|
738
|
+
"}" => 24,
|
739
|
+
"." => 25,
|
740
|
+
"(" => 26,
|
741
|
+
")" => 27,
|
742
|
+
"," => 28 }
|
743
|
+
|
744
|
+
racc_nt_base = 29
|
533
745
|
|
534
746
|
racc_use_result_var = true
|
535
747
|
|
@@ -560,7 +772,6 @@ Racc_token_to_s_table = [
|
|
560
772
|
"tNULL",
|
561
773
|
"tSTRING",
|
562
774
|
"tBYTES",
|
563
|
-
"tRESERVED",
|
564
775
|
"tIDENTIFIER",
|
565
776
|
"tMULTIOP",
|
566
777
|
"tADDOP",
|
@@ -573,13 +784,13 @@ Racc_token_to_s_table = [
|
|
573
784
|
"\"?\"",
|
574
785
|
"\":\"",
|
575
786
|
"\"!\"",
|
576
|
-
"\".\"",
|
577
|
-
"\"(\"",
|
578
|
-
"\")\"",
|
579
787
|
"\"[\"",
|
580
788
|
"\"]\"",
|
581
789
|
"\"{\"",
|
582
790
|
"\"}\"",
|
791
|
+
"\".\"",
|
792
|
+
"\"(\"",
|
793
|
+
"\")\"",
|
583
794
|
"\",\"",
|
584
795
|
"$start",
|
585
796
|
"target",
|
@@ -595,8 +806,8 @@ Racc_token_to_s_table = [
|
|
595
806
|
"negated_member",
|
596
807
|
"negative_member",
|
597
808
|
"primary",
|
598
|
-
"maybe_expr_list",
|
599
809
|
"maybe_field_inits",
|
810
|
+
"maybe_expr_list",
|
600
811
|
"identifier",
|
601
812
|
"maybe_map_inits",
|
602
813
|
"literal",
|
@@ -619,7 +830,7 @@ Racc_debug_parser = false
|
|
619
830
|
|
620
831
|
module_eval(<<'.,.,', 'parser.ry', 17)
|
621
832
|
def _reduce_4(val, _values, result)
|
622
|
-
result =
|
833
|
+
result = ternary_condition(val[0], val[2], val[4])
|
623
834
|
result
|
624
835
|
end
|
625
836
|
.,.,
|
@@ -628,7 +839,7 @@ module_eval(<<'.,.,', 'parser.ry', 17)
|
|
628
839
|
|
629
840
|
module_eval(<<'.,.,', 'parser.ry', 20)
|
630
841
|
def _reduce_6(val, _values, result)
|
631
|
-
result =
|
842
|
+
result = logical_operation(val[1], [val[0], val[2]])
|
632
843
|
result
|
633
844
|
end
|
634
845
|
.,.,
|
@@ -637,7 +848,7 @@ module_eval(<<'.,.,', 'parser.ry', 20)
|
|
637
848
|
|
638
849
|
module_eval(<<'.,.,', 'parser.ry', 23)
|
639
850
|
def _reduce_8(val, _values, result)
|
640
|
-
result =
|
851
|
+
result = logical_operation(val[1], [val[0], val[2]])
|
641
852
|
result
|
642
853
|
end
|
643
854
|
.,.,
|
@@ -646,7 +857,7 @@ module_eval(<<'.,.,', 'parser.ry', 23)
|
|
646
857
|
|
647
858
|
module_eval(<<'.,.,', 'parser.ry', 26)
|
648
859
|
def _reduce_10(val, _values, result)
|
649
|
-
result =
|
860
|
+
result = operation(val[1], [val[0], val[2]])
|
650
861
|
result
|
651
862
|
end
|
652
863
|
.,.,
|
@@ -655,14 +866,14 @@ module_eval(<<'.,.,', 'parser.ry', 26)
|
|
655
866
|
|
656
867
|
module_eval(<<'.,.,', 'parser.ry', 29)
|
657
868
|
def _reduce_12(val, _values, result)
|
658
|
-
result =
|
869
|
+
result = math_operation(val[1], [val[0], val[2]])
|
659
870
|
result
|
660
871
|
end
|
661
872
|
.,.,
|
662
873
|
|
663
874
|
module_eval(<<'.,.,', 'parser.ry', 30)
|
664
875
|
def _reduce_13(val, _values, result)
|
665
|
-
result =
|
876
|
+
result = math_operation(val[1], [val[0], val[2]])
|
666
877
|
result
|
667
878
|
end
|
668
879
|
.,.,
|
@@ -671,7 +882,7 @@ module_eval(<<'.,.,', 'parser.ry', 30)
|
|
671
882
|
|
672
883
|
module_eval(<<'.,.,', 'parser.ry', 33)
|
673
884
|
def _reduce_15(val, _values, result)
|
674
|
-
result =
|
885
|
+
result = math_operation(val[1], [val[0], val[2]])
|
675
886
|
result
|
676
887
|
end
|
677
888
|
.,.,
|
@@ -682,21 +893,21 @@ module_eval(<<'.,.,', 'parser.ry', 33)
|
|
682
893
|
|
683
894
|
module_eval(<<'.,.,', 'parser.ry', 38)
|
684
895
|
def _reduce_18(val, _values, result)
|
685
|
-
result =
|
896
|
+
result = unary_operation("!", val[1])
|
686
897
|
result
|
687
898
|
end
|
688
899
|
.,.,
|
689
900
|
|
690
901
|
module_eval(<<'.,.,', 'parser.ry', 39)
|
691
902
|
def _reduce_19(val, _values, result)
|
692
|
-
result =
|
903
|
+
result = unary_operation("-", val[1])
|
693
904
|
result
|
694
905
|
end
|
695
906
|
.,.,
|
696
907
|
|
697
908
|
module_eval(<<'.,.,', 'parser.ry', 41)
|
698
909
|
def _reduce_20(val, _values, result)
|
699
|
-
result =
|
910
|
+
result = unary_operation("!", val[1])
|
700
911
|
result
|
701
912
|
end
|
702
913
|
.,.,
|
@@ -705,7 +916,7 @@ module_eval(<<'.,.,', 'parser.ry', 41)
|
|
705
916
|
|
706
917
|
module_eval(<<'.,.,', 'parser.ry', 44)
|
707
918
|
def _reduce_22(val, _values, result)
|
708
|
-
result =
|
919
|
+
result = unary_operation("-", val[1])
|
709
920
|
result
|
710
921
|
end
|
711
922
|
.,.,
|
@@ -716,42 +927,42 @@ module_eval(<<'.,.,', 'parser.ry', 44)
|
|
716
927
|
|
717
928
|
module_eval(<<'.,.,', 'parser.ry', 48)
|
718
929
|
def _reduce_25(val, _values, result)
|
719
|
-
result =
|
930
|
+
result = indexing_call(val[0], val[2])
|
720
931
|
result
|
721
932
|
end
|
722
933
|
.,.,
|
723
934
|
|
724
935
|
module_eval(<<'.,.,', 'parser.ry', 49)
|
725
936
|
def _reduce_26(val, _values, result)
|
726
|
-
result =
|
937
|
+
result = new_message(val[0], val[2])
|
727
938
|
result
|
728
939
|
end
|
729
940
|
.,.,
|
730
941
|
|
731
942
|
module_eval(<<'.,.,', 'parser.ry', 50)
|
732
943
|
def _reduce_27(val, _values, result)
|
733
|
-
result =
|
944
|
+
result = selector_call(val[2], val[0])
|
734
945
|
result
|
735
946
|
end
|
736
947
|
.,.,
|
737
948
|
|
738
949
|
module_eval(<<'.,.,', 'parser.ry', 51)
|
739
950
|
def _reduce_28(val, _values, result)
|
740
|
-
result =
|
951
|
+
result = receiver_call(val[2], val[0], [val[4]].flatten(1))
|
741
952
|
result
|
742
953
|
end
|
743
954
|
.,.,
|
744
955
|
|
745
956
|
module_eval(<<'.,.,', 'parser.ry', 54)
|
746
957
|
def _reduce_29(val, _values, result)
|
747
|
-
result =
|
958
|
+
result = new_identifier(validated_id!(val[0]))
|
748
959
|
result
|
749
960
|
end
|
750
961
|
.,.,
|
751
962
|
|
752
963
|
module_eval(<<'.,.,', 'parser.ry', 55)
|
753
964
|
def _reduce_30(val, _values, result)
|
754
|
-
result =
|
965
|
+
result = global_call(validated_id!(val[0]), val[2])
|
755
966
|
result
|
756
967
|
end
|
757
968
|
.,.,
|
@@ -765,14 +976,14 @@ module_eval(<<'.,.,', 'parser.ry', 56)
|
|
765
976
|
|
766
977
|
module_eval(<<'.,.,', 'parser.ry', 57)
|
767
978
|
def _reduce_32(val, _values, result)
|
768
|
-
result =
|
979
|
+
result = new_list(val[1])
|
769
980
|
result
|
770
981
|
end
|
771
982
|
.,.,
|
772
983
|
|
773
984
|
module_eval(<<'.,.,', 'parser.ry', 58)
|
774
985
|
def _reduce_33(val, _values, result)
|
775
|
-
result =
|
986
|
+
result = new_map(val[1])
|
776
987
|
result
|
777
988
|
end
|
778
989
|
.,.,
|
@@ -781,7 +992,12 @@ module_eval(<<'.,.,', 'parser.ry', 58)
|
|
781
992
|
|
782
993
|
# reduce 35 omitted
|
783
994
|
|
784
|
-
|
995
|
+
module_eval(<<'.,.,', 'parser.ry', 62)
|
996
|
+
def _reduce_36(val, _values, result)
|
997
|
+
result = val[1]
|
998
|
+
result
|
999
|
+
end
|
1000
|
+
.,.,
|
785
1001
|
|
786
1002
|
# reduce 37 omitted
|
787
1003
|
|
@@ -794,7 +1010,7 @@ module_eval(<<'.,.,', 'parser.ry', 65)
|
|
794
1010
|
|
795
1011
|
module_eval(<<'.,.,', 'parser.ry', 67)
|
796
1012
|
def _reduce_39(val, _values, result)
|
797
|
-
result =
|
1013
|
+
result = []
|
798
1014
|
result
|
799
1015
|
end
|
800
1016
|
.,.,
|
@@ -810,7 +1026,7 @@ module_eval(<<'.,.,', 'parser.ry', 70)
|
|
810
1026
|
|
811
1027
|
module_eval(<<'.,.,', 'parser.ry', 71)
|
812
1028
|
def _reduce_42(val, _values, result)
|
813
|
-
[val[0]]
|
1029
|
+
result = [val[0]]
|
814
1030
|
result
|
815
1031
|
end
|
816
1032
|
.,.,
|
@@ -826,77 +1042,77 @@ module_eval(<<'.,.,', 'parser.ry', 73)
|
|
826
1042
|
|
827
1043
|
module_eval(<<'.,.,', 'parser.ry', 76)
|
828
1044
|
def _reduce_45(val, _values, result)
|
829
|
-
result = val[0].merge(
|
1045
|
+
result = val[0].merge(new_identifier(val[2]) => val[4])
|
830
1046
|
result
|
831
1047
|
end
|
832
1048
|
.,.,
|
833
1049
|
|
834
1050
|
module_eval(<<'.,.,', 'parser.ry', 77)
|
835
1051
|
def _reduce_46(val, _values, result)
|
836
|
-
result = {
|
1052
|
+
result = { new_identifier(val[0]) => val[2] }
|
837
1053
|
result
|
838
1054
|
end
|
839
1055
|
.,.,
|
840
1056
|
|
841
1057
|
module_eval(<<'.,.,', 'parser.ry', 79)
|
842
1058
|
def _reduce_47(val, _values, result)
|
843
|
-
val[0][val[2]
|
1059
|
+
val[0] << [val[2], val[4]]; result = val[0]
|
844
1060
|
result
|
845
1061
|
end
|
846
1062
|
.,.,
|
847
1063
|
|
848
1064
|
module_eval(<<'.,.,', 'parser.ry', 80)
|
849
1065
|
def _reduce_48(val, _values, result)
|
850
|
-
result =
|
1066
|
+
result = [[val[0], val[2]]]
|
851
1067
|
result
|
852
1068
|
end
|
853
1069
|
.,.,
|
854
1070
|
|
855
1071
|
module_eval(<<'.,.,', 'parser.ry', 82)
|
856
1072
|
def _reduce_49(val, _values, result)
|
857
|
-
result =
|
1073
|
+
result = literal_int(val[0])
|
858
1074
|
result
|
859
1075
|
end
|
860
1076
|
.,.,
|
861
1077
|
|
862
1078
|
module_eval(<<'.,.,', 'parser.ry', 83)
|
863
1079
|
def _reduce_50(val, _values, result)
|
864
|
-
result =
|
1080
|
+
result = literal_uint(val[0])
|
865
1081
|
result
|
866
1082
|
end
|
867
1083
|
.,.,
|
868
1084
|
|
869
1085
|
module_eval(<<'.,.,', 'parser.ry', 84)
|
870
1086
|
def _reduce_51(val, _values, result)
|
871
|
-
result =
|
1087
|
+
result = literal_double(val[0])
|
872
1088
|
result
|
873
1089
|
end
|
874
1090
|
.,.,
|
875
1091
|
|
876
1092
|
module_eval(<<'.,.,', 'parser.ry', 85)
|
877
1093
|
def _reduce_52(val, _values, result)
|
878
|
-
result =
|
1094
|
+
result = literal_bool(val[0])
|
879
1095
|
result
|
880
1096
|
end
|
881
1097
|
.,.,
|
882
1098
|
|
883
1099
|
module_eval(<<'.,.,', 'parser.ry', 86)
|
884
1100
|
def _reduce_53(val, _values, result)
|
885
|
-
result =
|
1101
|
+
result = literal_null
|
886
1102
|
result
|
887
1103
|
end
|
888
1104
|
.,.,
|
889
1105
|
|
890
1106
|
module_eval(<<'.,.,', 'parser.ry', 87)
|
891
1107
|
def _reduce_54(val, _values, result)
|
892
|
-
result =
|
1108
|
+
result = literal_string(val[0])
|
893
1109
|
result
|
894
1110
|
end
|
895
1111
|
.,.,
|
896
1112
|
|
897
1113
|
module_eval(<<'.,.,', 'parser.ry', 88)
|
898
1114
|
def _reduce_55(val, _values, result)
|
899
|
-
result =
|
1115
|
+
result = literal_bytes(val[0])
|
900
1116
|
result
|
901
1117
|
end
|
902
1118
|
.,.,
|