node_query 1.13.8 → 1.13.10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cebf13af77b1b91af393dbf741b12ef1804de496d85f243b336decdb05ee5c8a
4
- data.tar.gz: e4815863dc1b57e92f2e1bbc1858b8e35668e4a22d9392bc565af4f3993dcdc9
3
+ metadata.gz: 587cefdbcb8ef9ae22bdf3ec6f9a5ccbbe468c67801a841cdd96204634567b05
4
+ data.tar.gz: 4257ea586307071a0edb6ef6657af7a2227ed4b6006532d4186c1f02ed4d4711
5
5
  SHA512:
6
- metadata.gz: e9fd0443d795e0dccef4c74ea9ff9fc242f96c4b2790b9f56ae5a03d4fc235ed7d950c1f9d7391961ca8450f0de075a103d9ba02db402199957de3d84ea153d6
7
- data.tar.gz: 8aafbc1a54eea3af5fd5dcadced6ce5cf66d51ca0f76128bca1643401aab3c0b3c5673a11ed4cbca7955aa62698053c57525b2f57b03a3af6daf9b96b04554a9
6
+ metadata.gz: 60efa801673c6243456a98a50249edb70d7c46443def3b160530d2d9ab7633e62b4c012c9ed5f08f13ea8d3756870d63b194c9529818a4f3b2cc6c5a6a134533
7
+ data.tar.gz: ab891c93073c30d513f6886c72d7c5054268de9772231c350d190597978250510f25120fbbb339e9d93c96710f73dc7609b0199bccaf5a595794e11fefb90952
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.13.10 (2023-08-12)
4
+
5
+ * Update `node_query_parser.y`
6
+
7
+ ## 1.13.9 (2023-08-02)
8
+
9
+ * Add `OPERATOR` macro
10
+ * Use operator `=` instead of `==`
11
+
3
12
  ## 1.13.8 (2023-06-28)
4
13
 
5
14
  * Check `.to_value` instead of `.type`
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- node_query (1.13.8)
4
+ node_query (1.13.10)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -7,7 +7,7 @@ module NodeQuery::Compiler
7
7
  # @param key [String] the key
8
8
  # @param value the value can be any class implement {NodeQuery::Compiler::Comparable}
9
9
  # @param operator [String] the operator
10
- def initialize(key:, value:, operator: '==')
10
+ def initialize(key:, value:, operator: '=')
11
11
  @key = key
12
12
  @value = value
13
13
  @operator = operator
@@ -15,7 +15,7 @@ module NodeQuery::Compiler
15
15
  # @param node [Node] the node
16
16
  # @param base_node [Node] the base node for evaluated value
17
17
  # @return [Boolean]
18
- def match?(node, base_node, _operator = '==')
18
+ def match?(node, base_node, _operator = '=')
19
19
  return false unless node
20
20
 
21
21
  @node_type.to_sym == NodeQuery.adapter.get_node_type(node) && (!@attribute_list || @attribute_list.match?(
@@ -3,17 +3,17 @@
3
3
  module NodeQuery::Compiler
4
4
  # Compare acutal value with expected value.
5
5
  module Comparable
6
- SIMPLE_VALID_OPERATORS = ['==', '!=', 'includes', 'not_includes']
7
- STRING_VALID_OPERATORS = ['==', '!=', '^=', '$=', '*=', 'includes', 'not_includes']
8
- NUMBER_VALID_OPERATORS = ['==', '!=', '>', '>=', '<', '<=', 'includes', 'not_includes']
9
- ARRAY_VALID_OPERATORS = ['==', '!=', 'in', 'not_in']
6
+ SIMPLE_VALID_OPERATORS = ['=', '!=', 'includes', 'not_includes']
7
+ STRING_VALID_OPERATORS = ['=', '!=', '^=', '$=', '*=', 'includes', 'not_includes']
8
+ NUMBER_VALID_OPERATORS = ['=', '!=', '>', '>=', '<', '<=', 'includes', 'not_includes']
9
+ ARRAY_VALID_OPERATORS = ['=', '!=', 'in', 'not_in']
10
10
  REGEXP_VALID_OPERATORS = ['=~', '!~']
11
11
 
12
12
  # Check if the actual value matches the expected value.
13
13
  #
14
14
  # @param node [Node] node to calculate actual value
15
15
  # @param base_node [Node] the base node for evaluated value
16
- # @param operator [String] operator to compare with expected value, operator can be <code>'=='</code>, <code>'!='</code>, <code>'>'</code>, <code>'>='</code>, <code>'<'</code>, <code>'<='</code>, <code>'includes'</code>, <code>'in'</code>, <code>'not_in'</code>, <code>'=~'</code>, <code>'!~'</code>
16
+ # @param operator [String] operator to compare with expected value, operator can be <code>'='</code>, <code>'!='</code>, <code>'>'</code>, <code>'>='</code>, <code>'<'</code>, <code>'<='</code>, <code>'includes'</code>, <code>'in'</code>, <code>'not_in'</code>, <code>'=~'</code>, <code>'!~'</code>
17
17
  # @return [Boolean] true if actual value matches the expected value
18
18
  # @raise [NodeQuery::Compiler::InvalidOperatorError] if operator is invalid
19
19
  def match?(node, base_node, operator)
@@ -51,9 +51,9 @@ module NodeQuery::Compiler
51
51
  actual <= expected
52
52
  when 'in'
53
53
  if node.is_a?(Array)
54
- node.all? { |child| expected.any? { |expected_child| expected_child.match?(child, base_node, '==') } }
54
+ node.all? { |child| expected.any? { |expected_child| expected_child.match?(child, base_node, '=') } }
55
55
  else
56
- expected.any? { |expected_child| expected_child.match?(node, base_node, '==') }
56
+ expected.any? { |expected_child| expected_child.match?(node, base_node, '=') }
57
57
  end
58
58
  when 'not_in'
59
59
  if node.is_a?(Array)
@@ -69,7 +69,7 @@ module NodeQuery::Compiler
69
69
  if expected.is_a?(::Array)
70
70
  actual.is_a?(::Array) && actual.size == expected.size &&
71
71
  actual.zip(expected).all? { |actual_child, expected_child|
72
- expected_child.match?(actual_child, base_node, '==')
72
+ expected_child.match?(actual_child, base_node, '=')
73
73
  }
74
74
  else
75
75
  is_equal?(actual, expected)
@@ -33,7 +33,7 @@ module NodeQuery::Compiler
33
33
  # Check if node matches the selector.
34
34
  # @param node [Node] the node
35
35
  # @param base_node [Node] the base node for evaluated node
36
- def match?(node, base_node, operator = "==")
36
+ def match?(node, base_node, operator = "=")
37
37
  if node.is_a?(::Array)
38
38
  case operator
39
39
  when "not_includes"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class NodeQuery
4
- VERSION = "1.13.8"
4
+ VERSION = "1.13.10"
5
5
  end
@@ -10,6 +10,7 @@ macros
10
10
  NODE_TYPE /\.[a-zA-Z]+/
11
11
  IDENTIFIER /[@\*\-\.\w]*\w/
12
12
  IDENTIFIER_VALUE /[@\.\w!&:\?<>=]+/
13
+ OPERATOR /(\^=|\$=|\*=|!=|=~|!~|>=|<=|>|<|=|not includes|includes|not in|in)/i
13
14
  FALSE /false/
14
15
  FLOAT /\-?\d+\.\d+/
15
16
  INTEGER /\-?\d+/
@@ -39,21 +40,7 @@ rules
39
40
  /#{CLOSE_SELECTOR}/ { [:tCLOSE_SELECTOR, text] }
40
41
  /#{OPEN_ATTRIBUTE}/ { @nested_count += 1; @state = :KEY; [:tOPEN_ATTRIBUTE, text] }
41
42
  :KEY /\s+/
42
- :KEY /\^=/ { @state = :VALUE; [:tOPERATOR, '^='] }
43
- :KEY /\$=/ { @state = :VALUE; [:tOPERATOR, '$='] }
44
- :KEY /\*=/ { @state = :VALUE; [:tOPERATOR, '*='] }
45
- :KEY /!=/ { @state = :VALUE; [:tOPERATOR, '!='] }
46
- :KEY /=~/ { @state = :VALUE; [:tOPERATOR, '=~'] }
47
- :KEY /!~/ { @state = :VALUE; [:tOPERATOR, '!~'] }
48
- :KEY />=/ { @state = :VALUE; [:tOPERATOR, '>='] }
49
- :KEY /<=/ { @state = :VALUE; [:tOPERATOR, '<='] }
50
- :KEY />/ { @state = :VALUE; [:tOPERATOR, '>'] }
51
- :KEY /</ { @state = :VALUE; [:tOPERATOR, '<'] }
52
- :KEY /=/ { @state = :VALUE; [:tOPERATOR, '=='] }
53
- :KEY /not includes/i { @state = :VALUE; [:tOPERATOR, 'not_includes'] }
54
- :KEY /includes/i { @state = :VALUE; [:tOPERATOR, 'includes'] }
55
- :KEY /not in/i { @state = :VALUE; [:tOPERATOR, 'not_in'] }
56
- :KEY /in/i { @state = :VALUE; [:tOPERATOR, 'in'] }
43
+ :KEY /#{OPERATOR}/ { @state = :VALUE; [:tOPERATOR, text.downcase.sub(' ', '_')] }
57
44
  :KEY /#{IDENTIFIER}/ { [:tKEY, text] }
58
45
  :VALUE /\s+/
59
46
  :VALUE /\[\]=/ { [:tIDENTIFIER_VALUE, text] }
@@ -23,6 +23,7 @@ class NodeQueryLexer
23
23
  NODE_TYPE = /\.[a-zA-Z]+/
24
24
  IDENTIFIER = /[@\*\-\.\w]*\w/
25
25
  IDENTIFIER_VALUE = /[@\.\w!&:\?<>=]+/
26
+ OPERATOR = /(\^=|\$=|\*=|!=|=~|!~|>=|<=|>|<|=|not includes|includes|not in|in)/i
26
27
  FALSE = /false/
27
28
  FLOAT = /\-?\d+\.\d+/
28
29
  INTEGER = /\-?\d+/
@@ -157,36 +158,8 @@ class NodeQueryLexer
157
158
  case
158
159
  when ss.skip(/\s+/) then
159
160
  # do nothing
160
- when ss.skip(/\^=/) then
161
- action { @state = :VALUE; [:tOPERATOR, '^='] }
162
- when ss.skip(/\$=/) then
163
- action { @state = :VALUE; [:tOPERATOR, '$='] }
164
- when ss.skip(/\*=/) then
165
- action { @state = :VALUE; [:tOPERATOR, '*='] }
166
- when ss.skip(/!=/) then
167
- action { @state = :VALUE; [:tOPERATOR, '!='] }
168
- when ss.skip(/=~/) then
169
- action { @state = :VALUE; [:tOPERATOR, '=~'] }
170
- when ss.skip(/!~/) then
171
- action { @state = :VALUE; [:tOPERATOR, '!~'] }
172
- when ss.skip(/>=/) then
173
- action { @state = :VALUE; [:tOPERATOR, '>='] }
174
- when ss.skip(/<=/) then
175
- action { @state = :VALUE; [:tOPERATOR, '<='] }
176
- when ss.skip(/>/) then
177
- action { @state = :VALUE; [:tOPERATOR, '>'] }
178
- when ss.skip(/</) then
179
- action { @state = :VALUE; [:tOPERATOR, '<'] }
180
- when ss.skip(/=/) then
181
- action { @state = :VALUE; [:tOPERATOR, '=='] }
182
- when ss.skip(/not includes/i) then
183
- action { @state = :VALUE; [:tOPERATOR, 'not_includes'] }
184
- when ss.skip(/includes/i) then
185
- action { @state = :VALUE; [:tOPERATOR, 'includes'] }
186
- when ss.skip(/not in/i) then
187
- action { @state = :VALUE; [:tOPERATOR, 'not_in'] }
188
- when ss.skip(/in/i) then
189
- action { @state = :VALUE; [:tOPERATOR, 'in'] }
161
+ when text = ss.scan(/#{OPERATOR}/) then
162
+ action { @state = :VALUE; [:tOPERATOR, text.downcase.sub(' ', '_')] }
190
163
  when text = ss.scan(/#{IDENTIFIER}/) then
191
164
  action { [:tKEY, text] }
192
165
  else
@@ -22,90 +22,90 @@ class NodeQueryParser < Racc::Parser
22
22
  ##### State transition tables begin ###
23
23
 
24
24
  racc_action_table = [
25
- 8, 7, 8, 7, 9, 37, 5, 6, 5, 6,
26
- 28, 10, 12, 13, 17, 18, 22, 30, 31, 32,
27
- 33, 34, 35, 36, 8, 7, 23, 24, 25, 37,
28
- 5, 6, 8, 7, 17, 38, 41, 37, 5, 6,
29
- nil, 30, 31, 32, 33, 34, 35, 36, nil, 30,
30
- 31, 32, 33, 34, 35, 36, 8, 7, 8, 7,
31
- 8, 7, 5, 6, 5, 6, 5, 6, 8, 7,
32
- 8, 7, nil, nil, 5, 6, 5, 6 ]
25
+ 8, 7, 9, 36, 5, 6, 8, 7, 27, 10,
26
+ 5, 6, 12, 13, 18, 29, 30, 31, 32, 33,
27
+ 34, 35, 8, 7, 19, 36, 5, 6, 18, 8,
28
+ 7, 38, 36, 5, 6, 23, 24, 29, 30, 31,
29
+ 32, 33, 34, 35, 29, 30, 31, 32, 33, 34,
30
+ 35, 8, 7, 8, 7, 5, 6, 5, 6, 8,
31
+ 7, 8, 7, 5, 6, 5, 6, 8, 7, 25,
32
+ 37, 5, 6, 41, 42, 44 ]
33
33
 
34
34
  racc_action_check = [
35
- 25, 25, 0, 0, 1, 25, 25, 25, 0, 0,
36
- 25, 2, 4, 5, 8, 9, 17, 25, 25, 25,
37
- 25, 25, 25, 25, 28, 28, 20, 21, 22, 28,
38
- 28, 28, 40, 40, 24, 28, 39, 40, 40, 40,
39
- nil, 28, 28, 28, 28, 28, 28, 28, nil, 40,
40
- 40, 40, 40, 40, 40, 40, 3, 3, 6, 6,
41
- 7, 7, 3, 3, 6, 6, 7, 7, 10, 10,
42
- 13, 13, nil, nil, 10, 10, 13, 13 ]
35
+ 25, 25, 1, 25, 25, 25, 0, 0, 25, 2,
36
+ 0, 0, 4, 5, 8, 25, 25, 25, 25, 25,
37
+ 25, 25, 27, 27, 9, 27, 27, 27, 17, 40,
38
+ 40, 27, 40, 40, 40, 18, 21, 27, 27, 27,
39
+ 27, 27, 27, 27, 40, 40, 40, 40, 40, 40,
40
+ 40, 3, 3, 6, 6, 3, 3, 6, 6, 7,
41
+ 7, 10, 10, 7, 7, 10, 10, 13, 13, 23,
42
+ 26, 13, 13, 38, 39, 42 ]
43
43
 
44
44
  racc_action_pointer = [
45
- -1, 4, 9, 53, -5, -2, 55, 57, 3, 15,
46
- 65, nil, nil, 67, nil, nil, nil, 10, nil, nil,
47
- 10, 15, 10, nil, 23, -3, nil, nil, 21, nil,
48
- nil, nil, nil, nil, nil, nil, nil, nil, nil, 22,
49
- 29, nil, nil ]
45
+ 3, 2, 7, 48, -3, 0, 50, 56, 5, 24,
46
+ 58, nil, nil, 64, nil, nil, nil, 19, 30, nil,
47
+ nil, 22, nil, 53, nil, -3, 60, 19, nil, nil,
48
+ nil, nil, nil, nil, nil, nil, nil, nil, 63, 62,
49
+ 26, nil, 65, nil, nil ]
50
50
 
51
51
  racc_action_default = [
52
52
  -28, -28, -2, -4, -6, -28, -28, -28, -10, -28,
53
- -28, -3, -5, -28, -8, -9, -11, -28, 43, -1,
54
- -28, -28, -28, -7, -13, -28, -12, -14, -28, -19,
55
- -20, -21, -22, -23, -24, -25, -26, -27, -15, -28,
56
- -18, -16, -17 ]
53
+ -28, -3, -5, -28, -8, -9, -11, -13, -28, 45,
54
+ -1, -28, -12, -28, -7, -28, -28, -28, -19, -20,
55
+ -21, -22, -23, -24, -25, -26, -27, -14, -28, -28,
56
+ -18, -15, -28, -17, -16 ]
57
57
 
58
58
  racc_goto_table = [
59
- 14, 15, 16, 39, 1, 11, 21, 20, 27, nil,
60
- nil, nil, nil, nil, 19, 42, nil, nil, 26, 29,
61
- nil, nil, 29, nil, nil, nil, nil, nil, nil, nil,
62
- nil, nil, nil, nil, 29 ]
59
+ 14, 15, 39, 1, 11, 16, 26, 21, nil, nil,
60
+ nil, nil, nil, 20, 22, 43, nil, nil, nil, 28,
61
+ nil, 28, nil, nil, nil, nil, nil, nil, nil, nil,
62
+ nil, nil, nil, nil, 28 ]
63
63
 
64
64
  racc_goto_check = [
65
- 3, 3, 5, 8, 1, 2, 6, 3, 7, nil,
66
- nil, nil, nil, nil, 1, 8, nil, nil, 5, 3,
67
- nil, nil, 3, nil, nil, nil, nil, nil, nil, nil,
65
+ 3, 3, 8, 1, 2, 5, 7, 3, nil, nil,
66
+ nil, nil, nil, 1, 5, 8, nil, nil, nil, 3,
67
+ nil, 3, nil, nil, nil, nil, nil, nil, nil, nil,
68
68
  nil, nil, nil, nil, 3 ]
69
69
 
70
70
  racc_goto_pointer = [
71
- nil, 4, 2, -6, nil, -6, -11, -17, -25 ]
71
+ nil, 3, 1, -6, nil, -3, nil, -19, -25 ]
72
72
 
73
73
  racc_goto_default = [
74
- nil, nil, 2, 3, 4, nil, nil, 40, nil ]
74
+ nil, nil, 2, 3, 4, nil, 17, 40, nil ]
75
75
 
76
76
  racc_reduce_table = [
77
77
  0, 0, :racc_error,
78
- 3, 28, :_reduce_1,
79
- 1, 28, :_reduce_2,
80
- 2, 29, :_reduce_3,
81
- 1, 29, :_reduce_4,
82
- 2, 30, :_reduce_5,
83
- 1, 30, :_reduce_6,
84
- 4, 30, :_reduce_7,
85
- 2, 30, :_reduce_8,
86
- 2, 30, :_reduce_9,
87
- 1, 31, :_reduce_10,
88
- 2, 31, :_reduce_11,
89
- 4, 32, :_reduce_12,
90
- 3, 32, :_reduce_13,
91
- 3, 33, :_reduce_14,
92
- 4, 33, :_reduce_15,
93
- 5, 33, :_reduce_16,
94
- 2, 35, :_reduce_17,
95
- 1, 35, :_reduce_18,
96
- 1, 34, :_reduce_none,
97
- 1, 34, :_reduce_20,
98
- 1, 34, :_reduce_21,
99
- 1, 34, :_reduce_22,
100
- 1, 34, :_reduce_23,
101
- 1, 34, :_reduce_24,
102
- 1, 34, :_reduce_25,
103
- 1, 34, :_reduce_26,
104
- 1, 34, :_reduce_27 ]
78
+ 3, 26, :_reduce_1,
79
+ 1, 26, :_reduce_2,
80
+ 2, 27, :_reduce_3,
81
+ 1, 27, :_reduce_4,
82
+ 2, 28, :_reduce_5,
83
+ 1, 28, :_reduce_6,
84
+ 4, 28, :_reduce_7,
85
+ 2, 28, :_reduce_8,
86
+ 2, 28, :_reduce_9,
87
+ 1, 29, :_reduce_10,
88
+ 2, 29, :_reduce_11,
89
+ 2, 30, :_reduce_12,
90
+ 1, 30, :_reduce_13,
91
+ 5, 31, :_reduce_14,
92
+ 6, 31, :_reduce_15,
93
+ 7, 31, :_reduce_16,
94
+ 2, 33, :_reduce_17,
95
+ 1, 33, :_reduce_18,
96
+ 1, 32, :_reduce_none,
97
+ 1, 32, :_reduce_20,
98
+ 1, 32, :_reduce_21,
99
+ 1, 32, :_reduce_22,
100
+ 1, 32, :_reduce_23,
101
+ 1, 32, :_reduce_24,
102
+ 1, 32, :_reduce_25,
103
+ 1, 32, :_reduce_26,
104
+ 1, 32, :_reduce_27 ]
105
105
 
106
106
  racc_reduce_n = 28
107
107
 
108
- racc_shift_n = 43
108
+ racc_shift_n = 45
109
109
 
110
110
  racc_token_table = {
111
111
  false => 0,
@@ -113,30 +113,28 @@ racc_token_table = {
113
113
  :tCOMMA => 2,
114
114
  :tNODE_TYPE => 3,
115
115
  :tGOTO_SCOPE => 4,
116
- :tATTRIBUTE => 5,
117
- :tKEY => 6,
118
- :tIDENTIFIER => 7,
119
- :tIDENTIFIER_VALUE => 8,
120
- :tPSEUDO_CLASS => 9,
121
- :tRELATIONSHIP => 10,
122
- :tOPEN_ATTRIBUTE => 11,
123
- :tCLOSE_ATTRIBUTE => 12,
124
- :tOPEN_ARRAY => 13,
125
- :tCLOSE_ARRAY => 14,
126
- :tOPEN_SELECTOR => 15,
127
- :tCLOSE_SELECTOR => 16,
128
- :tPOSITION => 17,
129
- :tOPERATOR => 18,
130
- :tARRAY_VALUE => 19,
131
- :tBOOLEAN => 20,
132
- :tFLOAT => 21,
133
- :tINTEGER => 22,
134
- :tNIL => 23,
135
- :tREGEXP => 24,
136
- :tSTRING => 25,
137
- :tSYMBOL => 26 }
138
-
139
- racc_nt_base = 27
116
+ :tKEY => 5,
117
+ :tIDENTIFIER_VALUE => 6,
118
+ :tPSEUDO_CLASS => 7,
119
+ :tRELATIONSHIP => 8,
120
+ :tOPEN_ATTRIBUTE => 9,
121
+ :tCLOSE_ATTRIBUTE => 10,
122
+ :tOPEN_ARRAY => 11,
123
+ :tCLOSE_ARRAY => 12,
124
+ :tOPEN_SELECTOR => 13,
125
+ :tCLOSE_SELECTOR => 14,
126
+ :tPOSITION => 15,
127
+ :tOPERATOR => 16,
128
+ :tARRAY_VALUE => 17,
129
+ :tBOOLEAN => 18,
130
+ :tFLOAT => 19,
131
+ :tINTEGER => 20,
132
+ :tNIL => 21,
133
+ :tREGEXP => 22,
134
+ :tSTRING => 23,
135
+ :tSYMBOL => 24 }
136
+
137
+ racc_nt_base = 25
140
138
 
141
139
  racc_use_result_var = false
142
140
 
@@ -162,9 +160,7 @@ Racc_token_to_s_table = [
162
160
  "tCOMMA",
163
161
  "tNODE_TYPE",
164
162
  "tGOTO_SCOPE",
165
- "tATTRIBUTE",
166
163
  "tKEY",
167
- "tIDENTIFIER",
168
164
  "tIDENTIFIER_VALUE",
169
165
  "tPSEUDO_CLASS",
170
166
  "tRELATIONSHIP",
@@ -245,23 +241,23 @@ def _reduce_11(val, _values)
245
241
  end
246
242
 
247
243
  def _reduce_12(val, _values)
248
- NodeQuery::Compiler::AttributeList.new(attribute: val[1], rest: val[3])
244
+ NodeQuery::Compiler::AttributeList.new(attribute: val[0], rest: val[1])
249
245
  end
250
246
 
251
247
  def _reduce_13(val, _values)
252
- NodeQuery::Compiler::AttributeList.new(attribute: val[1])
248
+ NodeQuery::Compiler::AttributeList.new(attribute: val[0])
253
249
  end
254
250
 
255
251
  def _reduce_14(val, _values)
256
- NodeQuery::Compiler::Attribute.new(key: val[0], value: val[2], operator: val[1])
252
+ NodeQuery::Compiler::Attribute.new(key: val[1], value: val[3], operator: val[2])
257
253
  end
258
254
 
259
255
  def _reduce_15(val, _values)
260
- NodeQuery::Compiler::Attribute.new(key: val[0], value: NodeQuery::Compiler::ArrayValue.new, operator: val[1])
256
+ NodeQuery::Compiler::Attribute.new(key: val[1], value: NodeQuery::Compiler::ArrayValue.new, operator: val[2])
261
257
  end
262
258
 
263
259
  def _reduce_16(val, _values)
264
- NodeQuery::Compiler::Attribute.new(key: val[0], value: val[3], operator: val[1])
260
+ NodeQuery::Compiler::Attribute.new(key: val[1], value: val[4], operator: val[2])
265
261
  end
266
262
 
267
263
  def _reduce_17(val, _values)
@@ -1,6 +1,6 @@
1
1
  class NodeQueryParser
2
2
  options no_result_var
3
- token tCOMMA tNODE_TYPE tGOTO_SCOPE tATTRIBUTE tKEY tIDENTIFIER tIDENTIFIER_VALUE tPSEUDO_CLASS tRELATIONSHIP
3
+ token tCOMMA tNODE_TYPE tGOTO_SCOPE tKEY tIDENTIFIER_VALUE tPSEUDO_CLASS tRELATIONSHIP
4
4
  tOPEN_ATTRIBUTE tCLOSE_ATTRIBUTE tOPEN_ARRAY tCLOSE_ARRAY tOPEN_SELECTOR tCLOSE_SELECTOR tPOSITION
5
5
  tOPERATOR tARRAY_VALUE tBOOLEAN tFLOAT tINTEGER tNIL tREGEXP tSTRING tSYMBOL
6
6
  rule
@@ -24,13 +24,13 @@ rule
24
24
  | tNODE_TYPE attribute_list { NodeQuery::Compiler::BasicSelector.new(node_type: val[0], attribute_list: val[1]) }
25
25
 
26
26
  attribute_list
27
- : tOPEN_ATTRIBUTE attribute tCLOSE_ATTRIBUTE attribute_list { NodeQuery::Compiler::AttributeList.new(attribute: val[1], rest: val[3]) }
28
- | tOPEN_ATTRIBUTE attribute tCLOSE_ATTRIBUTE { NodeQuery::Compiler::AttributeList.new(attribute: val[1]) }
27
+ : attribute attribute_list { NodeQuery::Compiler::AttributeList.new(attribute: val[0], rest: val[1]) }
28
+ | attribute { NodeQuery::Compiler::AttributeList.new(attribute: val[0]) }
29
29
 
30
30
  attribute
31
- : tKEY tOPERATOR value { NodeQuery::Compiler::Attribute.new(key: val[0], value: val[2], operator: val[1]) }
32
- | tKEY tOPERATOR tOPEN_ARRAY tCLOSE_ARRAY { NodeQuery::Compiler::Attribute.new(key: val[0], value: NodeQuery::Compiler::ArrayValue.new, operator: val[1]) }
33
- | tKEY tOPERATOR tOPEN_ARRAY array_value tCLOSE_ARRAY { NodeQuery::Compiler::Attribute.new(key: val[0], value: val[3], operator: val[1]) }
31
+ : tOPEN_ATTRIBUTE tKEY tOPERATOR value tCLOSE_ATTRIBUTE { NodeQuery::Compiler::Attribute.new(key: val[1], value: val[3], operator: val[2]) }
32
+ | tOPEN_ATTRIBUTE tKEY tOPERATOR tOPEN_ARRAY tCLOSE_ARRAY tCLOSE_ATTRIBUTE { NodeQuery::Compiler::Attribute.new(key: val[1], value: NodeQuery::Compiler::ArrayValue.new, operator: val[2]) }
33
+ | tOPEN_ATTRIBUTE tKEY tOPERATOR tOPEN_ARRAY array_value tCLOSE_ARRAY tCLOSE_ATTRIBUTE { NodeQuery::Compiler::Attribute.new(key: val[1], value: val[4], operator: val[2]) }
34
34
 
35
35
  array_value
36
36
  : value array_value { NodeQuery::Compiler::ArrayValue.new(value: val[0], rest: val[1]) }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: node_query
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.8
4
+ version: 1.13.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-28 00:00:00.000000000 Z
11
+ date: 2023-08-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: ast node query language
14
14
  email:
@@ -78,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
78
  - !ruby/object:Gem::Version
79
79
  version: '0'
80
80
  requirements: []
81
- rubygems_version: 3.4.13
81
+ rubygems_version: 3.4.17
82
82
  signing_key:
83
83
  specification_version: 4
84
84
  summary: ast node query language