synvert-core 1.1.1 → 1.3.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/Gemfile +9 -0
- data/lib/synvert/core/array_ext.rb +9 -2
- data/lib/synvert/core/node_ext.rb +14 -2
- data/lib/synvert/core/node_query/compiler/array.rb +1 -1
- data/lib/synvert/core/node_query/compiler/attribute.rb +6 -18
- data/lib/synvert/core/node_query/compiler/comparable.rb +26 -19
- data/lib/synvert/core/node_query/compiler/expression.rb +22 -52
- data/lib/synvert/core/node_query/compiler/identifier.rb +1 -1
- data/lib/synvert/core/node_query/compiler/regexp.rb +2 -2
- data/lib/synvert/core/node_query/compiler/selector.rb +116 -31
- data/lib/synvert/core/node_query/compiler/simple_selector.rb +29 -0
- data/lib/synvert/core/node_query/compiler/string.rb +1 -1
- data/lib/synvert/core/node_query/compiler.rb +1 -0
- data/lib/synvert/core/node_query/lexer.rex +27 -17
- data/lib/synvert/core/node_query/lexer.rex.rb +53 -29
- data/lib/synvert/core/node_query/parser.racc.rb +119 -315
- data/lib/synvert/core/node_query/parser.y +20 -42
- data/lib/synvert/core/node_query.rb +7 -7
- data/lib/synvert/core/version.rb +1 -1
- data/spec/synvert/core/node_ext_spec.rb +7 -5
- data/spec/synvert/core/node_query/lexer_spec.rb +76 -50
- data/spec/synvert/core/node_query/parser_spec.rb +181 -114
- data/spec/synvert/core/rewriter/instance_spec.rb +3 -3
- data/spec/synvert/core/rewriter/scope/query_scope_spec.rb +3 -3
- data/synvert-core-ruby.gemspec +0 -10
- metadata +3 -128
@@ -25,179 +25,88 @@ module Synvert
|
|
25
25
|
##### State transition tables begin ###
|
26
26
|
|
27
27
|
racc_action_table = [
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
55, 56, 57, 58, nil, 52, 53, 54, 55, 56,
|
38
|
-
57, 58, nil, 52, 53, 54, 55, 56, 57, 58,
|
39
|
-
6, nil, nil, nil, 59, nil, nil, nil, 6, nil,
|
40
|
-
nil, 8, 59, 51, nil, nil, 6, nil, nil, 8,
|
41
|
-
59, 51, nil, 67, nil, nil, nil, 8, nil, 51,
|
42
|
-
nil, nil, 52, 53, 54, 55, 56, 57, 58, nil,
|
43
|
-
52, 53, 54, 55, 56, 57, 58, nil, 52, 53,
|
44
|
-
54, 55, 56, 57, 58, 6, nil, nil, nil, 59,
|
45
|
-
nil, nil, nil, 6, nil, nil, 8, 59, 51, nil,
|
46
|
-
nil, 74, 6, nil, 8, nil, 51, nil, nil, 78,
|
47
|
-
3, 4, 5, 8, nil, nil, nil, 52, 53, 54,
|
48
|
-
55, 56, 57, 58, nil, 52, 53, 54, 55, 56,
|
49
|
-
57, 58, 6, nil, nil, nil, 59, nil, nil, nil,
|
50
|
-
6, nil, nil, 8, 59, 51, nil, nil, 80, 6,
|
51
|
-
6, 8, nil, 51, 59, nil, 82, 3, 4, 5,
|
52
|
-
8, 8, nil, 51, 52, 53, 54, 55, 56, 57,
|
53
|
-
58, nil, 52, 53, 54, 55, 56, 57, 58, nil,
|
54
|
-
nil, 6, 52, 53, 54, 55, 56, 57, 58, 3,
|
55
|
-
4, 5, 8, 6, nil, nil, nil, 6, nil, nil,
|
56
|
-
nil, 3, 4, 5, 8, 3, 4, 5, 8, 6,
|
57
|
-
nil, nil, nil, 6, nil, nil, nil, 3, 4, 5,
|
58
|
-
8, 3, 4, 5, 8, 6, nil, nil, nil, 6,
|
59
|
-
nil, nil, nil, 3, 4, 5, 8, 3, 4, 5,
|
60
|
-
8, 40, 33, 35, 34, 37, 36, 39, 38, 43,
|
61
|
-
42, 41 ]
|
28
|
+
7, 8, 7, 12, 41, 10, 11, 7, 4, 5,
|
29
|
+
33, 41, 31, 14, 16, 17, 18, 33, 6, 20,
|
30
|
+
42, 34, 35, 36, 37, 38, 39, 40, 34, 35,
|
31
|
+
36, 37, 38, 39, 40, 7, 7, 22, 24, 41,
|
32
|
+
26, 27, 4, 5, 28, 33, 16, 7, 45, 46,
|
33
|
+
48, nil, 6, 4, 5, nil, 34, 35, 36, 37,
|
34
|
+
38, 39, 40, 6, 7, nil, 7, nil, 7, nil,
|
35
|
+
4, 5, 4, 5, 4, 5, nil, nil, nil, nil,
|
36
|
+
6, nil, 6, nil, 6 ]
|
62
37
|
|
63
38
|
racc_action_check = [
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
36, 36, 36, 36, nil, 37, 37, 37, 37, 37,
|
74
|
-
37, 37, nil, 38, 38, 38, 38, 38, 38, 38,
|
75
|
-
39, nil, nil, nil, 39, nil, nil, nil, 40, nil,
|
76
|
-
nil, 39, 40, 39, nil, nil, 41, nil, nil, 40,
|
77
|
-
41, 40, nil, 40, nil, nil, nil, 41, nil, 41,
|
78
|
-
nil, nil, 39, 39, 39, 39, 39, 39, 39, nil,
|
79
|
-
40, 40, 40, 40, 40, 40, 40, nil, 41, 41,
|
80
|
-
41, 41, 41, 41, 41, 49, nil, nil, nil, 49,
|
81
|
-
nil, nil, nil, 67, nil, nil, 49, 67, 49, nil,
|
82
|
-
nil, 49, 3, nil, 67, nil, 67, nil, nil, 67,
|
83
|
-
3, 3, 3, 3, nil, nil, nil, 49, 49, 49,
|
84
|
-
49, 49, 49, 49, nil, 67, 67, 67, 67, 67,
|
85
|
-
67, 67, 69, nil, nil, nil, 69, nil, nil, nil,
|
86
|
-
70, nil, nil, 69, 70, 69, nil, nil, 69, 4,
|
87
|
-
86, 70, nil, 70, 86, nil, 70, 4, 4, 4,
|
88
|
-
4, 86, nil, 86, 69, 69, 69, 69, 69, 69,
|
89
|
-
69, nil, 70, 70, 70, 70, 70, 70, 70, nil,
|
90
|
-
nil, 5, 86, 86, 86, 86, 86, 86, 86, 5,
|
91
|
-
5, 5, 5, 10, nil, nil, nil, 11, nil, nil,
|
92
|
-
nil, 10, 10, 10, 10, 11, 11, 11, 11, 12,
|
93
|
-
nil, nil, nil, 30, nil, nil, nil, 12, 12, 12,
|
94
|
-
12, 30, 30, 30, 30, 31, nil, nil, nil, 44,
|
95
|
-
nil, nil, nil, 31, 31, 31, 31, 44, 44, 44,
|
96
|
-
44, 23, 23, 23, 23, 23, 23, 23, 23, 23,
|
97
|
-
23, 23 ]
|
39
|
+
27, 1, 0, 4, 27, 3, 3, 31, 0, 0,
|
40
|
+
27, 31, 27, 6, 7, 8, 11, 31, 0, 14,
|
41
|
+
31, 27, 27, 27, 27, 27, 27, 27, 31, 31,
|
42
|
+
31, 31, 31, 31, 31, 44, 2, 16, 19, 44,
|
43
|
+
21, 22, 2, 2, 23, 44, 26, 5, 33, 43,
|
44
|
+
45, nil, 2, 5, 5, nil, 44, 44, 44, 44,
|
45
|
+
44, 44, 44, 5, 12, nil, 18, nil, 20, nil,
|
46
|
+
12, 12, 18, 18, 20, 20, nil, nil, nil, nil,
|
47
|
+
12, nil, 18, nil, 20 ]
|
98
48
|
|
99
49
|
racc_action_pointer = [
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
nil, 27, nil, nil, nil, nil, nil, nil, nil, nil,
|
106
|
-
nil, nil, nil, nil, nil, nil, nil, 171, nil, 210,
|
107
|
-
218, 41, nil, nil, nil, 44, 55, 49, nil, 52,
|
108
|
-
nil, 54, nil, 55, nil, nil, 228, nil, nil, nil,
|
109
|
-
nil, nil ]
|
50
|
+
0, 1, 34, -2, -13, 45, 8, 4, 15, nil,
|
51
|
+
nil, 0, 62, nil, 0, nil, 33, nil, 64, 21,
|
52
|
+
66, 29, 21, 27, nil, nil, 36, -2, nil, nil,
|
53
|
+
nil, 5, nil, 26, nil, nil, nil, nil, nil, nil,
|
54
|
+
nil, nil, nil, 34, 33, 37, nil, nil, nil ]
|
110
55
|
|
111
56
|
racc_action_default = [
|
112
|
-
-
|
113
|
-
|
114
|
-
-
|
115
|
-
-
|
116
|
-
-
|
117
|
-
-39, -49, -41, -42, -43, -44, -45, -46, -47, -48,
|
118
|
-
-21, -22, -23, -24, -25, -26, -27, -49, -28, -49,
|
119
|
-
-49, -49, -13, -14, -29, -49, -38, -49, -30, -49,
|
120
|
-
-31, -49, -32, -49, -12, -33, -49, -40, -34, -35,
|
121
|
-
-36, -37 ]
|
57
|
+
-28, -28, -2, -3, -28, -28, -28, -9, -28, -1,
|
58
|
+
-4, -28, -28, -7, -28, -10, -28, 49, -28, -28,
|
59
|
+
-28, -28, -28, -28, -6, -8, -12, -28, -5, -11,
|
60
|
+
-13, -28, -18, -28, -20, -21, -22, -23, -24, -25,
|
61
|
+
-26, -27, -14, -28, -17, -28, -15, -16, -19 ]
|
122
62
|
|
123
63
|
racc_goto_table = [
|
124
|
-
|
125
|
-
|
126
|
-
2, nil, nil, nil, nil, 2, 2, 2, nil, nil,
|
127
|
-
45, 46, 79, 47, 81, 83, nil, nil, nil, nil,
|
128
|
-
nil, nil, nil, nil, 71, 2, 2, nil, nil, nil,
|
129
|
-
nil, 91, nil, nil, nil, nil, nil, nil, nil, 2,
|
130
|
-
48, 60, 61, 62, 63, 64, 65, 66, 68 ]
|
64
|
+
15, 32, 13, 43, 1, 32, 9, 21, 30, 19,
|
65
|
+
nil, nil, nil, nil, nil, 23, 47, 25, 32, 29 ]
|
131
66
|
|
132
67
|
racc_goto_check = [
|
133
|
-
|
134
|
-
|
135
|
-
2, nil, nil, nil, nil, 2, 2, 2, nil, nil,
|
136
|
-
1, 1, 6, 3, 6, 6, nil, nil, nil, nil,
|
137
|
-
nil, nil, nil, nil, 1, 2, 2, nil, nil, nil,
|
138
|
-
nil, 6, nil, nil, nil, nil, nil, nil, nil, 2,
|
139
|
-
5, 5, 5, 5, 5, 5, 5, 5, 5 ]
|
68
|
+
4, 3, 2, 7, 1, 3, 1, 5, 6, 2,
|
69
|
+
nil, nil, nil, nil, nil, 2, 7, 2, 3, 4 ]
|
140
70
|
|
141
71
|
racc_goto_pointer = [
|
142
|
-
nil,
|
72
|
+
nil, 4, -3, -26, -7, -9, -19, -28 ]
|
143
73
|
|
144
74
|
racc_goto_default = [
|
145
|
-
nil, nil,
|
75
|
+
nil, nil, 2, 3, nil, nil, 44, nil ]
|
146
76
|
|
147
77
|
racc_reduce_table = [
|
148
78
|
0, 0, :racc_error,
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
2,
|
153
|
-
|
154
|
-
|
155
|
-
2,
|
156
|
-
|
157
|
-
|
158
|
-
2,
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
1,
|
166
|
-
|
167
|
-
3,
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
4, 45, :_reduce_32,
|
181
|
-
5, 45, :_reduce_33,
|
182
|
-
5, 45, :_reduce_34,
|
183
|
-
5, 45, :_reduce_35,
|
184
|
-
5, 45, :_reduce_36,
|
185
|
-
3, 47, :_reduce_37,
|
186
|
-
1, 47, :_reduce_38,
|
187
|
-
1, 46, :_reduce_none,
|
188
|
-
3, 46, :_reduce_40,
|
189
|
-
1, 46, :_reduce_41,
|
190
|
-
1, 46, :_reduce_42,
|
191
|
-
1, 46, :_reduce_43,
|
192
|
-
1, 46, :_reduce_44,
|
193
|
-
1, 46, :_reduce_45,
|
194
|
-
1, 46, :_reduce_46,
|
195
|
-
1, 46, :_reduce_47,
|
196
|
-
1, 46, :_reduce_48 ]
|
197
|
-
|
198
|
-
racc_reduce_n = 49
|
199
|
-
|
200
|
-
racc_shift_n = 92
|
79
|
+
2, 31, :_reduce_1,
|
80
|
+
1, 31, :_reduce_2,
|
81
|
+
1, 32, :_reduce_3,
|
82
|
+
2, 32, :_reduce_4,
|
83
|
+
5, 32, :_reduce_5,
|
84
|
+
4, 32, :_reduce_6,
|
85
|
+
2, 32, :_reduce_7,
|
86
|
+
4, 32, :_reduce_8,
|
87
|
+
1, 33, :_reduce_9,
|
88
|
+
2, 33, :_reduce_10,
|
89
|
+
4, 34, :_reduce_11,
|
90
|
+
3, 34, :_reduce_12,
|
91
|
+
3, 35, :_reduce_13,
|
92
|
+
4, 35, :_reduce_14,
|
93
|
+
5, 35, :_reduce_15,
|
94
|
+
2, 37, :_reduce_16,
|
95
|
+
1, 37, :_reduce_17,
|
96
|
+
1, 36, :_reduce_none,
|
97
|
+
3, 36, :_reduce_19,
|
98
|
+
1, 36, :_reduce_20,
|
99
|
+
1, 36, :_reduce_21,
|
100
|
+
1, 36, :_reduce_22,
|
101
|
+
1, 36, :_reduce_23,
|
102
|
+
1, 36, :_reduce_24,
|
103
|
+
1, 36, :_reduce_25,
|
104
|
+
1, 36, :_reduce_26,
|
105
|
+
1, 36, :_reduce_27 ]
|
106
|
+
|
107
|
+
racc_reduce_n = 28
|
108
|
+
|
109
|
+
racc_shift_n = 49
|
201
110
|
|
202
111
|
racc_token_table = {
|
203
112
|
false => 0,
|
@@ -209,40 +118,29 @@ racc_token_table = {
|
|
209
118
|
:tIDENTIFIER_VALUE => 6,
|
210
119
|
:tINDEX => 7,
|
211
120
|
:tPSEUDO_CLASS => 8,
|
212
|
-
:
|
213
|
-
:
|
214
|
-
:
|
215
|
-
:
|
216
|
-
:
|
217
|
-
:
|
218
|
-
:
|
219
|
-
:
|
220
|
-
:
|
221
|
-
:
|
222
|
-
:
|
223
|
-
:
|
224
|
-
:
|
225
|
-
:
|
226
|
-
:
|
227
|
-
:
|
228
|
-
:
|
229
|
-
:
|
230
|
-
:
|
231
|
-
:
|
232
|
-
:
|
233
|
-
|
234
|
-
|
235
|
-
:tARRAY_VALUE => 32,
|
236
|
-
:tDYNAMIC_ATTRIBUTE => 33,
|
237
|
-
:tBOOLEAN => 34,
|
238
|
-
:tFLOAT => 35,
|
239
|
-
:tINTEGER => 36,
|
240
|
-
:tNIL => 37,
|
241
|
-
:tREGEXP => 38,
|
242
|
-
:tSTRING => 39,
|
243
|
-
:tSYMBOL => 40 }
|
244
|
-
|
245
|
-
racc_nt_base = 41
|
121
|
+
:tRELATIONSHIP => 9,
|
122
|
+
:tOPEN_ATTRIBUTE => 10,
|
123
|
+
:tCLOSE_ATTRIBUTE => 11,
|
124
|
+
:tOPEN_DYNAMIC_ATTRIBUTE => 12,
|
125
|
+
:tCLOSE_DYNAMIC_ATTRIBUTE => 13,
|
126
|
+
:tOPEN_ARRAY => 14,
|
127
|
+
:tCLOSE_ARRAY => 15,
|
128
|
+
:tOPEN_SELECTOR => 16,
|
129
|
+
:tCLOSE_SELECTOR => 17,
|
130
|
+
:tOPEN_GOTO_SCOPE => 18,
|
131
|
+
:tCLOSE_GOTO_SCOPE => 19,
|
132
|
+
:tOPERATOR => 20,
|
133
|
+
:tARRAY_VALUE => 21,
|
134
|
+
:tDYNAMIC_ATTRIBUTE => 22,
|
135
|
+
:tBOOLEAN => 23,
|
136
|
+
:tFLOAT => 24,
|
137
|
+
:tINTEGER => 25,
|
138
|
+
:tNIL => 26,
|
139
|
+
:tREGEXP => 27,
|
140
|
+
:tSTRING => 28,
|
141
|
+
:tSYMBOL => 29 }
|
142
|
+
|
143
|
+
racc_nt_base = 30
|
246
144
|
|
247
145
|
racc_use_result_var = false
|
248
146
|
|
@@ -272,10 +170,7 @@ Racc_token_to_s_table = [
|
|
272
170
|
"tIDENTIFIER_VALUE",
|
273
171
|
"tINDEX",
|
274
172
|
"tPSEUDO_CLASS",
|
275
|
-
"
|
276
|
-
"tCHILD",
|
277
|
-
"tSUBSEQUENT_SIBLING",
|
278
|
-
"tNEXT_SIBLING",
|
173
|
+
"tRELATIONSHIP",
|
279
174
|
"tOPEN_ATTRIBUTE",
|
280
175
|
"tCLOSE_ATTRIBUTE",
|
281
176
|
"tOPEN_DYNAMIC_ATTRIBUTE",
|
@@ -284,17 +179,9 @@ Racc_token_to_s_table = [
|
|
284
179
|
"tCLOSE_ARRAY",
|
285
180
|
"tOPEN_SELECTOR",
|
286
181
|
"tCLOSE_SELECTOR",
|
287
|
-
"
|
288
|
-
"
|
289
|
-
"
|
290
|
-
"tNOT_MATCH",
|
291
|
-
"tGREATER_THAN",
|
292
|
-
"tGREATER_THAN_OR_EQUAL",
|
293
|
-
"tLESS_THAN",
|
294
|
-
"tLESS_THAN_OR_EQUAL",
|
295
|
-
"tIN",
|
296
|
-
"tNOT_IN",
|
297
|
-
"tINCLUDES",
|
182
|
+
"tOPEN_GOTO_SCOPE",
|
183
|
+
"tCLOSE_GOTO_SCOPE",
|
184
|
+
"tOPERATOR",
|
298
185
|
"tARRAY_VALUE",
|
299
186
|
"tDYNAMIC_ATTRIBUTE",
|
300
187
|
"tBOOLEAN",
|
@@ -307,6 +194,7 @@ Racc_token_to_s_table = [
|
|
307
194
|
"$start",
|
308
195
|
"expression",
|
309
196
|
"selector",
|
197
|
+
"simple_selector",
|
310
198
|
"attribute_list",
|
311
199
|
"attribute",
|
312
200
|
"value",
|
@@ -319,192 +207,108 @@ Racc_debug_parser = false
|
|
319
207
|
# reduce 0 omitted
|
320
208
|
|
321
209
|
def _reduce_1(val, _values)
|
322
|
-
Compiler::Expression.new(selector: val[0], rest: val[
|
210
|
+
Compiler::Expression.new(selector: val[0], rest: val[1])
|
323
211
|
end
|
324
212
|
|
325
213
|
def _reduce_2(val, _values)
|
326
|
-
Compiler::Expression.new(selector: val[0]
|
214
|
+
Compiler::Expression.new(selector: val[0])
|
327
215
|
end
|
328
216
|
|
329
217
|
def _reduce_3(val, _values)
|
330
|
-
Compiler::
|
218
|
+
Compiler::Selector.new(simple_selector: val[0])
|
331
219
|
end
|
332
220
|
|
333
221
|
def _reduce_4(val, _values)
|
334
|
-
Compiler::
|
222
|
+
Compiler::Selector.new(simple_selector: val[0], index: val[1])
|
335
223
|
end
|
336
224
|
|
337
225
|
def _reduce_5(val, _values)
|
338
|
-
Compiler::
|
226
|
+
Compiler::Selector.new(simple_selector: val[0], pseudo_class: val[1], pseudo_selector: val[3])
|
339
227
|
end
|
340
228
|
|
341
229
|
def _reduce_6(val, _values)
|
342
|
-
Compiler::
|
230
|
+
Compiler::Selector.new(pseudo_class: val[0], pseudo_selector: val[2])
|
343
231
|
end
|
344
232
|
|
345
233
|
def _reduce_7(val, _values)
|
346
|
-
Compiler::
|
234
|
+
Compiler::Selector.new(relationship: val[0], rest: val[1])
|
347
235
|
end
|
348
236
|
|
349
237
|
def _reduce_8(val, _values)
|
350
|
-
Compiler::
|
238
|
+
Compiler::Selector.new(goto_scope: val[1], rest: val[3])
|
351
239
|
end
|
352
240
|
|
353
241
|
def _reduce_9(val, _values)
|
354
|
-
Compiler::
|
242
|
+
Compiler::SimpleSelector.new(node_type: val[0])
|
355
243
|
end
|
356
244
|
|
357
245
|
def _reduce_10(val, _values)
|
358
|
-
Compiler::
|
246
|
+
Compiler::SimpleSelector.new(node_type: val[0], attribute_list: val[1])
|
359
247
|
end
|
360
248
|
|
361
249
|
def _reduce_11(val, _values)
|
362
|
-
Compiler::
|
250
|
+
Compiler::AttributeList.new(attribute: val[1], rest: val[3])
|
363
251
|
end
|
364
252
|
|
365
253
|
def _reduce_12(val, _values)
|
366
|
-
Compiler::
|
254
|
+
Compiler::AttributeList.new(attribute: val[1])
|
367
255
|
end
|
368
256
|
|
369
257
|
def _reduce_13(val, _values)
|
370
|
-
Compiler::
|
258
|
+
Compiler::Attribute.new(key: val[0], value: val[2], operator: val[1])
|
371
259
|
end
|
372
260
|
|
373
261
|
def _reduce_14(val, _values)
|
374
|
-
Compiler::
|
262
|
+
Compiler::Attribute.new(key: val[0], value: Compiler::Array.new, operator: val[1])
|
375
263
|
end
|
376
264
|
|
377
265
|
def _reduce_15(val, _values)
|
378
|
-
Compiler::
|
266
|
+
Compiler::Attribute.new(key: val[0], value: val[3], operator: val[1])
|
379
267
|
end
|
380
268
|
|
381
269
|
def _reduce_16(val, _values)
|
382
|
-
Compiler::
|
270
|
+
Compiler::Array.new(value: val[0], rest: val[1])
|
383
271
|
end
|
384
272
|
|
385
273
|
def _reduce_17(val, _values)
|
386
|
-
Compiler::Selector.new(attribute_list: val[0])
|
387
|
-
end
|
388
|
-
|
389
|
-
def _reduce_18(val, _values)
|
390
|
-
Compiler::AttributeList.new(attribute: val[1], rest: val[3])
|
391
|
-
end
|
392
|
-
|
393
|
-
def _reduce_19(val, _values)
|
394
|
-
Compiler::AttributeList.new(attribute: val[1])
|
395
|
-
end
|
396
|
-
|
397
|
-
def _reduce_20(val, _values)
|
398
|
-
Compiler::Attribute.new(key: val[0], value: val[2], operator: :!=)
|
399
|
-
end
|
400
|
-
|
401
|
-
def _reduce_21(val, _values)
|
402
|
-
Compiler::Attribute.new(key: val[0], value: val[2], operator: :!~)
|
403
|
-
end
|
404
|
-
|
405
|
-
def _reduce_22(val, _values)
|
406
|
-
Compiler::Attribute.new(key: val[0], value: val[2], operator: :=~)
|
407
|
-
end
|
408
|
-
|
409
|
-
def _reduce_23(val, _values)
|
410
|
-
Compiler::Attribute.new(key: val[0], value: val[2], operator: :>=)
|
411
|
-
end
|
412
|
-
|
413
|
-
def _reduce_24(val, _values)
|
414
|
-
Compiler::Attribute.new(key: val[0], value: val[2], operator: :>)
|
415
|
-
end
|
416
|
-
|
417
|
-
def _reduce_25(val, _values)
|
418
|
-
Compiler::Attribute.new(key: val[0], value: val[2], operator: :<=)
|
419
|
-
end
|
420
|
-
|
421
|
-
def _reduce_26(val, _values)
|
422
|
-
Compiler::Attribute.new(key: val[0], value: val[2], operator: :<)
|
423
|
-
end
|
424
|
-
|
425
|
-
def _reduce_27(val, _values)
|
426
|
-
Compiler::Attribute.new(key: val[0], value: val[2], operator: :==)
|
427
|
-
end
|
428
|
-
|
429
|
-
def _reduce_28(val, _values)
|
430
|
-
Compiler::Attribute.new(key: val[0], value: val[2], operator: :includes)
|
431
|
-
end
|
432
|
-
|
433
|
-
def _reduce_29(val, _values)
|
434
|
-
Compiler::Attribute.new(key: val[0], value: Compiler::Array.new, operator: :!=)
|
435
|
-
end
|
436
|
-
|
437
|
-
def _reduce_30(val, _values)
|
438
|
-
Compiler::Attribute.new(key: val[0], value: Compiler::Array.new, operator: :==)
|
439
|
-
end
|
440
|
-
|
441
|
-
def _reduce_31(val, _values)
|
442
|
-
Compiler::Attribute.new(key: val[0], value: Compiler::Array.new, operator: :not_in)
|
443
|
-
end
|
444
|
-
|
445
|
-
def _reduce_32(val, _values)
|
446
|
-
Compiler::Attribute.new(key: val[0], value: Compiler::Array.new, operator: :in)
|
447
|
-
end
|
448
|
-
|
449
|
-
def _reduce_33(val, _values)
|
450
|
-
Compiler::Attribute.new(key: val[0], value: val[3], operator: :!=)
|
451
|
-
end
|
452
|
-
|
453
|
-
def _reduce_34(val, _values)
|
454
|
-
Compiler::Attribute.new(key: val[0], value: val[3], operator: :==)
|
455
|
-
end
|
456
|
-
|
457
|
-
def _reduce_35(val, _values)
|
458
|
-
Compiler::Attribute.new(key: val[0], value: val[3], operator: :not_in)
|
459
|
-
end
|
460
|
-
|
461
|
-
def _reduce_36(val, _values)
|
462
|
-
Compiler::Attribute.new(key: val[0], value: val[3], operator: :in)
|
463
|
-
end
|
464
|
-
|
465
|
-
def _reduce_37(val, _values)
|
466
|
-
Compiler::Array.new(value: val[0], rest: val[2])
|
467
|
-
end
|
468
|
-
|
469
|
-
def _reduce_38(val, _values)
|
470
274
|
Compiler::Array.new(value: val[0])
|
471
275
|
end
|
472
276
|
|
473
|
-
# reduce
|
277
|
+
# reduce 18 omitted
|
474
278
|
|
475
|
-
def
|
279
|
+
def _reduce_19(val, _values)
|
476
280
|
Compiler::DynamicAttribute.new(value: val[1])
|
477
281
|
end
|
478
282
|
|
479
|
-
def
|
283
|
+
def _reduce_20(val, _values)
|
480
284
|
Compiler::Boolean.new(value: val[0])
|
481
285
|
end
|
482
286
|
|
483
|
-
def
|
287
|
+
def _reduce_21(val, _values)
|
484
288
|
Compiler::Float.new(value: val[0])
|
485
289
|
end
|
486
290
|
|
487
|
-
def
|
291
|
+
def _reduce_22(val, _values)
|
488
292
|
Compiler::Integer.new(value: val[0])
|
489
293
|
end
|
490
294
|
|
491
|
-
def
|
295
|
+
def _reduce_23(val, _values)
|
492
296
|
Compiler::Nil.new(value: val[0])
|
493
297
|
end
|
494
298
|
|
495
|
-
def
|
299
|
+
def _reduce_24(val, _values)
|
496
300
|
Compiler::Regexp.new(value: val[0])
|
497
301
|
end
|
498
302
|
|
499
|
-
def
|
303
|
+
def _reduce_25(val, _values)
|
500
304
|
Compiler::String.new(value: val[0])
|
501
305
|
end
|
502
306
|
|
503
|
-
def
|
307
|
+
def _reduce_26(val, _values)
|
504
308
|
Compiler::Symbol.new(value: val[0])
|
505
309
|
end
|
506
310
|
|
507
|
-
def
|
311
|
+
def _reduce_27(val, _values)
|
508
312
|
Compiler::Identifier.new(value: val[0])
|
509
313
|
end
|
510
314
|
|
@@ -1,63 +1,41 @@
|
|
1
1
|
class Synvert::Core::NodeQuery::Parser
|
2
2
|
options no_result_var
|
3
|
-
token tNODE_TYPE tATTRIBUTE tKEY tIDENTIFIER tIDENTIFIER_VALUE tINDEX tPSEUDO_CLASS
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
tARRAY_VALUE tDYNAMIC_ATTRIBUTE tBOOLEAN tFLOAT tINTEGER tNIL tREGEXP tSTRING tSYMBOL
|
3
|
+
token tNODE_TYPE tATTRIBUTE tKEY tIDENTIFIER tIDENTIFIER_VALUE tINDEX tPSEUDO_CLASS tRELATIONSHIP
|
4
|
+
tOPEN_ATTRIBUTE tCLOSE_ATTRIBUTE tOPEN_DYNAMIC_ATTRIBUTE tCLOSE_DYNAMIC_ATTRIBUTE
|
5
|
+
tOPEN_ARRAY tCLOSE_ARRAY tOPEN_SELECTOR tCLOSE_SELECTOR tOPEN_GOTO_SCOPE tCLOSE_GOTO_SCOPE
|
6
|
+
tOPERATOR tARRAY_VALUE tDYNAMIC_ATTRIBUTE tBOOLEAN tFLOAT tINTEGER tNIL tREGEXP tSTRING tSYMBOL
|
8
7
|
rule
|
9
8
|
expression
|
10
|
-
: selector
|
11
|
-
| selector tSUBSEQUENT_SIBLING expression { Compiler::Expression.new(selector: val[0], rest: val[2], relationship: :subsequent_sibling) }
|
12
|
-
| selector tNEXT_SIBLING expression { Compiler::Expression.new(selector: val[0], rest: val[2], relationship: :next_sibling) }
|
13
|
-
| selector expression { Compiler::Expression.new(selector: val[0], rest: val[1], relationship: :descendant) }
|
9
|
+
: selector expression { Compiler::Expression.new(selector: val[0], rest: val[1]) }
|
14
10
|
| selector { Compiler::Expression.new(selector: val[0]) }
|
15
|
-
| tCHILD expression { Compiler::Expression.new(rest: val[1], relationship: :child) }
|
16
|
-
| tSUBSEQUENT_SIBLING expression { Compiler::Expression.new(rest: val[1], relationship: :subsequent_sibling) }
|
17
|
-
| tNEXT_SIBLING expression { Compiler::Expression.new(rest: val[1], relationship: :next_sibling) }
|
18
11
|
|
19
12
|
selector
|
20
|
-
:
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
13
|
+
: simple_selector { Compiler::Selector.new(simple_selector: val[0]) }
|
14
|
+
| simple_selector tINDEX { Compiler::Selector.new(simple_selector: val[0], index: val[1]) }
|
15
|
+
| simple_selector tPSEUDO_CLASS tOPEN_SELECTOR selector tCLOSE_SELECTOR { Compiler::Selector.new(simple_selector: val[0], pseudo_class: val[1], pseudo_selector: val[3]) }
|
16
|
+
| tPSEUDO_CLASS tOPEN_SELECTOR selector tCLOSE_SELECTOR { Compiler::Selector.new(pseudo_class: val[0], pseudo_selector: val[2]) }
|
17
|
+
| tRELATIONSHIP selector { Compiler::Selector.new(relationship: val[0], rest: val[1]) }
|
18
|
+
| tOPEN_GOTO_SCOPE tIDENTIFIER tCLOSE_GOTO_SCOPE selector { Compiler::Selector.new(goto_scope: val[1], rest: val[3]) }
|
19
|
+
|
20
|
+
simple_selector
|
21
|
+
: tNODE_TYPE { Compiler::SimpleSelector.new(node_type: val[0]) }
|
22
|
+
| tNODE_TYPE attribute_list { Compiler::SimpleSelector.new(node_type: val[0], attribute_list: val[1]) }
|
30
23
|
|
31
24
|
attribute_list
|
32
25
|
: tOPEN_ATTRIBUTE attribute tCLOSE_ATTRIBUTE attribute_list { Compiler::AttributeList.new(attribute: val[1], rest: val[3]) }
|
33
26
|
| tOPEN_ATTRIBUTE attribute tCLOSE_ATTRIBUTE { Compiler::AttributeList.new(attribute: val[1]) }
|
34
|
-
;
|
35
27
|
|
36
28
|
attribute
|
37
|
-
: tKEY
|
38
|
-
| tKEY
|
39
|
-
| tKEY
|
40
|
-
| tKEY tGREATER_THAN_OR_EQUAL value { Compiler::Attribute.new(key: val[0], value: val[2], operator: :>=) }
|
41
|
-
| tKEY tGREATER_THAN value { Compiler::Attribute.new(key: val[0], value: val[2], operator: :>) }
|
42
|
-
| tKEY tLESS_THAN_OR_EQUAL value { Compiler::Attribute.new(key: val[0], value: val[2], operator: :<=) }
|
43
|
-
| tKEY tLESS_THAN value { Compiler::Attribute.new(key: val[0], value: val[2], operator: :<) }
|
44
|
-
| tKEY tEQUAL value { Compiler::Attribute.new(key: val[0], value: val[2], operator: :==) }
|
45
|
-
| tKEY tINCLUDES value { Compiler::Attribute.new(key: val[0], value: val[2], operator: :includes) }
|
46
|
-
| tKEY tNOT_EQUAL tOPEN_ARRAY tCLOSE_ARRAY { Compiler::Attribute.new(key: val[0], value: Compiler::Array.new, operator: :!=) }
|
47
|
-
| tKEY tEQUAL tOPEN_ARRAY tCLOSE_ARRAY { Compiler::Attribute.new(key: val[0], value: Compiler::Array.new, operator: :==) }
|
48
|
-
| tKEY tNOT_IN tOPEN_ARRAY tCLOSE_ARRAY { Compiler::Attribute.new(key: val[0], value: Compiler::Array.new, operator: :not_in) }
|
49
|
-
| tKEY tIN tOPEN_ARRAY tCLOSE_ARRAY { Compiler::Attribute.new(key: val[0], value: Compiler::Array.new, operator: :in) }
|
50
|
-
| tKEY tNOT_EQUAL tOPEN_ARRAY array_value tCLOSE_ARRAY { Compiler::Attribute.new(key: val[0], value: val[3], operator: :!=) }
|
51
|
-
| tKEY tEQUAL tOPEN_ARRAY array_value tCLOSE_ARRAY { Compiler::Attribute.new(key: val[0], value: val[3], operator: :==) }
|
52
|
-
| tKEY tNOT_IN tOPEN_ARRAY array_value tCLOSE_ARRAY { Compiler::Attribute.new(key: val[0], value: val[3], operator: :not_in) }
|
53
|
-
| tKEY tIN tOPEN_ARRAY array_value tCLOSE_ARRAY { Compiler::Attribute.new(key: val[0], value: val[3], operator: :in) }
|
29
|
+
: tKEY tOPERATOR value { Compiler::Attribute.new(key: val[0], value: val[2], operator: val[1]) }
|
30
|
+
| tKEY tOPERATOR tOPEN_ARRAY tCLOSE_ARRAY { Compiler::Attribute.new(key: val[0], value: Compiler::Array.new, operator: val[1]) }
|
31
|
+
| tKEY tOPERATOR tOPEN_ARRAY array_value tCLOSE_ARRAY { Compiler::Attribute.new(key: val[0], value: val[3], operator: val[1]) }
|
54
32
|
|
55
33
|
array_value
|
56
|
-
: value
|
34
|
+
: value array_value { Compiler::Array.new(value: val[0], rest: val[1]) }
|
57
35
|
| value { Compiler::Array.new(value: val[0]) }
|
58
36
|
|
59
37
|
value
|
60
|
-
:
|
38
|
+
: simple_selector
|
61
39
|
| tOPEN_DYNAMIC_ATTRIBUTE tDYNAMIC_ATTRIBUTE tCLOSE_DYNAMIC_ATTRIBUTE { Compiler::DynamicAttribute.new(value: val[1]) }
|
62
40
|
| tBOOLEAN { Compiler::Boolean.new(value: val[0]) }
|
63
41
|
| tFLOAT { Compiler::Float.new(value: val[0]) }
|