synvert-core 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e5bf36b2f9e986dd2baf0bbddf53f4671a3bf98af0db830c270960eb583b47ce
4
- data.tar.gz: 7e8693858d73d11c09652076ee03d49fe69662386caff67cbd0a3cc37e47d0a2
3
+ metadata.gz: 3c530d34ca0e2db5d9a295cb0cb48c375d13760f09290624805d742328a49103
4
+ data.tar.gz: 87cc4ef7ab9116bac2cbed78b9f71ab8d4ffa30281554d10319527a9aab94573
5
5
  SHA512:
6
- metadata.gz: ad0eb6125d82241c60f7f0e229b9735f7c253280f1e56d586dfd24e8afb9c25b2cf574ca9c21e252c485f529b1bdf5f6b26c2b59805781cdefd3bc07a76072d8
7
- data.tar.gz: 37bd754087a17d55577a10338fef9da3c60733d8634e9c394666a826fe205dc7f895121570f1e9cca4e7e1284f0b3b11c16e532e197afe2cd0ce61424c5d1557
6
+ metadata.gz: 1b864e1e350d3467fe12d2c5e26a5c5a0b685752e21802e3773edfbbb8fca8f7dec60fb545475a630a3f00c09359c66859b228cf7cb3d19aa6bf044df4848408
7
+ data.tar.gz: c8c5641b85080f03307fed835c05132488d140bb19b694c2b5b0958cb3d6377785ef1447c8b7fec59e7529f2ec610f6c78d72357b60f5fe4285d43d5071750fb
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.2.1 (2022-05-01)
4
+
5
+ * Selector always after a node type in NQL
6
+ * Define `pairs` method for `hash` ndoe
7
+
3
8
  ## 1.2.0 (2022-04-29)
4
9
 
5
10
  * Remove comma in NQL array value
@@ -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[caller key left_value message name parent_class parent_const receiver right_value value].each do |method_name|
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, 19, 11, 15, 53, 16, 10, 8, 20, 22,
29
- 10, 53, 45, 23, 43, 24, 8, 10, 26, 45,
30
- 53, 27, 40, 10, 63, 64, 10, 68, 45, 75,
31
- 77, 78, 79, 46, 47, 48, 49, 50, 51, 52,
32
- 46, 47, 48, 49, 50, 51, 52, 80, nil, 46,
33
- 47, 48, 49, 50, 51, 52, 8, nil, nil, nil,
34
- 53, nil, nil, 8, nil, nil, 10, 53, 45, nil,
35
- 8, nil, nil, 10, 53, 45, nil, nil, nil, nil,
36
- 10, nil, 45, nil, nil, nil, nil, nil, nil, 46,
37
- 47, 48, 49, 50, 51, 52, 46, 47, 48, 49,
38
- 50, 51, 52, 46, 47, 48, 49, 50, 51, 52,
39
- 8, nil, nil, nil, 53, nil, nil, 8, nil, nil,
40
- 10, 53, 45, nil, 8, nil, nil, 10, 53, 45,
41
- nil, 61, nil, nil, 10, nil, 45, nil, nil, nil,
42
- nil, nil, nil, 46, 47, 48, 49, 50, 51, 52,
43
- 46, 47, 48, 49, 50, 51, 52, 46, 47, 48,
44
- 49, 50, 51, 52, 8, nil, nil, nil, 53, nil,
45
- nil, 8, nil, nil, 10, 53, 45, nil, 8, 65,
46
- nil, 10, 53, 45, nil, nil, 69, nil, 10, nil,
47
- 45, nil, nil, 71, nil, nil, nil, 46, 47, 48,
48
- 49, 50, 51, 52, 46, 47, 48, 49, 50, 51,
49
- 52, 46, 47, 48, 49, 50, 51, 52, 8, nil,
50
- nil, nil, 53, nil, nil, 8, nil, nil, 10, 53,
51
- 45, nil, 8, 73, nil, 10, nil, 45, 6, 2,
52
- 3, 4, 10, nil, nil, nil, nil, nil, nil, nil,
53
- 5, 46, 47, 48, 49, 50, 51, 52, 46, 47,
54
- 48, 49, 50, 51, 52, 8, nil, nil, nil, nil,
55
- 8, 6, 2, 3, 4, 10, 6, 2, 3, 4,
56
- 10, nil, nil, 5, 8, nil, nil, nil, 5, 8,
57
- 6, 2, 3, 4, 10, 6, 2, 3, 4, 10,
58
- nil, nil, 5, 8, nil, nil, nil, 5, 8, 6,
59
- 2, 3, 4, 10, 6, 2, 3, 4, 10, nil,
60
- nil, 5, nil, nil, nil, nil, 5, 35, 28, 30,
61
- 29, 32, 31, 34, 33, 38, 37, 36 ]
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, 10,
65
- 28, 29, 28, 11, 28, 15, 30, 29, 18, 29,
66
- 30, 21, 25, 27, 37, 38, 30, 45, 30, 66,
67
- 68, 70, 72, 28, 28, 28, 28, 28, 28, 28,
68
- 29, 29, 29, 29, 29, 29, 29, 74, nil, 30,
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, 31, 32, 31, nil,
71
- 33, nil, nil, 32, 33, 32, nil, nil, nil, nil,
72
- 33, nil, 33, nil, nil, nil, nil, nil, nil, 31,
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
- 34, 35, 34, nil, 36, nil, nil, 35, 36, 35,
77
- nil, 35, nil, nil, 36, nil, 36, nil, 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, 43, nil, nil, nil, 43, nil,
81
- nil, 61, nil, nil, 43, 61, 43, nil, 63, 43,
82
- nil, 61, 63, 61, nil, nil, 61, nil, 63, nil,
83
- 63, nil, nil, 63, nil, nil, nil, 43, 43, 43,
84
- 43, 43, 43, 43, 61, 61, 61, 61, 61, 61,
85
- 61, 63, 63, 63, 63, 63, 63, 63, 64, nil,
86
- nil, nil, 64, nil, nil, 67, nil, nil, 64, 67,
87
- 64, nil, 0, 64, nil, 67, nil, 67, 0, 0,
88
- 0, 0, 0, nil, nil, nil, nil, nil, nil, nil,
89
- 0, 64, 64, 64, 64, 64, 64, 64, 67, 67,
90
- 67, 67, 67, 67, 67, 2, nil, nil, nil, nil,
91
- 3, 2, 2, 2, 2, 2, 3, 3, 3, 3,
92
- 3, nil, nil, 2, 4, nil, nil, nil, 3, 7,
93
- 4, 4, 4, 4, 4, 7, 7, 7, 7, 7,
94
- nil, nil, 4, 16, nil, nil, nil, 7, 24, 16,
95
- 16, 16, 16, 16, 24, 24, 24, 24, 24, nil,
96
- nil, 16, nil, nil, nil, nil, 24, 22, 22, 22,
97
- 22, 22, 22, 22, 22, 22, 22, 22 ]
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, 268, 282, -2, -13, 287, -6, 1,
101
- 5, 13, nil, nil, nil, -6, 301, nil, 11, nil,
102
- nil, 8, 305, nil, 306, 3, nil, 11, -2, 5,
103
- 14, 54, 61, 68, 108, 115, 122, 8, 9, nil,
104
- nil, nil, nil, 162, nil, -7, nil, nil, nil, nil,
105
- nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
106
- nil, 169, nil, 176, 216, nil, 12, 223, 15, nil,
107
- 14, nil, 15, nil, 30, nil, nil, nil, nil, nil,
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
- -45, -45, -45, -45, -45, -45, -45, -7, -12, -13,
112
- -45, -45, -1, -2, -3, -45, -45, -6, -11, -9,
113
- -10, -45, -45, 81, -45, -45, -8, -15, -45, -45,
114
- -45, -45, -45, -45, -45, -45, -45, -45, -45, -4,
115
- -5, -14, -16, -45, -35, -45, -37, -38, -39, -40,
116
- -41, -42, -43, -44, -17, -18, -19, -20, -21, -22,
117
- -23, -45, -24, -45, -45, -25, -45, -34, -45, -26,
118
- -45, -27, -45, -28, -45, -29, -33, -36, -30, -31,
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, 18, 12, 13, 14, 66, 7, 17, 7, 7,
123
- 7, 21, nil, 7, nil, nil, 25, nil, nil, nil,
124
- 41, nil, 7, 70, 39, 72, 74, nil, nil, 76,
125
- 7, 42, 54, 55, 56, 57, 58, 59, 60, 62 ]
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
- 1, 3, 1, 1, 1, 6, 2, 1, 2, 2,
129
- 2, 4, nil, 2, nil, nil, 1, nil, nil, nil,
130
- 3, nil, 2, 6, 1, 6, 6, nil, nil, 6,
131
- 2, 5, 5, 5, 5, 5, 5, 5, 5, 5 ]
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, 0, 6, -7, 1, 3, -38 ]
136
+ nil, 2, 23, 2, -17, 16, -41 ]
135
137
 
136
138
  racc_goto_default = [
137
- nil, nil, 44, 9, nil, 67, 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
- 2, 44, :_reduce_11,
152
- 1, 44, :_reduce_12,
153
- 1, 44, :_reduce_13,
154
- 4, 45, :_reduce_14,
155
- 3, 45, :_reduce_15,
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
- 3, 46, :_reduce_23,
164
- 3, 46, :_reduce_24,
165
+ 4, 46, :_reduce_23,
166
+ 4, 46, :_reduce_24,
165
167
  4, 46, :_reduce_25,
166
168
  4, 46, :_reduce_26,
167
- 4, 46, :_reduce_27,
168
- 4, 46, :_reduce_28,
169
+ 5, 46, :_reduce_27,
170
+ 5, 46, :_reduce_28,
169
171
  5, 46, :_reduce_29,
170
172
  5, 46, :_reduce_30,
171
- 5, 46, :_reduce_31,
172
- 5, 46, :_reduce_32,
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, :_reduce_36,
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 = 45
186
+ racc_reduce_n = 43
187
187
 
188
- racc_shift_n = 81
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 _reduce_12(val, _values)
351
+ def _reduce_11(val, _values)
356
352
  Compiler::Selector.new(node_type: val[0])
357
353
  end
358
354
 
359
- def _reduce_13(val, _values)
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 _reduce_15(val, _values)
359
+ def _reduce_13(val, _values)
368
360
  Compiler::AttributeList.new(attribute: val[1])
369
361
  end
370
362
 
371
- def _reduce_16(val, _values)
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 _reduce_17(val, _values)
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 _reduce_18(val, _values)
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 _reduce_19(val, _values)
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 _reduce_20(val, _values)
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 _reduce_21(val, _values)
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 _reduce_22(val, _values)
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 _reduce_23(val, _values)
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 _reduce_24(val, _values)
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 _reduce_25(val, _values)
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 _reduce_26(val, _values)
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 _reduce_27(val, _values)
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 _reduce_28(val, _values)
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 _reduce_29(val, _values)
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 _reduce_30(val, _values)
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 _reduce_31(val, _values)
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 _reduce_32(val, _values)
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 _reduce_33(val, _values)
431
+ def _reduce_31(val, _values)
440
432
  Compiler::Array.new(value: val[0], rest: val[1])
441
433
  end
442
434
 
443
- def _reduce_34(val, _values)
435
+ def _reduce_32(val, _values)
444
436
  Compiler::Array.new(value: val[0])
445
437
  end
446
438
 
447
- # reduce 35 omitted
439
+ # reduce 33 omitted
448
440
 
449
- def _reduce_36(val, _values)
441
+ def _reduce_34(val, _values)
450
442
  Compiler::DynamicAttribute.new(value: val[1])
451
443
  end
452
444
 
453
- def _reduce_37(val, _values)
445
+ def _reduce_35(val, _values)
454
446
  Compiler::Boolean.new(value: val[0])
455
447
  end
456
448
 
457
- def _reduce_38(val, _values)
449
+ def _reduce_36(val, _values)
458
450
  Compiler::Float.new(value: val[0])
459
451
  end
460
452
 
461
- def _reduce_39(val, _values)
453
+ def _reduce_37(val, _values)
462
454
  Compiler::Integer.new(value: val[0])
463
455
  end
464
456
 
465
- def _reduce_40(val, _values)
457
+ def _reduce_38(val, _values)
466
458
  Compiler::Nil.new(value: val[0])
467
459
  end
468
460
 
469
- def _reduce_41(val, _values)
461
+ def _reduce_39(val, _values)
470
462
  Compiler::Regexp.new(value: val[0])
471
463
  end
472
464
 
473
- def _reduce_42(val, _values)
465
+ def _reduce_40(val, _values)
474
466
  Compiler::String.new(value: val[0])
475
467
  end
476
468
 
477
- def _reduce_43(val, _values)
469
+ def _reduce_41(val, _values)
478
470
  Compiler::Symbol.new(value: val[0])
479
471
  end
480
472
 
481
- def _reduce_44(val, _values)
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: +[receiver = nil]+, +[message = create]+
9
- # * attribute regex: <code>[key=~/\A:([^'"]+)\z/]</code>, <code>[key!~/\A:([^'"]+)\z/]</code>
10
- # * attribute conditions: +[message != nil]+, +[value > 1]+, +[value >= 1]+, +[value < 1]+, +[value <= 1]+
11
- # * nested attribute: +[caller.message = map]+, +[arguments.size = 2]+
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, b)]+
25
- # * IN operator: +.send[message IN (try, try!)]+
26
- # * NOT IN operator: +.send[message NOT IN (create, build)]+
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
  #
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Synvert
4
4
  module Core
5
- VERSION = '1.2.0'
5
+ VERSION = '1.2.1'
6
6
  end
7
7
  end
@@ -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 + bar
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: :send,
1060
- receiver: { name: :foo, type: :lvar },
1061
- message: :+,
1062
- arguments: [{ name: :bar, type: :lvar }]
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=[size=2][first=.sym][last=.hash]]')
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.0
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-04-29 00:00:00.000000000 Z
11
+ date: 2022-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport