gql 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,18 @@
1
+ module GQL
2
+ class Executor
3
+ def initialize(ast_root)
4
+ @ast_root = ast_root
5
+ @variables = ast_root.variables
6
+ end
7
+
8
+ def execute(context = {})
9
+ root_class = Schema.root
10
+
11
+ raise Errors::UndefinedRoot if root_class.nil?
12
+ raise Errors::InvalidNodeClass.new(root_class, Node) unless root_class < Node
13
+
14
+ root = root_class.new(@ast_root, nil, @variables, context)
15
+ root.__value
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,7 @@
1
+ module GQL
2
+ class Field < Node
3
+ def __raw_value
4
+ __target
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,6 @@
1
+ module GQL
2
+ module Fields
3
+ class Boolean < Field
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,29 @@
1
+ module GQL
2
+ module Fields
3
+ class Connection < Field
4
+ def __value
5
+ if @ast_node.fields
6
+ __raw_value
7
+ else
8
+ super
9
+ end
10
+ end
11
+
12
+ def __raw_value
13
+ raise Errors::InvalidNodeClass.new(__connection_class__, GQL::Connection) unless __connection_class__ < GQL::Connection
14
+
15
+ connection = __connection_class__.new(__node_class__, @ast_node, __target, @variables, __context)
16
+ connection.__value
17
+ end
18
+
19
+ private
20
+ def __connection_class__
21
+ self.class.const_get :CONNECTION_CLASS
22
+ end
23
+
24
+ def __node_class__
25
+ self.class.const_get :NODE_CLASS
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,6 @@
1
+ module GQL
2
+ module Fields
3
+ class Float < Field
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,10 @@
1
+ module GQL
2
+ module Fields
3
+ class Integer < Field
4
+ # This is just an example call, monkeypatch to add your own.
5
+ call :is_zero, returns: Boolean do
6
+ target.zero?
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,17 @@
1
+ module GQL
2
+ module Fields
3
+ class Object < Field
4
+ def __value
5
+ raise Errors::InvalidNodeClass.new(__node_class__, Node) unless __node_class__ < Node
6
+
7
+ node = __node_class__.new(@ast_node, __target, @variables, __context)
8
+ node.__value
9
+ end
10
+
11
+ private
12
+ def __node_class__
13
+ self.class.const_get :NODE_CLASS
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,19 @@
1
+ module GQL
2
+ module Fields
3
+ class String < Field
4
+ call :upcase do
5
+ target.upcase
6
+ end
7
+
8
+ call :downcase do
9
+ target.downcase
10
+ end
11
+
12
+ call :length, returns: Integer do
13
+ target.size
14
+ end
15
+
16
+ # These are just example calls, monkeypatch to add your own.
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,121 @@
1
+ require 'active_support/core_ext/class/attribute'
2
+ require 'active_support/core_ext/string/inflections'
3
+
4
+ module GQL
5
+ class Node
6
+ class_attribute :call_definitions
7
+ self.call_definitions = {}
8
+
9
+ class_attribute :field_classes
10
+ self.field_classes = {}
11
+
12
+ class << self
13
+ def cursor(method_name)
14
+ define_method :cursor do
15
+ __target.send(method_name).to_s
16
+ end
17
+ end
18
+
19
+ def call(name, options = {}, &block)
20
+ definition = {
21
+ returns: options[:returns],
22
+ body: block || lambda { |*args| __target.public_send(name, *args) }
23
+ }
24
+
25
+ self.call_definitions = call_definitions.merge(name => definition)
26
+ end
27
+
28
+ def fields(&block)
29
+ instance_eval &block
30
+ end
31
+
32
+ def field(*names, base_class: nil, node_class: nil, connection_class: nil)
33
+ classes = names.reduce({}) do |result, name|
34
+ field_class = Class.new(base_class || Field)
35
+ field_class.const_set :NAME, name
36
+ field_class.const_set :NODE_CLASS, node_class
37
+ field_class.const_set :CONNECTION_CLASS, connection_class
38
+
39
+ self.const_set "#{name.to_s.camelize}Field", field_class
40
+
41
+ result.merge name => field_class
42
+ end
43
+
44
+ self.field_classes = field_classes.merge(classes)
45
+ end
46
+
47
+ def method_missing(method, *args, &block)
48
+ if base_class = Schema.fields[method]
49
+ options = args.extract_options!
50
+
51
+ field(*args, options.merge(base_class: base_class))
52
+ else
53
+ super
54
+ end
55
+ rescue NoMethodError => exc
56
+ raise Errors::UndefinedType, method
57
+ end
58
+ end
59
+
60
+ call :_identity do
61
+ target
62
+ end
63
+
64
+ attr_reader :__target, :__context
65
+
66
+ def initialize(ast_node, target, variables, context)
67
+ @ast_node, @__target = ast_node, target
68
+ @variables, @__context = variables, context
69
+ end
70
+
71
+ def __value
72
+ if ast_call = @ast_node.call
73
+ definition = self.class.call_definitions[ast_call.name]
74
+
75
+ raise Errors::UndefinedCall.new(ast_call.name, self.class) if definition.nil?
76
+
77
+ call = Call.new(self, ast_call, __target, definition, @variables, __context)
78
+ call.execute
79
+ elsif ast_fields = @ast_node.fields
80
+ ast_fields.reduce({}) do |memo, ast_field|
81
+ key = ast_field.alias_name || ast_field.name
82
+
83
+ val =
84
+ case key
85
+ when :node
86
+ field = self.class.new(ast_field, __target, @variables, __context)
87
+ field.__value
88
+ when :cursor
89
+ cursor
90
+ else
91
+ target = public_send(ast_field.name)
92
+ field_class = self.class.field_classes[ast_field.name]
93
+
94
+ raise Errors::InvalidNodeClass.new(field_class.superclass, Field) unless field_class < Field
95
+
96
+ field = field_class.new(ast_field, target, @variables, __context)
97
+ field.__value
98
+ end
99
+
100
+ memo.merge key => val
101
+ end
102
+ else
103
+ __raw_value
104
+ end
105
+ end
106
+
107
+ def __raw_value
108
+ nil
109
+ end
110
+
111
+ def method_missing(method, *args, &block)
112
+ if __target.respond_to? method
113
+ __target.public_send method, *args, &block
114
+ else
115
+ super
116
+ end
117
+ rescue NoMethodError => exc
118
+ raise Errors::UndefinedField.new(method, self.class)
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,704 @@
1
+ #
2
+ # DO NOT MODIFY!!!!
3
+ # This file is automatically generated by Racc 1.4.12
4
+ # from Racc grammer file "".
5
+ #
6
+
7
+ require 'racc/parser.rb'
8
+
9
+
10
+ require 'json'
11
+ require 'active_support/core_ext/object/blank'
12
+
13
+ module GQL
14
+ class Parser < Racc::Parser
15
+
16
+ module_eval(<<'...end parser.y/module_eval...', 'parser.y', 145)
17
+
18
+ class QueryNode < Struct.new(:call, :variables)
19
+ end
20
+
21
+ class FieldNode < Struct.new(:name, :alias_name, :call, :fields)
22
+ end
23
+
24
+ class CallNode < Struct.new(:name, :arguments, :call, :fields)
25
+ end
26
+
27
+ class JSONHandler
28
+ attr_reader :stack
29
+
30
+ def initialize
31
+ clear
32
+ end
33
+
34
+ def start_object
35
+ push [:hash]
36
+ end
37
+
38
+ def start_array
39
+ push [:array]
40
+ end
41
+
42
+ def end_array
43
+ @stack.pop
44
+ end
45
+
46
+ alias :end_object :end_array
47
+
48
+ def scalar(s)
49
+ @stack.last << [:scalar, s]
50
+ end
51
+
52
+ def push(o)
53
+ @stack.last << o
54
+ @stack << o
55
+ end
56
+
57
+ def result
58
+ root = @stack.first.last
59
+ value = process(root.first, root.drop(1))
60
+ clear
61
+ value
62
+ end
63
+
64
+ private
65
+ def clear
66
+ @stack = [[:json]]
67
+ end
68
+
69
+ def process(type, rest)
70
+ case type
71
+ when :array
72
+ rest.map { |x| process(x.first, x.drop(1)) }
73
+ when :hash
74
+ Hash[rest.map { |x|
75
+ process(x.first, x.drop(1))
76
+ }.each_slice(2).to_a]
77
+ when :scalar
78
+ rest.first
79
+ end
80
+ end
81
+ end
82
+
83
+ UNESCAPE_MAP = Hash.new { |h, k| h[k] = k.chr }
84
+
85
+ UNESCAPE_MAP.update(
86
+ ?" => '"',
87
+ ?\\ => '\\',
88
+ ?/ => '/',
89
+ ?b => "\b",
90
+ ?f => "\f",
91
+ ?n => "\n",
92
+ ?r => "\r",
93
+ ?t => "\t",
94
+ ?u => nil,
95
+ )
96
+
97
+ EMPTY_8BIT_STRING = ''
98
+
99
+ if String.method_defined? :encode
100
+ EMPTY_8BIT_STRING.force_encoding Encoding::ASCII_8BIT
101
+ end
102
+
103
+ def initialize(tokenizer)
104
+ super()
105
+
106
+ @tokenizer = tokenizer
107
+ end
108
+
109
+ def next_token
110
+ @tokenizer.next_token
111
+ end
112
+
113
+ def parse
114
+ @json = JSONHandler.new
115
+ do_parse
116
+ end
117
+
118
+ def on_error(token, value, vstack)
119
+ raise Errors::ParseError.new(value, token_to_str(token))
120
+ end
121
+
122
+ private
123
+ def unescape_string(str)
124
+ string = str.gsub(%r((?:\\[\\bfnrt"/]|(?:\\u(?:[A-Fa-f\d]{4}))+|\\[\x20-\xff]))n) do |c|
125
+ if u = UNESCAPE_MAP[$&[1]]
126
+ u
127
+ else # \uXXXX
128
+ bytes = EMPTY_8BIT_STRING.dup
129
+ i = 0
130
+
131
+ while c[6 * i] == ?\\ && c[6 * i + 1] == ?u
132
+ bytes << c[6 * i + 2, 2].to_i(16) << c[6 * i + 4, 2].to_i(16)
133
+ i += 1
134
+ end
135
+
136
+ JSON.iconv('utf-8', 'utf-16be', bytes)
137
+ end
138
+ end
139
+
140
+ if string.respond_to? :force_encoding
141
+ string.force_encoding ::Encoding::UTF_8
142
+ end
143
+
144
+ string
145
+ end
146
+
147
+ def convert_number(str)
148
+ str.count('.') > 0 ? str.to_f : str.to_i
149
+ end
150
+
151
+ def convert_variables(arr1, arr2)
152
+ Hash[*arr1.flatten(1)].merge Hash[*arr2.flatten(1)]
153
+ end
154
+ ...end parser.y/module_eval...
155
+ ##### State transition tables begin ###
156
+
157
+ racc_action_table = [
158
+ 30, 31, 32, 33, 34, 30, 31, 32, 33, 34,
159
+ 38, 25, 65, 6, 39, 10, 25, 27, 52, 30,
160
+ 52, 55, 27, 30, 31, 32, 33, 34, 62, 7,
161
+ 47, 47, 40, 71, 25, 38, 67, 6, 66, 39,
162
+ 27, 30, 31, 32, 33, 34, 30, 31, 32, 33,
163
+ 34, 10, 25, 59, 60, 6, 6, 25, 27, 12,
164
+ 10, 14, 6, 27, 30, 31, 32, 33, 34, 17,
165
+ 35, 10, 63, 30, 10, 25, 71, 71, 10, nil,
166
+ nil, 27 ]
167
+
168
+ racc_action_check = [
169
+ 26, 26, 26, 26, 26, 12, 12, 12, 12, 12,
170
+ 16, 26, 51, 0, 16, 39, 12, 26, 26, 24,
171
+ 51, 39, 12, 17, 17, 17, 17, 17, 46, 1,
172
+ 46, 24, 17, 58, 17, 58, 56, 17, 56, 58,
173
+ 17, 60, 60, 60, 60, 60, 63, 63, 63, 63,
174
+ 63, 2, 60, 41, 41, 60, 3, 63, 60, 5,
175
+ 6, 7, 8, 63, 65, 65, 65, 65, 65, 9,
176
+ 13, 38, 49, 62, 67, 65, 68, 69, 71, nil,
177
+ nil, 65 ]
178
+
179
+ racc_action_pointer = [
180
+ -3, 29, 43, 40, nil, 44, 52, 61, 46, 59,
181
+ nil, nil, 3, 53, nil, nil, 1, 21, nil, nil,
182
+ nil, nil, nil, nil, 17, nil, -2, nil, nil, nil,
183
+ nil, nil, nil, nil, nil, nil, nil, nil, 63, 7,
184
+ nil, 42, nil, nil, nil, nil, 16, nil, nil, 54,
185
+ nil, 0, nil, nil, nil, nil, 24, nil, 26, nil,
186
+ 39, nil, 71, 44, nil, 62, nil, 66, 69, 70,
187
+ nil, 70, nil, nil, nil, nil, nil, nil, nil, nil ]
188
+
189
+ racc_action_default = [
190
+ -24, -56, -56, -25, -26, -56, -56, -56, -24, -6,
191
+ -55, -27, -56, -56, 80, -1, -4, -56, -28, -30,
192
+ -31, -32, -33, -34, -56, -37, -56, -44, -48, -49,
193
+ -50, -51, -52, -53, -54, -29, -2, -3, -56, -56,
194
+ -7, -56, -10, -11, -12, -35, -56, -38, -40, -56,
195
+ -42, -56, -45, -47, -5, -13, -56, -16, -22, -8,
196
+ -56, -36, -56, -56, -43, -56, -14, -56, -20, -21,
197
+ -19, -56, -9, -39, -41, -46, -15, -17, -18, -23 ]
198
+
199
+ racc_goto_table = [
200
+ 13, 42, 43, 53, 36, 37, 57, 8, 45, 70,
201
+ 48, 49, 50, 2, 1, 16, 41, 19, 56, 77,
202
+ 78, 15, 11, 18, 46, 51, nil, nil, nil, nil,
203
+ 61, nil, nil, 58, 76, nil, nil, 64, nil, nil,
204
+ 74, nil, 75, 54, 72, 43, 68, 69, 73, 49,
205
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
206
+ nil, 58, nil, nil, nil, 79 ]
207
+
208
+ racc_goto_check = [
209
+ 4, 9, 10, 18, 6, 7, 13, 3, 23, 14,
210
+ 25, 26, 28, 2, 1, 5, 8, 11, 12, 14,
211
+ 14, 2, 16, 17, 24, 29, nil, nil, nil, nil,
212
+ 23, nil, nil, 4, 13, nil, nil, 28, nil, nil,
213
+ 18, nil, 18, 3, 9, 10, 6, 7, 25, 26,
214
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
215
+ nil, 4, nil, nil, nil, 4 ]
216
+
217
+ racc_goto_pointer = [
218
+ nil, 14, 13, 5, -6, 6, -12, -11, -1, -16,
219
+ -15, 5, -21, -33, -49, nil, 19, 11, -23, nil,
220
+ nil, nil, nil, -16, 0, -14, -13, nil, -14, -1,
221
+ nil ]
222
+
223
+ racc_goto_default = [
224
+ nil, nil, nil, nil, 9, nil, nil, nil, nil, nil,
225
+ 5, 44, nil, nil, nil, 3, 4, nil, 20, 21,
226
+ 22, 23, 24, nil, nil, nil, 28, 26, nil, nil,
227
+ 29 ]
228
+
229
+ racc_reduce_table = [
230
+ 0, 0, :racc_error,
231
+ 3, 22, :_reduce_1,
232
+ 3, 24, :_reduce_2,
233
+ 3, 24, :_reduce_3,
234
+ 2, 24, :_reduce_4,
235
+ 2, 28, :_reduce_5,
236
+ 0, 26, :_reduce_6,
237
+ 2, 26, :_reduce_7,
238
+ 3, 26, :_reduce_8,
239
+ 3, 29, :_reduce_9,
240
+ 1, 29, :_reduce_10,
241
+ 1, 30, :_reduce_none,
242
+ 1, 30, :_reduce_none,
243
+ 2, 27, :_reduce_13,
244
+ 3, 27, :_reduce_14,
245
+ 3, 33, :_reduce_15,
246
+ 1, 33, :_reduce_16,
247
+ 3, 34, :_reduce_17,
248
+ 3, 34, :_reduce_18,
249
+ 2, 34, :_reduce_19,
250
+ 2, 34, :_reduce_20,
251
+ 2, 34, :_reduce_21,
252
+ 1, 34, :_reduce_22,
253
+ 2, 35, :_reduce_23,
254
+ 0, 23, :_reduce_24,
255
+ 1, 23, :_reduce_25,
256
+ 1, 36, :_reduce_26,
257
+ 2, 36, :_reduce_27,
258
+ 3, 37, :_reduce_28,
259
+ 3, 31, :_reduce_29,
260
+ 1, 38, :_reduce_none,
261
+ 1, 32, :_reduce_31,
262
+ 1, 39, :_reduce_none,
263
+ 1, 39, :_reduce_none,
264
+ 1, 39, :_reduce_none,
265
+ 2, 40, :_reduce_none,
266
+ 3, 40, :_reduce_none,
267
+ 1, 43, :_reduce_37,
268
+ 1, 44, :_reduce_38,
269
+ 3, 45, :_reduce_none,
270
+ 1, 45, :_reduce_none,
271
+ 3, 46, :_reduce_none,
272
+ 2, 41, :_reduce_none,
273
+ 3, 41, :_reduce_none,
274
+ 1, 48, :_reduce_44,
275
+ 1, 49, :_reduce_45,
276
+ 3, 50, :_reduce_none,
277
+ 1, 50, :_reduce_none,
278
+ 1, 42, :_reduce_none,
279
+ 1, 42, :_reduce_49,
280
+ 1, 47, :_reduce_50,
281
+ 1, 51, :_reduce_51,
282
+ 1, 51, :_reduce_52,
283
+ 1, 51, :_reduce_53,
284
+ 1, 51, :_reduce_54,
285
+ 1, 25, :_reduce_55 ]
286
+
287
+ racc_reduce_n = 56
288
+
289
+ racc_shift_n = 80
290
+
291
+ racc_token_table = {
292
+ false => 0,
293
+ :error => 1,
294
+ :STRING => 2,
295
+ :NUMBER => 3,
296
+ :TRUE => 4,
297
+ :FALSE => 5,
298
+ :NULL => 6,
299
+ :AS => 7,
300
+ :IDENT => 8,
301
+ "." => 9,
302
+ "(" => 10,
303
+ ")" => 11,
304
+ "," => 12,
305
+ "{" => 13,
306
+ "}" => 14,
307
+ "=" => 15,
308
+ "<" => 16,
309
+ ">" => 17,
310
+ ":" => 18,
311
+ "[" => 19,
312
+ "]" => 20 }
313
+
314
+ racc_nt_base = 21
315
+
316
+ racc_use_result_var = true
317
+
318
+ Racc_arg = [
319
+ racc_action_table,
320
+ racc_action_check,
321
+ racc_action_default,
322
+ racc_action_pointer,
323
+ racc_goto_table,
324
+ racc_goto_check,
325
+ racc_goto_default,
326
+ racc_goto_pointer,
327
+ racc_nt_base,
328
+ racc_reduce_table,
329
+ racc_token_table,
330
+ racc_shift_n,
331
+ racc_reduce_n,
332
+ racc_use_result_var ]
333
+
334
+ Racc_token_to_s_table = [
335
+ "$end",
336
+ "error",
337
+ "STRING",
338
+ "NUMBER",
339
+ "TRUE",
340
+ "FALSE",
341
+ "NULL",
342
+ "AS",
343
+ "IDENT",
344
+ "\".\"",
345
+ "\"(\"",
346
+ "\")\"",
347
+ "\",\"",
348
+ "\"{\"",
349
+ "\"}\"",
350
+ "\"=\"",
351
+ "\"<\"",
352
+ "\">\"",
353
+ "\":\"",
354
+ "\"[\"",
355
+ "\"]\"",
356
+ "$start",
357
+ "query",
358
+ "variables",
359
+ "call",
360
+ "identifier",
361
+ "arguments",
362
+ "fields",
363
+ "sub_call",
364
+ "argument_list",
365
+ "argument",
366
+ "variable_identifier",
367
+ "json_text",
368
+ "field_list",
369
+ "field",
370
+ "alias_identifier",
371
+ "variable_list",
372
+ "variable",
373
+ "variable_value",
374
+ "json_value",
375
+ "object",
376
+ "array",
377
+ "scalar",
378
+ "start_object",
379
+ "end_object",
380
+ "pairs",
381
+ "pair",
382
+ "string",
383
+ "start_array",
384
+ "end_array",
385
+ "values",
386
+ "literal" ]
387
+
388
+ Racc_debug_parser = false
389
+
390
+ ##### State transition tables end #####
391
+
392
+ # reduce 0 omitted
393
+
394
+ module_eval(<<'.,.,', 'parser.y', 4)
395
+ def _reduce_1(val, _values, result)
396
+ result = QueryNode.new(val[1], convert_variables(val[0], val[2]))
397
+ result
398
+ end
399
+ .,.,
400
+
401
+ module_eval(<<'.,.,', 'parser.y', 8)
402
+ def _reduce_2(val, _values, result)
403
+ result = CallNode.new(val[0], val[1], nil, val[2].presence)
404
+ result
405
+ end
406
+ .,.,
407
+
408
+ module_eval(<<'.,.,', 'parser.y', 9)
409
+ def _reduce_3(val, _values, result)
410
+ result = CallNode.new(val[0], val[1], val[2], nil)
411
+ result
412
+ end
413
+ .,.,
414
+
415
+ module_eval(<<'.,.,', 'parser.y', 10)
416
+ def _reduce_4(val, _values, result)
417
+ result = CallNode.new(val[0], val[1], nil, nil)
418
+ result
419
+ end
420
+ .,.,
421
+
422
+ module_eval(<<'.,.,', 'parser.y', 14)
423
+ def _reduce_5(val, _values, result)
424
+ result = val[1]
425
+ result
426
+ end
427
+ .,.,
428
+
429
+ module_eval(<<'.,.,', 'parser.y', 18)
430
+ def _reduce_6(val, _values, result)
431
+ result = []
432
+ result
433
+ end
434
+ .,.,
435
+
436
+ module_eval(<<'.,.,', 'parser.y', 19)
437
+ def _reduce_7(val, _values, result)
438
+ result = []
439
+ result
440
+ end
441
+ .,.,
442
+
443
+ module_eval(<<'.,.,', 'parser.y', 20)
444
+ def _reduce_8(val, _values, result)
445
+ result = val[1]
446
+ result
447
+ end
448
+ .,.,
449
+
450
+ module_eval(<<'.,.,', 'parser.y', 24)
451
+ def _reduce_9(val, _values, result)
452
+ result.push val[2]
453
+ result
454
+ end
455
+ .,.,
456
+
457
+ module_eval(<<'.,.,', 'parser.y', 25)
458
+ def _reduce_10(val, _values, result)
459
+ result = val
460
+ result
461
+ end
462
+ .,.,
463
+
464
+ # reduce 11 omitted
465
+
466
+ # reduce 12 omitted
467
+
468
+ module_eval(<<'.,.,', 'parser.y', 34)
469
+ def _reduce_13(val, _values, result)
470
+ result = []
471
+ result
472
+ end
473
+ .,.,
474
+
475
+ module_eval(<<'.,.,', 'parser.y', 35)
476
+ def _reduce_14(val, _values, result)
477
+ result = val[1]
478
+ result
479
+ end
480
+ .,.,
481
+
482
+ module_eval(<<'.,.,', 'parser.y', 39)
483
+ def _reduce_15(val, _values, result)
484
+ result.push val[2]
485
+ result
486
+ end
487
+ .,.,
488
+
489
+ module_eval(<<'.,.,', 'parser.y', 40)
490
+ def _reduce_16(val, _values, result)
491
+ result = val
492
+ result
493
+ end
494
+ .,.,
495
+
496
+ module_eval(<<'.,.,', 'parser.y', 44)
497
+ def _reduce_17(val, _values, result)
498
+ result = FieldNode.new(val[0], val[2], nil, val[1].presence)
499
+ result
500
+ end
501
+ .,.,
502
+
503
+ module_eval(<<'.,.,', 'parser.y', 45)
504
+ def _reduce_18(val, _values, result)
505
+ result = FieldNode.new(val[0], val[2], val[1], nil)
506
+ result
507
+ end
508
+ .,.,
509
+
510
+ module_eval(<<'.,.,', 'parser.y', 46)
511
+ def _reduce_19(val, _values, result)
512
+ result = FieldNode.new(val[0], val[1], nil, nil)
513
+ result
514
+ end
515
+ .,.,
516
+
517
+ module_eval(<<'.,.,', 'parser.y', 47)
518
+ def _reduce_20(val, _values, result)
519
+ result = FieldNode.new(val[0], nil, nil, val[1].presence)
520
+ result
521
+ end
522
+ .,.,
523
+
524
+ module_eval(<<'.,.,', 'parser.y', 48)
525
+ def _reduce_21(val, _values, result)
526
+ result = FieldNode.new(val[0], nil, val[1], nil)
527
+ result
528
+ end
529
+ .,.,
530
+
531
+ module_eval(<<'.,.,', 'parser.y', 49)
532
+ def _reduce_22(val, _values, result)
533
+ result = FieldNode.new(val[0], nil, nil, nil)
534
+ result
535
+ end
536
+ .,.,
537
+
538
+ module_eval(<<'.,.,', 'parser.y', 53)
539
+ def _reduce_23(val, _values, result)
540
+ result = val[1]
541
+ result
542
+ end
543
+ .,.,
544
+
545
+ module_eval(<<'.,.,', 'parser.y', 57)
546
+ def _reduce_24(val, _values, result)
547
+ result = []
548
+ result
549
+ end
550
+ .,.,
551
+
552
+ module_eval(<<'.,.,', 'parser.y', 58)
553
+ def _reduce_25(val, _values, result)
554
+ result = val[0]
555
+ result
556
+ end
557
+ .,.,
558
+
559
+ module_eval(<<'.,.,', 'parser.y', 62)
560
+ def _reduce_26(val, _values, result)
561
+ result = val
562
+ result
563
+ end
564
+ .,.,
565
+
566
+ module_eval(<<'.,.,', 'parser.y', 63)
567
+ def _reduce_27(val, _values, result)
568
+ result.push val[1]
569
+ result
570
+ end
571
+ .,.,
572
+
573
+ module_eval(<<'.,.,', 'parser.y', 67)
574
+ def _reduce_28(val, _values, result)
575
+ result = [val[0], val[2]]
576
+ result
577
+ end
578
+ .,.,
579
+
580
+ module_eval(<<'.,.,', 'parser.y', 71)
581
+ def _reduce_29(val, _values, result)
582
+ result = val[1]
583
+ result
584
+ end
585
+ .,.,
586
+
587
+ # reduce 30 omitted
588
+
589
+ module_eval(<<'.,.,', 'parser.y', 79)
590
+ def _reduce_31(val, _values, result)
591
+ result = @json.result
592
+ result
593
+ end
594
+ .,.,
595
+
596
+ # reduce 32 omitted
597
+
598
+ # reduce 33 omitted
599
+
600
+ # reduce 34 omitted
601
+
602
+ # reduce 35 omitted
603
+
604
+ # reduce 36 omitted
605
+
606
+ module_eval(<<'.,.,', 'parser.y', 92)
607
+ def _reduce_37(val, _values, result)
608
+ @json.start_object
609
+ result
610
+ end
611
+ .,.,
612
+
613
+ module_eval(<<'.,.,', 'parser.y', 93)
614
+ def _reduce_38(val, _values, result)
615
+ @json.end_object
616
+ result
617
+ end
618
+ .,.,
619
+
620
+ # reduce 39 omitted
621
+
622
+ # reduce 40 omitted
623
+
624
+ # reduce 41 omitted
625
+
626
+ # reduce 42 omitted
627
+
628
+ # reduce 43 omitted
629
+
630
+ module_eval(<<'.,.,', 'parser.y', 109)
631
+ def _reduce_44(val, _values, result)
632
+ @json.start_array
633
+ result
634
+ end
635
+ .,.,
636
+
637
+ module_eval(<<'.,.,', 'parser.y', 110)
638
+ def _reduce_45(val, _values, result)
639
+ @json.end_array
640
+ result
641
+ end
642
+ .,.,
643
+
644
+ # reduce 46 omitted
645
+
646
+ # reduce 47 omitted
647
+
648
+ # reduce 48 omitted
649
+
650
+ module_eval(<<'.,.,', 'parser.y', 119)
651
+ def _reduce_49(val, _values, result)
652
+ @json.scalar val[0]
653
+ result
654
+ end
655
+ .,.,
656
+
657
+ module_eval(<<'.,.,', 'parser.y', 123)
658
+ def _reduce_50(val, _values, result)
659
+ @json.scalar unescape_string(val[0])
660
+ result
661
+ end
662
+ .,.,
663
+
664
+ module_eval(<<'.,.,', 'parser.y', 127)
665
+ def _reduce_51(val, _values, result)
666
+ result = convert_number(val[0])
667
+ result
668
+ end
669
+ .,.,
670
+
671
+ module_eval(<<'.,.,', 'parser.y', 128)
672
+ def _reduce_52(val, _values, result)
673
+ result = true
674
+ result
675
+ end
676
+ .,.,
677
+
678
+ module_eval(<<'.,.,', 'parser.y', 129)
679
+ def _reduce_53(val, _values, result)
680
+ result = false
681
+ result
682
+ end
683
+ .,.,
684
+
685
+ module_eval(<<'.,.,', 'parser.y', 130)
686
+ def _reduce_54(val, _values, result)
687
+ result = nil
688
+ result
689
+ end
690
+ .,.,
691
+
692
+ module_eval(<<'.,.,', 'parser.y', 134)
693
+ def _reduce_55(val, _values, result)
694
+ result = val[0].to_sym
695
+ result
696
+ end
697
+ .,.,
698
+
699
+ def _reduce_none(val, _values, result)
700
+ val[0]
701
+ end
702
+
703
+ end # class Parser
704
+ end # module GQL