fluent-plugin-filter_where 1.0.0

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,206 @@
1
+ #--
2
+ # DO NOT MODIFY!!!!
3
+ # This file is automatically generated by rex 1.0.5
4
+ # from lexical definition file "lib/fluent/plugin/filter_where/parser.rex".
5
+ #++
6
+
7
+ require 'racc/parser'
8
+ class Fluent::FilterWhere::Parser < Racc::Parser
9
+ require 'strscan'
10
+
11
+ class ScanError < StandardError ; end
12
+
13
+ attr_reader :lineno
14
+ attr_reader :filename
15
+ attr_accessor :state
16
+
17
+ def scan_setup(str)
18
+ @ss = StringScanner.new(str)
19
+ @lineno = 1
20
+ @state = nil
21
+ end
22
+
23
+ def action
24
+ yield
25
+ end
26
+
27
+ def scan_str(str)
28
+ scan_setup(str)
29
+ do_parse
30
+ end
31
+ alias :scan :scan_str
32
+
33
+ def load_file( filename )
34
+ @filename = filename
35
+ open(filename, "r") do |f|
36
+ scan_setup(f.read)
37
+ end
38
+ end
39
+
40
+ def scan_file( filename )
41
+ load_file(filename)
42
+ do_parse
43
+ end
44
+
45
+
46
+ def next_token
47
+ return if @ss.eos?
48
+
49
+ # skips empty actions
50
+ until token = _next_token or @ss.eos?; end
51
+ token
52
+ end
53
+
54
+ def _next_token
55
+ text = @ss.peek(1)
56
+ @lineno += 1 if text == "\n"
57
+ token = case @state
58
+ when nil
59
+ case
60
+ when (text = @ss.scan(/\(/i))
61
+ action { [:"(", text] }
62
+
63
+ when (text = @ss.scan(/\)/i))
64
+ action { [:")", text] }
65
+
66
+ when (text = @ss.scan(/\=/i))
67
+ action { [:EQ, text] }
68
+
69
+ when (text = @ss.scan(/\<\>/i))
70
+ action { [:NEQ, text] }
71
+
72
+ when (text = @ss.scan(/\!\=/i))
73
+ action { [:NEQ, text] }
74
+
75
+ when (text = @ss.scan(/\>\=/i))
76
+ action { [:GE, text] }
77
+
78
+ when (text = @ss.scan(/\>/i))
79
+ action { [:GT, text] }
80
+
81
+ when (text = @ss.scan(/\<\=/i))
82
+ action { [:LE, text] }
83
+
84
+ when (text = @ss.scan(/\</i))
85
+ action { [:LT, text] }
86
+
87
+ when (text = @ss.scan(/-?[0-9]+(\.[0-9]+)?/i))
88
+ action { [:NUMBER, NumberLiteral.new(text)] }
89
+
90
+ when (text = @ss.scan(/[a-zA-Z$][a-zA-z0-9\.\-_]*/i))
91
+ action {
92
+ case text.downcase
93
+ when 'and'.freeze
94
+ [:AND, text]
95
+ when 'or'.freeze
96
+ [:OR, text]
97
+ when 'start_with'.freeze
98
+ [:START_WITH, text]
99
+ when 'end_with'.freeze
100
+ [:END_WITH, text]
101
+ when 'include'.freeze
102
+ [:INCLUDE, text]
103
+ when 'regexp'.freeze
104
+ [:REGEXP, text]
105
+ when 'is'.freeze
106
+ [:IS, text]
107
+ when 'not'.freeze
108
+ [:NOT, text]
109
+ when 'null'.freeze
110
+ [:NULL, text]
111
+ when 'true'.freeze
112
+ [:BOOLEAN, BooleanLiteral.new(text)]
113
+ when 'false'.freeze
114
+ [:BOOLEAN, BooleanLiteral.new(text)]
115
+ else
116
+ [:IDENTIFIER, IdentifierLiteral.new(text)]
117
+ end
118
+ }
119
+
120
+
121
+ when (text = @ss.scan(/\"/i))
122
+ action { @state = :IDENTIFIER; @string = ''; nil }
123
+
124
+ when (text = @ss.scan(/\'/i))
125
+ action { @state = :STRING; @string = ''; nil }
126
+
127
+ when (text = @ss.scan(/[ \t]+/i))
128
+ action { }
129
+
130
+ when (text = @ss.scan(/\n|\r|\r\n/i))
131
+ action { }
132
+
133
+ else
134
+ text = @ss.string[@ss.pos .. -1]
135
+ raise ScanError, "can not match: '" + text + "'"
136
+ end # if
137
+
138
+ when :IDENTIFIER
139
+ case
140
+ when (text = @ss.scan(/\"/i))
141
+ action { @state = nil; [:IDENTIFIER, IdentifierLiteral.new(@string)] }
142
+
143
+ when (text = @ss.scan(/[^\r\n\"\\]+/i))
144
+ action { @string << text; nil }
145
+
146
+ when (text = @ss.scan(/\\\"/i))
147
+ action { @string << '"'; nil }
148
+
149
+ when (text = @ss.scan(/\\\'/i))
150
+ action { @string << "'"; nil }
151
+
152
+ when (text = @ss.scan(/\\\\/i))
153
+ action { @string << "\\"; nil }
154
+
155
+ else
156
+ text = @ss.string[@ss.pos .. -1]
157
+ raise ScanError, "can not match: '" + text + "'"
158
+ end # if
159
+
160
+ when :STRING
161
+ case
162
+ when (text = @ss.scan(/\'/i))
163
+ action { @state = nil; [:STRING, StringLiteral.new(@string)] }
164
+
165
+ when (text = @ss.scan(/[^\r\n\'\\]+/i))
166
+ action { @string << text; nil }
167
+
168
+ when (text = @ss.scan(/\b/i))
169
+ action { @string << "\b"; nil }
170
+
171
+ when (text = @ss.scan(/\t/i))
172
+ action { @string << "\t"; nil }
173
+
174
+ when (text = @ss.scan(/\n/i))
175
+ action { @string << "\n"; nil }
176
+
177
+ when (text = @ss.scan(/\f/i))
178
+ action { @string << "\f"; nil }
179
+
180
+ when (text = @ss.scan(/\r/i))
181
+ action { @string << "\r"; nil }
182
+
183
+ when (text = @ss.scan(/\"/i))
184
+ action { @string << '"'; nil }
185
+
186
+ when (text = @ss.scan(/\'/i))
187
+ action { @string << "'"; nil }
188
+
189
+ when (text = @ss.scan(/\\/i))
190
+ action { @string << "\\"; nil }
191
+
192
+ else
193
+ text = @ss.string[@ss.pos .. -1]
194
+ raise ScanError, "can not match: '" + text + "'"
195
+ end # if
196
+
197
+ else
198
+ raise ScanError, "undefined state: '" + state.to_s + "'"
199
+ end # case state
200
+ token
201
+ end # def _next_token
202
+
203
+ def on_error(error_token_id, error_value, value_stack)
204
+ super
205
+ end
206
+ end # class
@@ -0,0 +1,419 @@
1
+ #
2
+ # DO NOT MODIFY!!!!
3
+ # This file is automatically generated by Racc 1.4.14
4
+ # from Racc grammer file "".
5
+ #
6
+
7
+ require 'racc/parser.rb'
8
+
9
+ #
10
+ # generated by racc
11
+ #
12
+ module Fluent; module FilterWhere; end; end
13
+ require_relative 'parser.rex'
14
+ require_relative 'parser/literal'
15
+ require_relative 'parser/exp'
16
+
17
+ module Fluent
18
+ module FilterWhere
19
+ class Parser < Racc::Parser
20
+
21
+ module_eval(<<'...end parser.racc/module_eval...', 'parser.racc', 84)
22
+
23
+ ...end parser.racc/module_eval...
24
+ ##### State transition tables begin ###
25
+
26
+ racc_action_table = [
27
+ 10, 11, 7, 31, 32, 44, 46, 45, 7, 33,
28
+ 34, 35, 61, 7, 62, 4, 6, 5, 3, 8,
29
+ 70, 4, 6, 5, 3, 8, 4, 6, 5, 3,
30
+ 8, 7, 41, 43, 42, 63, 7, 10, 11, 23,
31
+ 24, 64, 56, 65, 4, 6, 5, 3, 8, 4,
32
+ 6, 5, 3, 8, 55, 12, 13, 14, 15, 16,
33
+ 17, 18, 19, 20, 21, 22, 25, 26, 27, 28,
34
+ 29, 30, 10, 11, 66, 67, 68, 69, 10, 71,
35
+ 9, 38, 47, 48, 49, 50, 51, 52, 53, 54,
36
+ 57, 58, 59, 60 ]
37
+
38
+ racc_action_check = [
39
+ 37, 37, 0, 6, 6, 13, 13, 13, 11, 6,
40
+ 6, 6, 27, 7, 28, 0, 0, 0, 0, 0,
41
+ 37, 11, 11, 11, 11, 11, 7, 7, 7, 7,
42
+ 7, 8, 12, 12, 12, 29, 10, 2, 2, 4,
43
+ 4, 30, 22, 31, 8, 8, 8, 8, 8, 10,
44
+ 10, 10, 10, 10, 22, 3, 3, 3, 3, 3,
45
+ 3, 3, 3, 3, 3, 3, 5, 5, 5, 5,
46
+ 5, 5, 36, 36, 32, 33, 34, 35, 40, 56,
47
+ 1, 9, 14, 15, 16, 17, 18, 19, 20, 21,
48
+ 23, 24, 25, 26 ]
49
+
50
+ racc_action_pointer = [
51
+ -2, 80, 35, 50, 34, 61, -2, 9, 27, 81,
52
+ 32, 4, 15, -12, 63, 64, 65, 66, 68, 69,
53
+ 70, 71, 38, 70, 71, 72, 73, -8, -6, 15,
54
+ 21, 23, 54, 55, 56, 57, 70, -2, nil, nil,
55
+ 76, nil, nil, nil, nil, nil, nil, nil, nil, nil,
56
+ nil, nil, nil, nil, nil, nil, 63, nil, nil, nil,
57
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
58
+ nil, nil ]
59
+
60
+ racc_action_default = [
61
+ -1, -36, -2, -36, -36, -36, -36, -36, -36, -36,
62
+ -36, -36, -36, -36, -36, -36, -36, -36, -36, -36,
63
+ -36, -36, -36, -36, -36, -36, -36, -36, -36, -36,
64
+ -36, -36, -36, -36, -36, -36, -34, -36, 72, -32,
65
+ -33, -3, -7, -19, -4, -8, -20, -9, -10, -11,
66
+ -12, -21, -22, -23, -29, -30, -36, -5, -6, -13,
67
+ -14, -15, -16, -17, -18, -24, -25, -26, -27, -28,
68
+ -35, -31 ]
69
+
70
+ racc_goto_table = [
71
+ 2, 1, nil, nil, nil, nil, nil, 36, 37, nil,
72
+ 39, 40 ]
73
+
74
+ racc_goto_check = [
75
+ 2, 1, nil, nil, nil, nil, nil, 2, 2, nil,
76
+ 2, 2 ]
77
+
78
+ racc_goto_pointer = [
79
+ nil, 1, 0 ]
80
+
81
+ racc_goto_default = [
82
+ nil, nil, nil ]
83
+
84
+ racc_reduce_table = [
85
+ 0, 0, :racc_error,
86
+ 0, 24, :_reduce_none,
87
+ 1, 24, :_reduce_2,
88
+ 3, 25, :_reduce_3,
89
+ 3, 25, :_reduce_4,
90
+ 3, 25, :_reduce_5,
91
+ 3, 25, :_reduce_6,
92
+ 3, 25, :_reduce_7,
93
+ 3, 25, :_reduce_8,
94
+ 3, 25, :_reduce_9,
95
+ 3, 25, :_reduce_10,
96
+ 3, 25, :_reduce_11,
97
+ 3, 25, :_reduce_12,
98
+ 3, 25, :_reduce_13,
99
+ 3, 25, :_reduce_14,
100
+ 3, 25, :_reduce_15,
101
+ 3, 25, :_reduce_16,
102
+ 3, 25, :_reduce_17,
103
+ 3, 25, :_reduce_18,
104
+ 3, 25, :_reduce_19,
105
+ 3, 25, :_reduce_20,
106
+ 3, 25, :_reduce_21,
107
+ 3, 25, :_reduce_22,
108
+ 3, 25, :_reduce_23,
109
+ 3, 25, :_reduce_24,
110
+ 3, 25, :_reduce_25,
111
+ 3, 25, :_reduce_26,
112
+ 3, 25, :_reduce_27,
113
+ 3, 25, :_reduce_28,
114
+ 3, 25, :_reduce_29,
115
+ 3, 25, :_reduce_30,
116
+ 4, 25, :_reduce_31,
117
+ 3, 25, :_reduce_32,
118
+ 3, 25, :_reduce_33,
119
+ 2, 25, :_reduce_34,
120
+ 3, 25, :_reduce_35 ]
121
+
122
+ racc_reduce_n = 36
123
+
124
+ racc_shift_n = 72
125
+
126
+ racc_token_table = {
127
+ false => 0,
128
+ :error => 1,
129
+ :OR => 2,
130
+ :AND => 3,
131
+ :NOT => 4,
132
+ :EQ => 5,
133
+ :NEQ => 6,
134
+ :GT => 7,
135
+ :GE => 8,
136
+ :LT => 9,
137
+ :LE => 10,
138
+ :START_WITH => 11,
139
+ :END_WITH => 12,
140
+ :INCLUDE => 13,
141
+ :REGEXP => 14,
142
+ :IS => 15,
143
+ :NULL => 16,
144
+ :BOOLEAN => 17,
145
+ :STRING => 18,
146
+ :NUMBER => 19,
147
+ :IDENTIFIER => 20,
148
+ "(" => 21,
149
+ ")" => 22 }
150
+
151
+ racc_nt_base = 23
152
+
153
+ racc_use_result_var = false
154
+
155
+ Racc_arg = [
156
+ racc_action_table,
157
+ racc_action_check,
158
+ racc_action_default,
159
+ racc_action_pointer,
160
+ racc_goto_table,
161
+ racc_goto_check,
162
+ racc_goto_default,
163
+ racc_goto_pointer,
164
+ racc_nt_base,
165
+ racc_reduce_table,
166
+ racc_token_table,
167
+ racc_shift_n,
168
+ racc_reduce_n,
169
+ racc_use_result_var ]
170
+
171
+ Racc_token_to_s_table = [
172
+ "$end",
173
+ "error",
174
+ "OR",
175
+ "AND",
176
+ "NOT",
177
+ "EQ",
178
+ "NEQ",
179
+ "GT",
180
+ "GE",
181
+ "LT",
182
+ "LE",
183
+ "START_WITH",
184
+ "END_WITH",
185
+ "INCLUDE",
186
+ "REGEXP",
187
+ "IS",
188
+ "NULL",
189
+ "BOOLEAN",
190
+ "STRING",
191
+ "NUMBER",
192
+ "IDENTIFIER",
193
+ "\"(\"",
194
+ "\")\"",
195
+ "$start",
196
+ "input",
197
+ "exp" ]
198
+
199
+ Racc_debug_parser = false
200
+
201
+ ##### State transition tables end #####
202
+
203
+ # reduce 0 omitted
204
+
205
+ # reduce 1 omitted
206
+
207
+ module_eval(<<'.,.,', 'parser.racc', 34)
208
+ def _reduce_2(val, _values)
209
+ val[0]
210
+ end
211
+ .,.,
212
+
213
+ module_eval(<<'.,.,', 'parser.racc', 37)
214
+ def _reduce_3(val, _values)
215
+ BooleanOpExp.new(val[0], val[2], :EQ)
216
+ end
217
+ .,.,
218
+
219
+ module_eval(<<'.,.,', 'parser.racc', 38)
220
+ def _reduce_4(val, _values)
221
+ BooleanOpExp.new(val[0], val[2], :NEQ)
222
+ end
223
+ .,.,
224
+
225
+ module_eval(<<'.,.,', 'parser.racc', 39)
226
+ def _reduce_5(val, _values)
227
+ BooleanOpExp.new(val[0], val[2], :EQ)
228
+ end
229
+ .,.,
230
+
231
+ module_eval(<<'.,.,', 'parser.racc', 40)
232
+ def _reduce_6(val, _values)
233
+ BooleanOpExp.new(val[0], val[2], :NEQ)
234
+ end
235
+ .,.,
236
+
237
+ module_eval(<<'.,.,', 'parser.racc', 41)
238
+ def _reduce_7(val, _values)
239
+ NumberOpExp.new(val[0], val[2], :EQ)
240
+ end
241
+ .,.,
242
+
243
+ module_eval(<<'.,.,', 'parser.racc', 42)
244
+ def _reduce_8(val, _values)
245
+ NumberOpExp.new(val[0], val[2], :NEQ)
246
+ end
247
+ .,.,
248
+
249
+ module_eval(<<'.,.,', 'parser.racc', 43)
250
+ def _reduce_9(val, _values)
251
+ NumberOpExp.new(val[0], val[2], :GT)
252
+ end
253
+ .,.,
254
+
255
+ module_eval(<<'.,.,', 'parser.racc', 44)
256
+ def _reduce_10(val, _values)
257
+ NumberOpExp.new(val[0], val[2], :GE)
258
+ end
259
+ .,.,
260
+
261
+ module_eval(<<'.,.,', 'parser.racc', 45)
262
+ def _reduce_11(val, _values)
263
+ NumberOpExp.new(val[0], val[2], :LT)
264
+ end
265
+ .,.,
266
+
267
+ module_eval(<<'.,.,', 'parser.racc', 46)
268
+ def _reduce_12(val, _values)
269
+ NumberOpExp.new(val[0], val[2], :LE)
270
+ end
271
+ .,.,
272
+
273
+ module_eval(<<'.,.,', 'parser.racc', 47)
274
+ def _reduce_13(val, _values)
275
+ NumberOpExp.new(val[0], val[2], :EQ)
276
+ end
277
+ .,.,
278
+
279
+ module_eval(<<'.,.,', 'parser.racc', 48)
280
+ def _reduce_14(val, _values)
281
+ NumberOpExp.new(val[0], val[2], :NEQ)
282
+ end
283
+ .,.,
284
+
285
+ module_eval(<<'.,.,', 'parser.racc', 49)
286
+ def _reduce_15(val, _values)
287
+ NumberOpExp.new(val[0], val[2], :GT)
288
+ end
289
+ .,.,
290
+
291
+ module_eval(<<'.,.,', 'parser.racc', 50)
292
+ def _reduce_16(val, _values)
293
+ NumberOpExp.new(val[0], val[2], :GE)
294
+ end
295
+ .,.,
296
+
297
+ module_eval(<<'.,.,', 'parser.racc', 51)
298
+ def _reduce_17(val, _values)
299
+ NumberOpExp.new(val[0], val[2], :LT)
300
+ end
301
+ .,.,
302
+
303
+ module_eval(<<'.,.,', 'parser.racc', 52)
304
+ def _reduce_18(val, _values)
305
+ NumberOpExp.new(val[0], val[2], :LE)
306
+ end
307
+ .,.,
308
+
309
+ module_eval(<<'.,.,', 'parser.racc', 53)
310
+ def _reduce_19(val, _values)
311
+ StringOpExp.new(val[0], val[2], :EQ)
312
+ end
313
+ .,.,
314
+
315
+ module_eval(<<'.,.,', 'parser.racc', 54)
316
+ def _reduce_20(val, _values)
317
+ StringOpExp.new(val[0], val[2], :NEQ)
318
+ end
319
+ .,.,
320
+
321
+ module_eval(<<'.,.,', 'parser.racc', 55)
322
+ def _reduce_21(val, _values)
323
+ StringOpExp.new(val[0], val[2], :START_WITH)
324
+ end
325
+ .,.,
326
+
327
+ module_eval(<<'.,.,', 'parser.racc', 56)
328
+ def _reduce_22(val, _values)
329
+ StringOpExp.new(val[0], val[2], :END_WITH)
330
+ end
331
+ .,.,
332
+
333
+ module_eval(<<'.,.,', 'parser.racc', 57)
334
+ def _reduce_23(val, _values)
335
+ StringOpExp.new(val[0], val[2], :INCLUDE)
336
+ end
337
+ .,.,
338
+
339
+ module_eval(<<'.,.,', 'parser.racc', 58)
340
+ def _reduce_24(val, _values)
341
+ StringOpExp.new(val[0], val[2], :EQ)
342
+ end
343
+ .,.,
344
+
345
+ module_eval(<<'.,.,', 'parser.racc', 59)
346
+ def _reduce_25(val, _values)
347
+ StringOpExp.new(val[0], val[2], :NEQ)
348
+ end
349
+ .,.,
350
+
351
+ module_eval(<<'.,.,', 'parser.racc', 60)
352
+ def _reduce_26(val, _values)
353
+ StringOpExp.new(val[0], val[2], :START_WITH)
354
+ end
355
+ .,.,
356
+
357
+ module_eval(<<'.,.,', 'parser.racc', 61)
358
+ def _reduce_27(val, _values)
359
+ StringOpExp.new(val[0], val[2], :END_WITH)
360
+ end
361
+ .,.,
362
+
363
+ module_eval(<<'.,.,', 'parser.racc', 62)
364
+ def _reduce_28(val, _values)
365
+ StringOpExp.new(val[0], val[2], :INCLUDE)
366
+ end
367
+ .,.,
368
+
369
+ module_eval(<<'.,.,', 'parser.racc', 63)
370
+ def _reduce_29(val, _values)
371
+ RegexpOpExp.new(val[0], val[2], :REGEXP)
372
+ end
373
+ .,.,
374
+
375
+ module_eval(<<'.,.,', 'parser.racc', 64)
376
+ def _reduce_30(val, _values)
377
+ NullOpExp.new(val[0], :EQ)
378
+ end
379
+ .,.,
380
+
381
+ module_eval(<<'.,.,', 'parser.racc', 65)
382
+ def _reduce_31(val, _values)
383
+ NullOpExp.new(val[0], :NEQ)
384
+ end
385
+ .,.,
386
+
387
+ module_eval(<<'.,.,', 'parser.racc', 66)
388
+ def _reduce_32(val, _values)
389
+ LogicalOpExp.new(val[0], val[2], :OR)
390
+ end
391
+ .,.,
392
+
393
+ module_eval(<<'.,.,', 'parser.racc', 67)
394
+ def _reduce_33(val, _values)
395
+ LogicalOpExp.new(val[0], val[2], :AND)
396
+ end
397
+ .,.,
398
+
399
+ module_eval(<<'.,.,', 'parser.racc', 68)
400
+ def _reduce_34(val, _values)
401
+ NegateOpExp.new(val[1])
402
+ end
403
+ .,.,
404
+
405
+ module_eval(<<'.,.,', 'parser.racc', 69)
406
+ def _reduce_35(val, _values)
407
+ val[1]
408
+ end
409
+ .,.,
410
+
411
+ def _reduce_none(val, _values)
412
+ val[0]
413
+ end
414
+
415
+ end # class Parser
416
+ end # module FilterWhere
417
+ end # module Fluent
418
+
419
+