synvert-core 1.2.0 → 1.2.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 +5 -0
- data/lib/synvert/core/node_ext.rb +14 -2
- data/lib/synvert/core/node_query/parser.racc.rb +141 -149
- data/lib/synvert/core/node_query/parser.y +0 -2
- 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/parser_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c530d34ca0e2db5d9a295cb0cb48c375d13760f09290624805d742328a49103
|
4
|
+
data.tar.gz: 87cc4ef7ab9116bac2cbed78b9f71ab8d4ffa30281554d10319527a9aab94573
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b864e1e350d3467fe12d2c5e26a5c5a0b685752e21802e3773edfbbb8fca8f7dec60fb545475a630a3f00c09359c66859b228cf7cb3d19aa6bf044df4848408
|
7
|
+
data.tar.gz: c8c5641b85080f03307fed835c05132488d140bb19b694c2b5b0958cb3d6377785ef1447c8b7fec59e7529f2ec610f6c78d72357b60f5fe4285d43d5071750fb
|
data/CHANGELOG.md
CHANGED
@@ -93,9 +93,21 @@ module Parser::AST
|
|
93
93
|
end
|
94
94
|
|
95
95
|
# Dyamically defined method
|
96
|
-
# caller, key, left_value, message, name, parent_class, parent_const, receivr, rgith_value and value.
|
96
|
+
# caller, key, left_value, message, name, pairs, parent_class, parent_const, receivr, rgith_value and value.
|
97
97
|
# based on const TYPE_CHILDREN.
|
98
|
-
%i[
|
98
|
+
%i[
|
99
|
+
caller
|
100
|
+
key
|
101
|
+
left_value
|
102
|
+
message
|
103
|
+
name
|
104
|
+
pairs
|
105
|
+
parent_class
|
106
|
+
parent_const
|
107
|
+
receiver
|
108
|
+
right_value
|
109
|
+
value
|
110
|
+
].each do |method_name|
|
99
111
|
define_method(method_name) do
|
100
112
|
index = TYPE_CHILDREN[type]&.index(method_name)
|
101
113
|
return children[index] if index
|
@@ -25,116 +25,118 @@ module Synvert
|
|
25
25
|
##### State transition tables begin ###
|
26
26
|
|
27
27
|
racc_action_table = [
|
28
|
-
8,
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
46, 47, 48, 49, 50,
|
33
|
-
47, 48, 49, 50,
|
34
|
-
|
35
|
-
8, nil, nil,
|
36
|
-
|
37
|
-
47, 48, 49, 50,
|
38
|
-
50,
|
39
|
-
8, nil, nil, nil,
|
40
|
-
|
41
|
-
nil,
|
42
|
-
nil, nil, nil, 46, 47, 48, 49, 50,
|
43
|
-
46, 47, 48, 49, 50,
|
44
|
-
|
45
|
-
nil, 8, nil, nil,
|
46
|
-
nil,
|
47
|
-
|
48
|
-
49, 50,
|
49
|
-
|
50
|
-
nil, nil,
|
51
|
-
|
52
|
-
3, 4,
|
53
|
-
5, 46, 47, 48, 49, 50,
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
nil, nil, 5,
|
59
|
-
2, 3, 4,
|
60
|
-
nil, 5,
|
61
|
-
|
28
|
+
8, 17, 9, 13, 51, 14, 18, 8, 19, 20,
|
29
|
+
22, 51, 43, 24, 41, 26, 8, 27, 18, 43,
|
30
|
+
51, 61, 62, 66, 73, 75, 76, 77, 43, 78,
|
31
|
+
nil, nil, nil, 44, 45, 46, 47, 48, 49, 50,
|
32
|
+
44, 45, 46, 47, 48, 49, 50, nil, nil, 44,
|
33
|
+
45, 46, 47, 48, 49, 50, 8, nil, nil, nil,
|
34
|
+
51, nil, nil, 8, nil, nil, nil, 51, 43, nil,
|
35
|
+
8, nil, nil, nil, 51, 43, nil, nil, nil, nil,
|
36
|
+
nil, nil, 43, nil, nil, nil, nil, nil, nil, 44,
|
37
|
+
45, 46, 47, 48, 49, 50, 44, 45, 46, 47,
|
38
|
+
48, 49, 50, 44, 45, 46, 47, 48, 49, 50,
|
39
|
+
8, nil, nil, nil, 51, nil, nil, 8, nil, nil,
|
40
|
+
nil, 51, 43, nil, 8, nil, nil, nil, 51, 43,
|
41
|
+
nil, 59, nil, nil, nil, nil, 43, nil, nil, nil,
|
42
|
+
nil, nil, nil, 44, 45, 46, 47, 48, 49, 50,
|
43
|
+
44, 45, 46, 47, 48, 49, 50, 44, 45, 46,
|
44
|
+
47, 48, 49, 50, 8, nil, nil, nil, 51, nil,
|
45
|
+
nil, 8, nil, nil, nil, 51, 43, nil, 8, 63,
|
46
|
+
nil, nil, 51, 43, nil, nil, 67, nil, nil, nil,
|
47
|
+
43, nil, nil, 69, nil, nil, nil, 44, 45, 46,
|
48
|
+
47, 48, 49, 50, 44, 45, 46, 47, 48, 49,
|
49
|
+
50, 44, 45, 46, 47, 48, 49, 50, 8, nil,
|
50
|
+
nil, nil, 51, nil, nil, 8, nil, nil, nil, 51,
|
51
|
+
43, nil, 8, 71, nil, nil, nil, 43, 6, 2,
|
52
|
+
3, 4, nil, nil, nil, nil, nil, nil, nil, nil,
|
53
|
+
5, 44, 45, 46, 47, 48, 49, 50, 44, 45,
|
54
|
+
46, 47, 48, 49, 50, 8, nil, nil, nil, 8,
|
55
|
+
nil, 6, 2, 3, 4, 6, 2, 3, 4, nil,
|
56
|
+
nil, nil, 8, 5, nil, nil, 8, 5, 6, 2,
|
57
|
+
3, 4, 6, 2, 3, 4, nil, nil, nil, 8,
|
58
|
+
5, nil, nil, 8, 5, 6, 2, 3, 4, 6,
|
59
|
+
2, 3, 4, nil, nil, nil, nil, 5, nil, nil,
|
60
|
+
nil, 5, 35, 28, 30, 29, 32, 31, 34, 33,
|
61
|
+
38, 37, 36 ]
|
62
62
|
|
63
63
|
racc_action_check = [
|
64
|
-
28, 8, 1, 5, 28, 6, 8, 29, 9,
|
65
|
-
|
66
|
-
30,
|
67
|
-
|
68
|
-
29, 29, 29, 29, 29, 29, 29,
|
64
|
+
28, 8, 1, 5, 28, 6, 8, 29, 9, 13,
|
65
|
+
16, 29, 28, 18, 28, 21, 30, 23, 27, 29,
|
66
|
+
30, 37, 38, 43, 64, 66, 68, 70, 30, 72,
|
67
|
+
nil, nil, nil, 28, 28, 28, 28, 28, 28, 28,
|
68
|
+
29, 29, 29, 29, 29, 29, 29, nil, nil, 30,
|
69
69
|
30, 30, 30, 30, 30, 30, 31, nil, nil, nil,
|
70
|
-
31, nil, nil, 32, nil, nil,
|
71
|
-
33, nil, nil,
|
72
|
-
|
70
|
+
31, nil, nil, 32, nil, nil, nil, 32, 31, nil,
|
71
|
+
33, nil, nil, nil, 33, 32, nil, nil, nil, nil,
|
72
|
+
nil, nil, 33, nil, nil, nil, nil, nil, nil, 31,
|
73
73
|
31, 31, 31, 31, 31, 31, 32, 32, 32, 32,
|
74
74
|
32, 32, 32, 33, 33, 33, 33, 33, 33, 33,
|
75
75
|
34, nil, nil, nil, 34, nil, nil, 35, nil, nil,
|
76
|
-
|
77
|
-
nil, 35, nil, nil,
|
76
|
+
nil, 35, 34, nil, 36, nil, nil, nil, 36, 35,
|
77
|
+
nil, 35, nil, nil, nil, nil, 36, nil, nil, nil,
|
78
78
|
nil, nil, nil, 34, 34, 34, 34, 34, 34, 34,
|
79
79
|
35, 35, 35, 35, 35, 35, 35, 36, 36, 36,
|
80
|
-
36, 36, 36, 36,
|
81
|
-
nil,
|
82
|
-
nil, 61,
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
nil, nil,
|
87
|
-
|
88
|
-
0, 0,
|
89
|
-
0,
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
4, 4,
|
94
|
-
|
95
|
-
|
96
|
-
nil,
|
97
|
-
|
80
|
+
36, 36, 36, 36, 41, nil, nil, nil, 41, nil,
|
81
|
+
nil, 59, nil, nil, nil, 59, 41, nil, 61, 41,
|
82
|
+
nil, nil, 61, 59, nil, nil, 59, nil, nil, nil,
|
83
|
+
61, nil, nil, 61, nil, nil, nil, 41, 41, 41,
|
84
|
+
41, 41, 41, 41, 59, 59, 59, 59, 59, 59,
|
85
|
+
59, 61, 61, 61, 61, 61, 61, 61, 62, nil,
|
86
|
+
nil, nil, 62, nil, nil, 65, nil, nil, nil, 65,
|
87
|
+
62, nil, 0, 62, nil, nil, nil, 65, 0, 0,
|
88
|
+
0, 0, nil, nil, nil, nil, nil, nil, nil, nil,
|
89
|
+
0, 62, 62, 62, 62, 62, 62, 62, 65, 65,
|
90
|
+
65, 65, 65, 65, 65, 2, nil, nil, nil, 3,
|
91
|
+
nil, 2, 2, 2, 2, 3, 3, 3, 3, nil,
|
92
|
+
nil, nil, 4, 2, nil, nil, 7, 3, 4, 4,
|
93
|
+
4, 4, 7, 7, 7, 7, nil, nil, nil, 14,
|
94
|
+
4, nil, nil, 20, 7, 14, 14, 14, 14, 20,
|
95
|
+
20, 20, 20, nil, nil, nil, nil, 14, nil, nil,
|
96
|
+
nil, 20, 24, 24, 24, 24, 24, 24, 24, 24,
|
97
|
+
24, 24, 24 ]
|
98
98
|
|
99
99
|
racc_action_pointer = [
|
100
|
-
230, 2, 263,
|
101
|
-
|
102
|
-
nil,
|
103
|
-
14, 54, 61, 68, 108, 115, 122,
|
104
|
-
nil,
|
105
|
-
nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
106
|
-
nil,
|
107
|
-
|
108
|
-
nil ]
|
100
|
+
230, 2, 263, 267, 280, -2, -13, 284, -6, 8,
|
101
|
+
nil, nil, nil, -12, 297, nil, 3, nil, 9, nil,
|
102
|
+
301, -4, nil, 4, 300, nil, nil, 6, -2, 5,
|
103
|
+
14, 54, 61, 68, 108, 115, 122, 5, 6, nil,
|
104
|
+
nil, 162, nil, -11, nil, nil, nil, nil, nil, nil,
|
105
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, 169,
|
106
|
+
nil, 176, 216, nil, 7, 223, 10, nil, 9, nil,
|
107
|
+
10, nil, 12, nil, nil, nil, nil, nil, nil ]
|
109
108
|
|
110
109
|
racc_action_default = [
|
111
|
-
-
|
112
|
-
|
113
|
-
-
|
114
|
-
-
|
115
|
-
|
116
|
-
-41, -42, -
|
117
|
-
-
|
118
|
-
-
|
119
|
-
-32 ]
|
110
|
+
-43, -43, -43, -43, -43, -43, -43, -7, -11, -43,
|
111
|
+
-1, -2, -3, -43, -43, -6, -10, -9, -43, 79,
|
112
|
+
-43, -43, -8, -43, -43, -4, -5, -13, -43, -43,
|
113
|
+
-43, -43, -43, -43, -43, -43, -43, -43, -43, -12,
|
114
|
+
-14, -43, -33, -43, -35, -36, -37, -38, -39, -40,
|
115
|
+
-41, -42, -15, -16, -17, -18, -19, -20, -21, -43,
|
116
|
+
-22, -43, -43, -23, -43, -32, -43, -24, -43, -25,
|
117
|
+
-43, -26, -43, -27, -31, -34, -28, -29, -30 ]
|
120
118
|
|
121
119
|
racc_goto_table = [
|
122
|
-
1,
|
123
|
-
|
124
|
-
|
125
|
-
7,
|
120
|
+
64, 23, 1, nil, 10, 11, 12, nil, nil, 15,
|
121
|
+
16, nil, nil, nil, nil, nil, 21, nil, 68, nil,
|
122
|
+
70, 72, 25, 7, 74, 7, 7, 7, nil, 39,
|
123
|
+
7, nil, nil, nil, nil, nil, nil, 7, nil, nil,
|
124
|
+
nil, nil, nil, 7, 40, 52, 53, 54, 55, 56,
|
125
|
+
57, 58, 60 ]
|
126
126
|
|
127
127
|
racc_goto_check = [
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
2,
|
128
|
+
6, 4, 1, nil, 1, 1, 1, nil, nil, 1,
|
129
|
+
3, nil, nil, nil, nil, nil, 1, nil, 6, nil,
|
130
|
+
6, 6, 1, 2, 6, 2, 2, 2, nil, 3,
|
131
|
+
2, nil, nil, nil, nil, nil, nil, 2, nil, nil,
|
132
|
+
nil, nil, nil, 2, 5, 5, 5, 5, 5, 5,
|
133
|
+
5, 5, 5 ]
|
132
134
|
|
133
135
|
racc_goto_pointer = [
|
134
|
-
nil,
|
136
|
+
nil, 2, 23, 2, -17, 16, -41 ]
|
135
137
|
|
136
138
|
racc_goto_default = [
|
137
|
-
nil, nil,
|
139
|
+
nil, nil, 42, nil, nil, 65, nil ]
|
138
140
|
|
139
141
|
racc_reduce_table = [
|
140
142
|
0, 0, :racc_error,
|
@@ -148,11 +150,11 @@ racc_reduce_table = [
|
|
148
150
|
3, 44, :_reduce_8,
|
149
151
|
2, 44, :_reduce_9,
|
150
152
|
2, 44, :_reduce_10,
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
3,
|
153
|
+
1, 44, :_reduce_11,
|
154
|
+
4, 45, :_reduce_12,
|
155
|
+
3, 45, :_reduce_13,
|
156
|
+
3, 46, :_reduce_14,
|
157
|
+
3, 46, :_reduce_15,
|
156
158
|
3, 46, :_reduce_16,
|
157
159
|
3, 46, :_reduce_17,
|
158
160
|
3, 46, :_reduce_18,
|
@@ -160,32 +162,30 @@ racc_reduce_table = [
|
|
160
162
|
3, 46, :_reduce_20,
|
161
163
|
3, 46, :_reduce_21,
|
162
164
|
3, 46, :_reduce_22,
|
163
|
-
|
164
|
-
|
165
|
+
4, 46, :_reduce_23,
|
166
|
+
4, 46, :_reduce_24,
|
165
167
|
4, 46, :_reduce_25,
|
166
168
|
4, 46, :_reduce_26,
|
167
|
-
|
168
|
-
|
169
|
+
5, 46, :_reduce_27,
|
170
|
+
5, 46, :_reduce_28,
|
169
171
|
5, 46, :_reduce_29,
|
170
172
|
5, 46, :_reduce_30,
|
171
|
-
|
172
|
-
|
173
|
-
2, 48, :_reduce_33,
|
174
|
-
1, 48, :_reduce_34,
|
173
|
+
2, 48, :_reduce_31,
|
174
|
+
1, 48, :_reduce_32,
|
175
175
|
1, 47, :_reduce_none,
|
176
|
-
3, 47, :
|
176
|
+
3, 47, :_reduce_34,
|
177
|
+
1, 47, :_reduce_35,
|
178
|
+
1, 47, :_reduce_36,
|
177
179
|
1, 47, :_reduce_37,
|
178
180
|
1, 47, :_reduce_38,
|
179
181
|
1, 47, :_reduce_39,
|
180
182
|
1, 47, :_reduce_40,
|
181
183
|
1, 47, :_reduce_41,
|
182
|
-
1, 47, :_reduce_42
|
183
|
-
1, 47, :_reduce_43,
|
184
|
-
1, 47, :_reduce_44 ]
|
184
|
+
1, 47, :_reduce_42 ]
|
185
185
|
|
186
|
-
racc_reduce_n =
|
186
|
+
racc_reduce_n = 43
|
187
187
|
|
188
|
-
racc_shift_n =
|
188
|
+
racc_shift_n = 79
|
189
189
|
|
190
190
|
racc_token_table = {
|
191
191
|
false => 0,
|
@@ -345,140 +345,132 @@ def _reduce_9(val, _values)
|
|
345
345
|
end
|
346
346
|
|
347
347
|
def _reduce_10(val, _values)
|
348
|
-
Compiler::Selector.new(attribute_list: val[0], index: val[1])
|
349
|
-
end
|
350
|
-
|
351
|
-
def _reduce_11(val, _values)
|
352
348
|
Compiler::Selector.new(node_type: val[0], attribute_list: val[1])
|
353
349
|
end
|
354
350
|
|
355
|
-
def
|
351
|
+
def _reduce_11(val, _values)
|
356
352
|
Compiler::Selector.new(node_type: val[0])
|
357
353
|
end
|
358
354
|
|
359
|
-
def
|
360
|
-
Compiler::Selector.new(attribute_list: val[0])
|
361
|
-
end
|
362
|
-
|
363
|
-
def _reduce_14(val, _values)
|
355
|
+
def _reduce_12(val, _values)
|
364
356
|
Compiler::AttributeList.new(attribute: val[1], rest: val[3])
|
365
357
|
end
|
366
358
|
|
367
|
-
def
|
359
|
+
def _reduce_13(val, _values)
|
368
360
|
Compiler::AttributeList.new(attribute: val[1])
|
369
361
|
end
|
370
362
|
|
371
|
-
def
|
363
|
+
def _reduce_14(val, _values)
|
372
364
|
Compiler::Attribute.new(key: val[0], value: val[2], operator: :!=)
|
373
365
|
end
|
374
366
|
|
375
|
-
def
|
367
|
+
def _reduce_15(val, _values)
|
376
368
|
Compiler::Attribute.new(key: val[0], value: val[2], operator: :!~)
|
377
369
|
end
|
378
370
|
|
379
|
-
def
|
371
|
+
def _reduce_16(val, _values)
|
380
372
|
Compiler::Attribute.new(key: val[0], value: val[2], operator: :=~)
|
381
373
|
end
|
382
374
|
|
383
|
-
def
|
375
|
+
def _reduce_17(val, _values)
|
384
376
|
Compiler::Attribute.new(key: val[0], value: val[2], operator: :>=)
|
385
377
|
end
|
386
378
|
|
387
|
-
def
|
379
|
+
def _reduce_18(val, _values)
|
388
380
|
Compiler::Attribute.new(key: val[0], value: val[2], operator: :>)
|
389
381
|
end
|
390
382
|
|
391
|
-
def
|
383
|
+
def _reduce_19(val, _values)
|
392
384
|
Compiler::Attribute.new(key: val[0], value: val[2], operator: :<=)
|
393
385
|
end
|
394
386
|
|
395
|
-
def
|
387
|
+
def _reduce_20(val, _values)
|
396
388
|
Compiler::Attribute.new(key: val[0], value: val[2], operator: :<)
|
397
389
|
end
|
398
390
|
|
399
|
-
def
|
391
|
+
def _reduce_21(val, _values)
|
400
392
|
Compiler::Attribute.new(key: val[0], value: val[2], operator: :==)
|
401
393
|
end
|
402
394
|
|
403
|
-
def
|
395
|
+
def _reduce_22(val, _values)
|
404
396
|
Compiler::Attribute.new(key: val[0], value: val[2], operator: :includes)
|
405
397
|
end
|
406
398
|
|
407
|
-
def
|
399
|
+
def _reduce_23(val, _values)
|
408
400
|
Compiler::Attribute.new(key: val[0], value: Compiler::Array.new, operator: :!=)
|
409
401
|
end
|
410
402
|
|
411
|
-
def
|
403
|
+
def _reduce_24(val, _values)
|
412
404
|
Compiler::Attribute.new(key: val[0], value: Compiler::Array.new, operator: :==)
|
413
405
|
end
|
414
406
|
|
415
|
-
def
|
407
|
+
def _reduce_25(val, _values)
|
416
408
|
Compiler::Attribute.new(key: val[0], value: Compiler::Array.new, operator: :not_in)
|
417
409
|
end
|
418
410
|
|
419
|
-
def
|
411
|
+
def _reduce_26(val, _values)
|
420
412
|
Compiler::Attribute.new(key: val[0], value: Compiler::Array.new, operator: :in)
|
421
413
|
end
|
422
414
|
|
423
|
-
def
|
415
|
+
def _reduce_27(val, _values)
|
424
416
|
Compiler::Attribute.new(key: val[0], value: val[3], operator: :!=)
|
425
417
|
end
|
426
418
|
|
427
|
-
def
|
419
|
+
def _reduce_28(val, _values)
|
428
420
|
Compiler::Attribute.new(key: val[0], value: val[3], operator: :==)
|
429
421
|
end
|
430
422
|
|
431
|
-
def
|
423
|
+
def _reduce_29(val, _values)
|
432
424
|
Compiler::Attribute.new(key: val[0], value: val[3], operator: :not_in)
|
433
425
|
end
|
434
426
|
|
435
|
-
def
|
427
|
+
def _reduce_30(val, _values)
|
436
428
|
Compiler::Attribute.new(key: val[0], value: val[3], operator: :in)
|
437
429
|
end
|
438
430
|
|
439
|
-
def
|
431
|
+
def _reduce_31(val, _values)
|
440
432
|
Compiler::Array.new(value: val[0], rest: val[1])
|
441
433
|
end
|
442
434
|
|
443
|
-
def
|
435
|
+
def _reduce_32(val, _values)
|
444
436
|
Compiler::Array.new(value: val[0])
|
445
437
|
end
|
446
438
|
|
447
|
-
# reduce
|
439
|
+
# reduce 33 omitted
|
448
440
|
|
449
|
-
def
|
441
|
+
def _reduce_34(val, _values)
|
450
442
|
Compiler::DynamicAttribute.new(value: val[1])
|
451
443
|
end
|
452
444
|
|
453
|
-
def
|
445
|
+
def _reduce_35(val, _values)
|
454
446
|
Compiler::Boolean.new(value: val[0])
|
455
447
|
end
|
456
448
|
|
457
|
-
def
|
449
|
+
def _reduce_36(val, _values)
|
458
450
|
Compiler::Float.new(value: val[0])
|
459
451
|
end
|
460
452
|
|
461
|
-
def
|
453
|
+
def _reduce_37(val, _values)
|
462
454
|
Compiler::Integer.new(value: val[0])
|
463
455
|
end
|
464
456
|
|
465
|
-
def
|
457
|
+
def _reduce_38(val, _values)
|
466
458
|
Compiler::Nil.new(value: val[0])
|
467
459
|
end
|
468
460
|
|
469
|
-
def
|
461
|
+
def _reduce_39(val, _values)
|
470
462
|
Compiler::Regexp.new(value: val[0])
|
471
463
|
end
|
472
464
|
|
473
|
-
def
|
465
|
+
def _reduce_40(val, _values)
|
474
466
|
Compiler::String.new(value: val[0])
|
475
467
|
end
|
476
468
|
|
477
|
-
def
|
469
|
+
def _reduce_41(val, _values)
|
478
470
|
Compiler::Symbol.new(value: val[0])
|
479
471
|
end
|
480
472
|
|
481
|
-
def
|
473
|
+
def _reduce_42(val, _values)
|
482
474
|
Compiler::Identifier.new(value: val[0])
|
483
475
|
end
|
484
476
|
|
@@ -19,10 +19,8 @@ rule
|
|
19
19
|
selector
|
20
20
|
: tNODE_TYPE attribute_list tINDEX { Compiler::Selector.new(node_type: val[0], attribute_list: val[1], index: val[2]) }
|
21
21
|
| tNODE_TYPE tINDEX { Compiler::Selector.new(node_type: val[0], index: val[1]) }
|
22
|
-
| attribute_list tINDEX { Compiler::Selector.new(attribute_list: val[0], index: val[1]) }
|
23
22
|
| tNODE_TYPE attribute_list { Compiler::Selector.new(node_type: val[0], attribute_list: val[1]) }
|
24
23
|
| tNODE_TYPE { Compiler::Selector.new(node_type: val[0]) }
|
25
|
-
| attribute_list { Compiler::Selector.new(attribute_list: val[0]) }
|
26
24
|
;
|
27
25
|
|
28
26
|
attribute_list
|
@@ -5,10 +5,10 @@
|
|
5
5
|
# It supports the following selectors:
|
6
6
|
#
|
7
7
|
# * AST node type: +.class+, +.send+
|
8
|
-
# * attribute value:
|
9
|
-
# * attribute regex: <code
|
10
|
-
# * attribute conditions:
|
11
|
-
# * nested attribute:
|
8
|
+
# * attribute value: +.send[receiver = nil]+, +.send[message = create]+
|
9
|
+
# * attribute regex: <code>.send[key=~/\A:([^'"]+)\z/]</code>, <code>.send[key!~/\A:([^'"]+)\z/]</code>
|
10
|
+
# * attribute conditions: +.send[message != nil]+, +.send[value > 1]+, +.send[value >= 1]+, +.send[value < 1]+, +.send[value <= 1]+
|
11
|
+
# * nested attribute: +.send[caller.message = map]+, +.send[arguments.size = 2]+
|
12
12
|
# * first or last child: +.def:first-child+, +.send:last-child+
|
13
13
|
# * nth-child or nth-last-child: +.def:nth-child(2)+, +.send:nth-last-child(2)+
|
14
14
|
# * descendant: +.class .send+
|
@@ -21,9 +21,9 @@
|
|
21
21
|
#
|
22
22
|
# * not_has: +.class:not_has(.def)+, it's same as +:not(:has())+ in css, just to make implementation easy.
|
23
23
|
# * nested selector: +.send[arguments = [size = 2][first = .sym][last = .hash]]+
|
24
|
-
# * array value: +.send[arguments = (a
|
25
|
-
# * IN operator: +.send[message IN (try
|
26
|
-
# * NOT IN operator: +.send[message NOT IN (create
|
24
|
+
# * array value: +.send[arguments = (a b)]+
|
25
|
+
# * IN operator: +.send[message IN (try try!)]+
|
26
|
+
# * NOT IN operator: +.send[message NOT IN (create build)]+
|
27
27
|
# * INCLUDES operator: +.send[arguments INCLUDES &block]+
|
28
28
|
# * dynamic attribute value: +.hash > .pair[key={{value}}]+
|
29
29
|
#
|
data/lib/synvert/core/version.rb
CHANGED
@@ -1033,7 +1033,7 @@ describe Parser::AST::Node do
|
|
1033
1033
|
node = parse(<<~EOS)
|
1034
1034
|
class Synvert
|
1035
1035
|
def foobar(foo, bar)
|
1036
|
-
foo
|
1036
|
+
{ foo => bar }
|
1037
1037
|
end
|
1038
1038
|
end
|
1039
1039
|
EOS
|
@@ -1056,10 +1056,12 @@ describe Parser::AST::Node do
|
|
1056
1056
|
],
|
1057
1057
|
body: [
|
1058
1058
|
{
|
1059
|
-
type: :
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1059
|
+
type: :hash,
|
1060
|
+
pairs: {
|
1061
|
+
type: :pair,
|
1062
|
+
key: { type: :lvar, name: :foo },
|
1063
|
+
value: { type: :lvar, name: :bar }
|
1064
|
+
}
|
1063
1065
|
}
|
1064
1066
|
]
|
1065
1067
|
}
|
@@ -310,7 +310,7 @@ module Synvert::Core::NodeQuery
|
|
310
310
|
end
|
311
311
|
|
312
312
|
it 'matches arguments' do
|
313
|
-
expression = parser.parse('.send[arguments
|
313
|
+
expression = parser.parse('.send[arguments.size=2][arguments.first=.sym][arguments.last=.hash]')
|
314
314
|
expect(expression.query_nodes(node)).to eq [node.body.first.body.last, node.body.second.body.last]
|
315
315
|
end
|
316
316
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: synvert-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Huang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|