oga 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,828 @@
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
+ module Oga
9
+ module CSS
10
+ class Parser < Racc::Parser
11
+
12
+ ##
13
+ # @param [String] data The input to parse.
14
+ #
15
+ def initialize(data)
16
+ @lexer = Lexer.new(data)
17
+ end
18
+
19
+ ##
20
+ # Resets the internal state of the parser.
21
+ #
22
+ def reset
23
+ @current_element = nil
24
+ end
25
+
26
+ ##
27
+ # @param [Symbol] type
28
+ # @param [Array] children
29
+ # @return [AST::Node]
30
+ #
31
+ def s(type, *children)
32
+ return AST::Node.new(type, children)
33
+ end
34
+
35
+ ##
36
+ # Yields the next token from the lexer.
37
+ #
38
+ # @yieldparam [Array]
39
+ #
40
+ def yield_next_token
41
+ @lexer.advance do |*args|
42
+ yield args
43
+ end
44
+
45
+ yield [false, false]
46
+ end
47
+
48
+ ##
49
+ # Returns the node test for the current element.
50
+ #
51
+ # @return [AST::Node]
52
+ #
53
+ def current_element
54
+ return @current_element ||= s(:test, nil, '*')
55
+ end
56
+
57
+ ##
58
+ # Parses the input and returns the corresponding AST.
59
+ #
60
+ # @example
61
+ # parser = Oga::CSS::Parser.new('foo.bar')
62
+ # ast = parser.parse
63
+ #
64
+ # @return [AST::Node]
65
+ #
66
+ def parse
67
+ reset
68
+
69
+ ast = yyparse(self, :yield_next_token)
70
+
71
+ return ast
72
+ end
73
+
74
+ ##
75
+ # Generates the AST for a node test.
76
+ #
77
+ # @param [String] namespace
78
+ # @param [String] name
79
+ # @return [AST::Node]
80
+ #
81
+ def on_test(namespace, name)
82
+ @current_element = s(:test, namespace, name)
83
+
84
+ return @current_element
85
+ end
86
+
87
+ ##
88
+ # @param [String] name
89
+ # @param [AST::Node] arg
90
+ # @return [AST::Node]
91
+ #
92
+ def on_pseudo_class(name, arg = nil)
93
+ handler = "on_pseudo_class_#{name.gsub('-', '_')}"
94
+
95
+ return arg ? send(handler, arg) : send(handler)
96
+ end
97
+
98
+ ##
99
+ # Generates the AST for the `root` pseudo class.
100
+ #
101
+ # @return [AST::Node]
102
+ #
103
+ def on_pseudo_class_root
104
+ return s(:call, 'not', s(:axis, 'parent', s(:test, nil, '*')))
105
+ end
106
+
107
+ ##
108
+ # Generates the AST for the `nth-child` pseudo class.
109
+ #
110
+ # @param [AST::Node] arg
111
+ # @return [AST::Node]
112
+ #
113
+ def on_pseudo_class_nth_child(arg)
114
+ return generate_nth_child('preceding-sibling', arg)
115
+ end
116
+
117
+ ##
118
+ # Generates the AST for the `nth-last-child` pseudo class.
119
+ #
120
+ # @param [AST::Node] arg
121
+ # @return [AST::Node]
122
+ #
123
+ def on_pseudo_class_nth_last_child(arg)
124
+ return generate_nth_child('following-sibling', arg)
125
+ end
126
+
127
+ ##
128
+ # Generates the AST for the `nth-of-type` pseudo class.
129
+ #
130
+ # @param [AST::Node] arg
131
+ # @return [AST::Node]
132
+ #
133
+ def on_pseudo_class_nth_of_type(arg)
134
+ return generate_nth_child('preceding-sibling', arg, current_element)
135
+ end
136
+
137
+ ##
138
+ # Generates the AST for the `nth-last-of-type` pseudo class.
139
+ #
140
+ # @param [AST::Node] arg
141
+ # @return [AST::Node]
142
+ #
143
+ def on_pseudo_class_nth_last_of_type(arg)
144
+ return generate_nth_child('following-sibling', arg, current_element)
145
+ end
146
+
147
+ ##
148
+ # Generates the AST for the `:first-child` selector.
149
+ #
150
+ # @return [AST::Node]
151
+ #
152
+ def on_pseudo_class_first_child
153
+ return generate_no_siblings('preceding-sibling')
154
+ end
155
+
156
+ ##
157
+ # Generates the AST for the `:last-child` selector.
158
+ #
159
+ # @return [AST::Node]
160
+ #
161
+ def on_pseudo_class_last_child
162
+ return generate_no_siblings('following-sibling')
163
+ end
164
+
165
+ ##
166
+ # Generates the AST for the `:first-of-type` selector.
167
+ #
168
+ # @return [AST::Node]
169
+ #
170
+ def on_pseudo_class_first_of_type
171
+ return generate_no_siblings('preceding-sibling', current_element)
172
+ end
173
+
174
+ ##
175
+ # Generates the AST for the `:last-of-type` selector.
176
+ #
177
+ # @return [AST::Node]
178
+ #
179
+ def on_pseudo_class_last_of_type
180
+ return generate_no_siblings('following-sibling', current_element)
181
+ end
182
+
183
+ ##
184
+ # Generates the AST for the `:only-child` selector.
185
+ #
186
+ # @return [AST::Node]
187
+ #
188
+ def on_pseudo_class_only_child
189
+ return s(:and, on_pseudo_class_first_child, on_pseudo_class_last_child)
190
+ end
191
+
192
+ ##
193
+ # Generates the AST for the `:only-of-type` selector.
194
+ #
195
+ # @return [AST::Node]
196
+ #
197
+ def on_pseudo_class_only_of_type
198
+ return s(:and, on_pseudo_class_first_of_type, on_pseudo_class_last_of_type)
199
+ end
200
+
201
+ ##
202
+ # Generates the AST for the `:empty` selector.
203
+ #
204
+ # @return [AST::Node]
205
+ #
206
+ def on_pseudo_class_empty
207
+ return s(:call, 'not', s(:axis, 'child', s(:type_test, 'node')))
208
+ end
209
+
210
+ private
211
+
212
+ ##
213
+ # @param [String] count_axis
214
+ # @param [AST::Node] arg
215
+ # @param [AST::Node] count_test
216
+ # @return [AST::Node]
217
+ #
218
+ def generate_nth_child(count_axis, arg, count_test = s(:test, nil, '*'))
219
+ count_call = s(:call, 'count', s(:axis, count_axis, count_test))
220
+
221
+ # literal 2, 4, etc
222
+ if int_node?(arg)
223
+ node = s(:eq, count_call, s(:int, arg.children[0] - 1))
224
+ else
225
+ step, offset = *arg
226
+ before_count = s(:add, count_call, s(:int, 1))
227
+ compare = step_comparison(step)
228
+
229
+ # 2n+2, 2n-4, etc
230
+ if offset
231
+ mod_val = step_modulo_value(step)
232
+ node = s(
233
+ :and,
234
+ s(compare, before_count, offset),
235
+ s(:eq, s(:mod, s(:sub, before_count, offset), mod_val), s(:int, 0))
236
+ )
237
+
238
+ # 2n, n, -2n
239
+ else
240
+ node = s(:eq, s(:mod, before_count, step), s(:int, 0))
241
+ end
242
+ end
243
+
244
+ return node
245
+ end
246
+
247
+ ##
248
+ # @param [String] axis
249
+ # @param [AST::Node] test
250
+ # @return [AST::Node]
251
+ #
252
+ def generate_no_siblings(axis, test = s(:test, nil, '*'))
253
+ return s(:eq, s(:call, 'count', s(:axis, axis, test)), s(:int, 0))
254
+ end
255
+
256
+ ##
257
+ # @param [AST::Node] node
258
+ # @return [TrueClass|FalseClass]
259
+ #
260
+ def int_node?(node)
261
+ return node.type == :int
262
+ end
263
+
264
+ ##
265
+ # @param [AST::Node] node
266
+ # @return [TrueClass|FalseClass]
267
+ #
268
+ def non_positive_number?(node)
269
+ return node.children[0] <= 0
270
+ end
271
+
272
+ ##
273
+ # @param [AST::Node] node
274
+ # @return [Symbol]
275
+ #
276
+ def step_comparison(node)
277
+ return node.children[0] >= 0 ? :gte : :lte
278
+ end
279
+
280
+ ##
281
+ # @param [AST::Node] step
282
+ # @return [AST::Node]
283
+ #
284
+ def step_modulo_value(step)
285
+ # -2n
286
+ if step and non_positive_number?(step)
287
+ mod_val = s(:int, -step.children[0])
288
+
289
+ # 2n
290
+ elsif step
291
+ mod_val = step
292
+
293
+ else
294
+ mod_val = s(:int, 1)
295
+ end
296
+
297
+ return mod_val
298
+ end
299
+
300
+ # vim: set ft=racc:
301
+ ##### State transition tables begin ###
302
+
303
+ racc_action_table = [
304
+ 13, 41, 19, 43, 23, 13, 44, 45, 26, 25,
305
+ 13, 40, 19, 13, 23, 9, 10, 11, 64, 48,
306
+ 9, 10, 11, 20, 21, 9, 10, 11, 63, 62,
307
+ 49, 65, 66, 20, 21, 13, 35, 19, 13, 23,
308
+ 19, 24, 23, 19, 68, 23, 19, 68, 23, 68,
309
+ 9, 10, 11, 9, 10, 11, 68, 68, 20, 21,
310
+ 68, 20, 21, 13, 20, 21, 13, 20, 21, 19,
311
+ 74, 23, 19, 75, 23, 19, 62, 23, 9, 10,
312
+ 11, 9, 10, 11, 50, 51, 52, 53, 54, 55,
313
+ 20, 21, 77, 20, 21, 62, 20, 21, 62 ]
314
+
315
+ racc_action_check = [
316
+ 0, 21, 0, 22, 0, 11, 23, 24, 4, 3,
317
+ 43, 20, 43, 19, 43, 0, 0, 0, 43, 35,
318
+ 11, 11, 11, 0, 0, 43, 43, 43, 43, 43,
319
+ 36, 43, 43, 43, 43, 25, 13, 25, 26, 25,
320
+ 26, 1, 26, 5, 50, 5, 6, 51, 6, 52,
321
+ 25, 25, 25, 26, 26, 26, 53, 54, 25, 25,
322
+ 55, 26, 26, 10, 5, 5, 9, 6, 6, 7,
323
+ 56, 7, 28, 57, 28, 29, 63, 29, 10, 10,
324
+ 10, 9, 9, 9, 37, 37, 37, 37, 37, 37,
325
+ 7, 7, 64, 28, 28, 75, 29, 29, 77 ]
326
+
327
+ racc_action_pointer = [
328
+ -2, 41, nil, 2, 1, 39, 42, 65, nil, 64,
329
+ 61, 3, nil, 33, nil, nil, nil, nil, nil, 11,
330
+ 9, -1, -5, 4, 7, 33, 36, nil, 68, 71,
331
+ nil, nil, nil, nil, nil, 17, 25, 73, nil, nil,
332
+ nil, nil, nil, 8, nil, nil, nil, nil, nil, nil,
333
+ 22, 25, 27, 34, 35, 38, 61, 53, nil, nil,
334
+ nil, nil, nil, 55, 72, nil, nil, nil, nil, nil,
335
+ nil, nil, nil, nil, nil, 74, nil, 77, nil, nil ]
336
+
337
+ racc_action_default = [
338
+ -2, -59, -1, -3, -4, -7, -8, -10, -12, -16,
339
+ -16, -16, -19, -20, -23, -24, -25, -26, -27, -59,
340
+ -59, -59, -40, -59, -59, -59, -59, -22, -9, -11,
341
+ -13, -17, -18, -14, -15, -59, -59, -29, -30, -31,
342
+ -38, -39, -41, -59, -42, 80, -6, -5, -21, -28,
343
+ -59, -59, -59, -59, -59, -59, -59, -44, -45, -46,
344
+ -47, -48, -50, -51, -59, -57, -58, -32, -49, -33,
345
+ -34, -35, -36, -37, -43, -55, -52, -53, -56, -54 ]
346
+
347
+ racc_goto_table = [
348
+ 3, 57, 28, 29, 27, 67, 69, 70, 71, 72,
349
+ 73, 31, 31, 31, 32, 32, 32, 30, 33, 34,
350
+ 36, 76, 4, 39, 37, 46, 47, 27, 27, 38,
351
+ 1, 42, 56, 78, 2, 79, 58, 59, 60, nil,
352
+ nil, nil, nil, 61 ]
353
+
354
+ racc_goto_check = [
355
+ 3, 23, 5, 5, 11, 19, 19, 19, 19, 19,
356
+ 19, 8, 8, 8, 7, 7, 7, 9, 9, 9,
357
+ 16, 23, 4, 10, 17, 3, 3, 11, 11, 18,
358
+ 1, 21, 22, 23, 2, 23, 24, 25, 26, nil,
359
+ nil, nil, nil, 3 ]
360
+
361
+ racc_goto_pointer = [
362
+ nil, 30, 34, 0, 22, -4, nil, 5, 2, 8,
363
+ 4, -1, nil, nil, nil, nil, 1, 5, 10, -45,
364
+ nil, 9, -11, -42, -7, -6, -5 ]
365
+
366
+ racc_goto_default = [
367
+ nil, nil, nil, nil, nil, 5, 6, 7, 8, nil,
368
+ 12, 14, 15, 16, 17, 18, nil, nil, nil, nil,
369
+ 22, nil, nil, nil, nil, nil, nil ]
370
+
371
+ racc_reduce_table = [
372
+ 0, 0, :racc_error,
373
+ 1, 28, :_reduce_1,
374
+ 0, 28, :_reduce_2,
375
+ 1, 29, :_reduce_3,
376
+ 1, 29, :_reduce_4,
377
+ 3, 31, :_reduce_5,
378
+ 3, 31, :_reduce_6,
379
+ 1, 30, :_reduce_7,
380
+ 1, 30, :_reduce_none,
381
+ 2, 30, :_reduce_9,
382
+ 1, 30, :_reduce_none,
383
+ 2, 30, :_reduce_11,
384
+ 1, 33, :_reduce_12,
385
+ 2, 34, :_reduce_13,
386
+ 2, 34, :_reduce_14,
387
+ 2, 34, :_reduce_15,
388
+ 0, 36, :_reduce_none,
389
+ 1, 36, :_reduce_none,
390
+ 1, 36, :_reduce_none,
391
+ 1, 35, :_reduce_19,
392
+ 1, 37, :_reduce_20,
393
+ 3, 37, :_reduce_21,
394
+ 2, 32, :_reduce_22,
395
+ 1, 32, :_reduce_none,
396
+ 1, 38, :_reduce_none,
397
+ 1, 38, :_reduce_none,
398
+ 1, 38, :_reduce_none,
399
+ 1, 38, :_reduce_none,
400
+ 3, 42, :_reduce_28,
401
+ 1, 43, :_reduce_none,
402
+ 1, 43, :_reduce_none,
403
+ 1, 44, :_reduce_31,
404
+ 3, 45, :_reduce_32,
405
+ 3, 45, :_reduce_33,
406
+ 3, 45, :_reduce_34,
407
+ 3, 45, :_reduce_35,
408
+ 3, 45, :_reduce_36,
409
+ 3, 45, :_reduce_37,
410
+ 2, 39, :_reduce_38,
411
+ 2, 40, :_reduce_39,
412
+ 1, 41, :_reduce_40,
413
+ 2, 41, :_reduce_41,
414
+ 2, 47, :_reduce_42,
415
+ 3, 48, :_reduce_43,
416
+ 1, 49, :_reduce_none,
417
+ 1, 49, :_reduce_none,
418
+ 1, 49, :_reduce_none,
419
+ 1, 49, :_reduce_none,
420
+ 1, 49, :_reduce_none,
421
+ 1, 46, :_reduce_49,
422
+ 1, 50, :_reduce_50,
423
+ 1, 53, :_reduce_51,
424
+ 2, 53, :_reduce_52,
425
+ 2, 53, :_reduce_53,
426
+ 3, 53, :_reduce_54,
427
+ 2, 53, :_reduce_55,
428
+ 3, 53, :_reduce_56,
429
+ 1, 51, :_reduce_57,
430
+ 1, 52, :_reduce_58 ]
431
+
432
+ racc_reduce_n = 59
433
+
434
+ racc_shift_n = 80
435
+
436
+ racc_token_table = {
437
+ false => 0,
438
+ :error => 1,
439
+ :T_IDENT => 2,
440
+ :T_PIPE => 3,
441
+ :T_LBRACK => 4,
442
+ :T_RBRACK => 5,
443
+ :T_COLON => 6,
444
+ :T_SPACE => 7,
445
+ :T_LPAREN => 8,
446
+ :T_RPAREN => 9,
447
+ :T_MINUS => 10,
448
+ :T_EQ => 11,
449
+ :T_SPACE_IN => 12,
450
+ :T_STARTS_WITH => 13,
451
+ :T_ENDS_WITH => 14,
452
+ :T_IN => 15,
453
+ :T_HYPHEN_IN => 16,
454
+ :T_GREATER => 17,
455
+ :T_TILDE => 18,
456
+ :T_PLUS => 19,
457
+ :T_NTH => 20,
458
+ :T_INT => 21,
459
+ :T_STRING => 22,
460
+ :T_ODD => 23,
461
+ :T_EVEN => 24,
462
+ :T_DOT => 25,
463
+ :T_HASH => 26 }
464
+
465
+ racc_nt_base = 27
466
+
467
+ racc_use_result_var = false
468
+
469
+ Racc_arg = [
470
+ racc_action_table,
471
+ racc_action_check,
472
+ racc_action_default,
473
+ racc_action_pointer,
474
+ racc_goto_table,
475
+ racc_goto_check,
476
+ racc_goto_default,
477
+ racc_goto_pointer,
478
+ racc_nt_base,
479
+ racc_reduce_table,
480
+ racc_token_table,
481
+ racc_shift_n,
482
+ racc_reduce_n,
483
+ racc_use_result_var ]
484
+
485
+ Racc_token_to_s_table = [
486
+ "$end",
487
+ "error",
488
+ "T_IDENT",
489
+ "T_PIPE",
490
+ "T_LBRACK",
491
+ "T_RBRACK",
492
+ "T_COLON",
493
+ "T_SPACE",
494
+ "T_LPAREN",
495
+ "T_RPAREN",
496
+ "T_MINUS",
497
+ "T_EQ",
498
+ "T_SPACE_IN",
499
+ "T_STARTS_WITH",
500
+ "T_ENDS_WITH",
501
+ "T_IN",
502
+ "T_HYPHEN_IN",
503
+ "T_GREATER",
504
+ "T_TILDE",
505
+ "T_PLUS",
506
+ "T_NTH",
507
+ "T_INT",
508
+ "T_STRING",
509
+ "T_ODD",
510
+ "T_EVEN",
511
+ "T_DOT",
512
+ "T_HASH",
513
+ "$start",
514
+ "css",
515
+ "selectors",
516
+ "selector",
517
+ "selectors_",
518
+ "predicates",
519
+ "descendant_or_self",
520
+ "axis",
521
+ "node_test",
522
+ "axis_selector",
523
+ "node_name",
524
+ "predicate",
525
+ "class",
526
+ "id",
527
+ "pseudo_class",
528
+ "attribute_predicate",
529
+ "attribute_predicate_members",
530
+ "attribute",
531
+ "operator",
532
+ "string",
533
+ "pseudo_name",
534
+ "pseudo_args",
535
+ "pseudo_arg",
536
+ "integer",
537
+ "odd",
538
+ "even",
539
+ "nth" ]
540
+
541
+ Racc_debug_parser = false
542
+
543
+ ##### State transition tables end #####
544
+
545
+ # reduce 0 omitted
546
+
547
+ def _reduce_1(val, _values)
548
+ val[0]
549
+ end
550
+
551
+ def _reduce_2(val, _values)
552
+ nil
553
+ end
554
+
555
+ def _reduce_3(val, _values)
556
+ # a single "+ y" selector
557
+ if val[0].is_a?(Array)
558
+ return s(:path, *val[0])
559
+ else
560
+ return val[0]
561
+ end
562
+
563
+ end
564
+
565
+ def _reduce_4(val, _values)
566
+ s(:path, *val[0].flatten)
567
+ end
568
+
569
+ def _reduce_5(val, _values)
570
+ val[0] << val[2]
571
+ end
572
+
573
+ def _reduce_6(val, _values)
574
+ [val[0], val[2]]
575
+ end
576
+
577
+ def _reduce_7(val, _values)
578
+ s(:predicate, s(:axis, 'descendant', on_test(nil, '*')), val[0])
579
+
580
+ end
581
+
582
+ # reduce 8 omitted
583
+
584
+ def _reduce_9(val, _values)
585
+ s(:predicate, val[0], val[1])
586
+ end
587
+
588
+ # reduce 10 omitted
589
+
590
+ def _reduce_11(val, _values)
591
+ s(:predicate, val[0], val[1])
592
+ end
593
+
594
+ def _reduce_12(val, _values)
595
+ s(:axis, 'descendant', val[0])
596
+ end
597
+
598
+ def _reduce_13(val, _values)
599
+ s(:axis, 'child', val[1])
600
+
601
+ end
602
+
603
+ def _reduce_14(val, _values)
604
+ s(:axis, 'following-sibling', val[1])
605
+
606
+ end
607
+
608
+ def _reduce_15(val, _values)
609
+ [
610
+ s(
611
+ :predicate,
612
+ s(:axis, 'following-sibling', on_test(nil, '*')),
613
+ s(:int, 1)
614
+ ),
615
+ s(:axis, 'self', val[1])
616
+ ]
617
+
618
+ end
619
+
620
+ # reduce 16 omitted
621
+
622
+ # reduce 17 omitted
623
+
624
+ # reduce 18 omitted
625
+
626
+ def _reduce_19(val, _values)
627
+ on_test(*val[0])
628
+ end
629
+
630
+ def _reduce_20(val, _values)
631
+ [nil, val[0]]
632
+ end
633
+
634
+ def _reduce_21(val, _values)
635
+ [val[0], val[2]]
636
+ end
637
+
638
+ def _reduce_22(val, _values)
639
+ s(:and, val[0], val[1])
640
+ end
641
+
642
+ # reduce 23 omitted
643
+
644
+ # reduce 24 omitted
645
+
646
+ # reduce 25 omitted
647
+
648
+ # reduce 26 omitted
649
+
650
+ # reduce 27 omitted
651
+
652
+ def _reduce_28(val, _values)
653
+ val[1]
654
+ end
655
+
656
+ # reduce 29 omitted
657
+
658
+ # reduce 30 omitted
659
+
660
+ def _reduce_31(val, _values)
661
+ s(:axis, 'attribute', on_test(*val[0]))
662
+ end
663
+
664
+ def _reduce_32(val, _values)
665
+ s(:eq, val[0], val[2])
666
+
667
+ end
668
+
669
+ def _reduce_33(val, _values)
670
+ s(
671
+ :call,
672
+ 'contains',
673
+ s(:call, 'concat', s(:string, ' '), val[0], s(:string, ' ')),
674
+ s(:call, 'concat', s(:string, ' '), val[2], s(:string, ' '))
675
+ )
676
+
677
+ end
678
+
679
+ def _reduce_34(val, _values)
680
+ s(:call, 'starts-with', val[0], val[2])
681
+
682
+ end
683
+
684
+ def _reduce_35(val, _values)
685
+ s(
686
+ :eq,
687
+ s(
688
+ :call,
689
+ 'substring',
690
+ val[0],
691
+ s(
692
+ :add,
693
+ s(
694
+ :sub,
695
+ s(:call, 'string-length', val[0]),
696
+ s(:call, 'string-length', val[2])
697
+ ),
698
+ s(:int, 1)
699
+ ),
700
+ s(:call, 'string-length', val[2])
701
+ ),
702
+ val[2]
703
+ )
704
+
705
+ end
706
+
707
+ def _reduce_36(val, _values)
708
+ s(:call, 'contains', val[0], val[2])
709
+
710
+ end
711
+
712
+ def _reduce_37(val, _values)
713
+ s(
714
+ :or,
715
+ s(:eq, val[0], val[2]),
716
+ s(
717
+ :call,
718
+ 'starts-with',
719
+ val[0],
720
+ s(:call, 'concat', val[2], s(:string, '-'))
721
+ )
722
+ )
723
+
724
+ end
725
+
726
+ def _reduce_38(val, _values)
727
+ axis = s(:axis, 'attribute', s(:test, nil, 'class'))
728
+
729
+ s(
730
+ :call,
731
+ 'contains',
732
+ s(:call, 'concat', s(:string, ' '), axis, s(:string, ' ')),
733
+ s(:string, " #{val[1]} ")
734
+ )
735
+
736
+ end
737
+
738
+ def _reduce_39(val, _values)
739
+ s(
740
+ :eq,
741
+ s(:axis, 'attribute', s(:test, nil, 'id')),
742
+ s(:string, val[1])
743
+ )
744
+
745
+ end
746
+
747
+ def _reduce_40(val, _values)
748
+ on_pseudo_class(val[0])
749
+ end
750
+
751
+ def _reduce_41(val, _values)
752
+ on_pseudo_class(val[0], val[1])
753
+ end
754
+
755
+ def _reduce_42(val, _values)
756
+ val[1]
757
+ end
758
+
759
+ def _reduce_43(val, _values)
760
+ val[1]
761
+ end
762
+
763
+ # reduce 44 omitted
764
+
765
+ # reduce 45 omitted
766
+
767
+ # reduce 46 omitted
768
+
769
+ # reduce 47 omitted
770
+
771
+ # reduce 48 omitted
772
+
773
+ def _reduce_49(val, _values)
774
+ s(:string, val[0])
775
+ end
776
+
777
+ def _reduce_50(val, _values)
778
+ s(:int, val[0].to_i)
779
+ end
780
+
781
+ def _reduce_51(val, _values)
782
+ s(:nth, s(:int, 1))
783
+ end
784
+
785
+ def _reduce_52(val, _values)
786
+ s(:nth, s(:int, 1), val[1])
787
+ end
788
+
789
+ def _reduce_53(val, _values)
790
+ s(:nth, s(:int, 1))
791
+ end
792
+
793
+ def _reduce_54(val, _values)
794
+ s(:nth, s(:int, -1), val[2])
795
+ end
796
+
797
+ def _reduce_55(val, _values)
798
+ s(:nth, val[0])
799
+ end
800
+
801
+ def _reduce_56(val, _values)
802
+ a = val[0]
803
+ b = val[2]
804
+
805
+ # 2n-1 gets turned into 2n+1
806
+ if b.children[0] < 0
807
+ b = s(:int, a.children[0] - (b.children[0] % a.children[0]))
808
+ end
809
+
810
+ s(:nth, a, b)
811
+
812
+ end
813
+
814
+ def _reduce_57(val, _values)
815
+ s(:nth, s(:int, 2), s(:int, 1))
816
+ end
817
+
818
+ def _reduce_58(val, _values)
819
+ s(:nth, s(:int, 2))
820
+ end
821
+
822
+ def _reduce_none(val, _values)
823
+ val[0]
824
+ end
825
+
826
+ end # class Parser
827
+ end # module CSS
828
+ end # module Oga