node_query 1.13.9 → 1.13.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +2 -2
- data/lib/node_query/helper.rb +14 -9
- data/lib/node_query/version.rb +1 -1
- data/lib/node_query_parser.racc.rb +89 -93
- data/lib/node_query_parser.y +6 -6
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d162f1ed40046054e6b68d3b89341508485ca005541c16408c632f86f205a818
|
4
|
+
data.tar.gz: 191962526bb18daa93b6e506181c99d211cdc3273fe861d4e6aec699720b5557
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a3ed7084d7268f5e4aef354fd5b49abec8e255ca542a755992eabb705402e23eabfead3d16b37a6b451c63c5703bdf2f24da59be8bbdbbe9b623e02b44dcf9f
|
7
|
+
data.tar.gz: 00d10e20a2a6cbc4db6340bdc01f77a543361e689cc877fbb5923f996306c51301cd40612fbf9d6e3928954aa680a0f3055cea6d273dc7043bfaebb960e9cfed
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
node_query (1.13.
|
4
|
+
node_query (1.13.11)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -67,7 +67,7 @@ GEM
|
|
67
67
|
shellany (0.0.1)
|
68
68
|
syntax_tree (6.1.1)
|
69
69
|
prettier_print (>= 1.2.0)
|
70
|
-
syntax_tree_ext (0.6.
|
70
|
+
syntax_tree_ext (0.6.4)
|
71
71
|
syntax_tree
|
72
72
|
thor (1.2.1)
|
73
73
|
|
data/lib/node_query/helper.rb
CHANGED
@@ -33,15 +33,7 @@ class NodeQuery::Helper
|
|
33
33
|
# @yieldparam child [Node] child node
|
34
34
|
def handle_recursive_child(node, &block)
|
35
35
|
NodeQuery.adapter.get_children(node).each do |child|
|
36
|
-
|
37
|
-
block.call(child)
|
38
|
-
handle_recursive_child(child, &block)
|
39
|
-
elsif child.is_a?(Array)
|
40
|
-
child.each do |child_child|
|
41
|
-
block.call(child_child)
|
42
|
-
handle_recursive_child(child_child, &block)
|
43
|
-
end
|
44
|
-
end
|
36
|
+
handle_child(child, &block)
|
45
37
|
end
|
46
38
|
end
|
47
39
|
|
@@ -67,5 +59,18 @@ class NodeQuery::Helper
|
|
67
59
|
|
68
60
|
node.to_s
|
69
61
|
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
def handle_child(node, &block)
|
66
|
+
if NodeQuery.adapter.is_node?(node)
|
67
|
+
block.call(node)
|
68
|
+
handle_recursive_child(node, &block)
|
69
|
+
elsif node.is_a?(Array)
|
70
|
+
node.each do |child_node|
|
71
|
+
handle_child(child_node, &block) unless child_node.nil?
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
70
75
|
end
|
71
76
|
end
|
data/lib/node_query/version.rb
CHANGED
@@ -22,90 +22,90 @@ class NodeQueryParser < Racc::Parser
|
|
22
22
|
##### State transition tables begin ###
|
23
23
|
|
24
24
|
racc_action_table = [
|
25
|
-
8, 7,
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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,
|
36
|
-
|
37
|
-
25, 25,
|
38
|
-
|
39
|
-
|
40
|
-
40,
|
41
|
-
7,
|
42
|
-
|
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
|
-
|
46
|
-
|
47
|
-
|
48
|
-
nil, nil, nil, nil, nil, nil, nil, nil,
|
49
|
-
|
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,
|
54
|
-
-28, -
|
55
|
-
-
|
56
|
-
-18, -
|
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,
|
60
|
-
nil, nil, nil,
|
61
|
-
nil, nil,
|
62
|
-
nil, nil, nil, nil,
|
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,
|
66
|
-
nil, nil, nil,
|
67
|
-
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,
|
71
|
+
nil, 3, 1, -6, nil, -3, nil, -19, -25 ]
|
72
72
|
|
73
73
|
racc_goto_default = [
|
74
|
-
nil, nil, 2, 3, 4, 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,
|
79
|
-
1,
|
80
|
-
2,
|
81
|
-
1,
|
82
|
-
2,
|
83
|
-
1,
|
84
|
-
4,
|
85
|
-
2,
|
86
|
-
2,
|
87
|
-
1,
|
88
|
-
2,
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
2,
|
95
|
-
1,
|
96
|
-
1,
|
97
|
-
1,
|
98
|
-
1,
|
99
|
-
1,
|
100
|
-
1,
|
101
|
-
1,
|
102
|
-
1,
|
103
|
-
1,
|
104
|
-
1,
|
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 =
|
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
|
-
:
|
117
|
-
:
|
118
|
-
:
|
119
|
-
:
|
120
|
-
:
|
121
|
-
:
|
122
|
-
:
|
123
|
-
:
|
124
|
-
:
|
125
|
-
:
|
126
|
-
:
|
127
|
-
:
|
128
|
-
:
|
129
|
-
:
|
130
|
-
:
|
131
|
-
:
|
132
|
-
:
|
133
|
-
:
|
134
|
-
:
|
135
|
-
:
|
136
|
-
|
137
|
-
|
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[
|
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[
|
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[
|
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[
|
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[
|
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)
|
data/lib/node_query_parser.y
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class NodeQueryParser
|
2
2
|
options no_result_var
|
3
|
-
token tCOMMA tNODE_TYPE tGOTO_SCOPE
|
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
|
-
:
|
28
|
-
|
|
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[
|
32
|
-
| tKEY tOPERATOR tOPEN_ARRAY tCLOSE_ARRAY { NodeQuery::Compiler::Attribute.new(key: val[
|
33
|
-
| tKEY tOPERATOR tOPEN_ARRAY array_value tCLOSE_ARRAY { NodeQuery::Compiler::Attribute.new(key: val[
|
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.
|
4
|
+
version: 1.13.11
|
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-08-
|
11
|
+
date: 2023-08-17 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.
|
81
|
+
rubygems_version: 3.4.18
|
82
82
|
signing_key:
|
83
83
|
specification_version: 4
|
84
84
|
summary: ast node query language
|