synvert-core 1.0.2 → 1.0.5
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a19f84568d17d7d51bf4f4486a7f95a299261c25eacd5ff57faea07fd597bc26
|
4
|
+
data.tar.gz: 8dce2d09629733e239046581aa03433a7231cf8094ba0e1aec99f1df7ec0f867
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a731bae510193fccf6c5682ff7559e7610b7774af5e2d0a196bad1ed838f84c5700e9dfcb123d0314b2ac40034d6246cd676b9e60e01f148ed17e6c32f1bc90
|
7
|
+
data.tar.gz: 15fad0af1dce17af70f2b3a8ab1af3827f57892437076ddda86acdde19f7b24691b05c5c7b064ef33985815e0fdb0eb7fc4ad29924433c955067ee715f302138
|
@@ -11,17 +11,17 @@ macros
|
|
11
11
|
CLOSE_DYNAMIC_ATTRIBUTE /}}/
|
12
12
|
NODE_TYPE /\.[a-z]+/
|
13
13
|
IDENTIFIER /[\.\w]+/
|
14
|
-
IDENTIFIER_VALUE /[\.\w
|
14
|
+
IDENTIFIER_VALUE /[\.\w!&:\?<>=]+/
|
15
15
|
FALSE /false/
|
16
16
|
FLOAT /\d+\.\d+/
|
17
17
|
INTEGER /\d+/
|
18
18
|
NIL /nil/
|
19
19
|
REGEXP_BODY /(?:[^\/]|\\\/)*/
|
20
20
|
REGEXP /\/(#{REGEXP_BODY})(?<!\\)\/([imxo]*)/
|
21
|
-
SYMBOL /:[\w
|
21
|
+
SYMBOL /:[\w!\?<>=]+/
|
22
22
|
TRUE /true/
|
23
|
-
SINGLE_QUOTE_STRING /'(
|
24
|
-
DOUBLE_QUOTE_STRING /"(
|
23
|
+
SINGLE_QUOTE_STRING /'(.*?)'/
|
24
|
+
DOUBLE_QUOTE_STRING /"(.*?)"/
|
25
25
|
|
26
26
|
rules
|
27
27
|
|
@@ -66,9 +66,6 @@ rules
|
|
66
66
|
:VALUE /#{DOUBLE_QUOTE_STRING}/ { [:tSTRING, text[1...-1]] }
|
67
67
|
:VALUE /#{SINGLE_QUOTE_STRING}/ { [:tSTRING, text[1...-1]] }
|
68
68
|
:VALUE /#{NODE_TYPE}/ { [:tNODE_TYPE, text[1..]] }
|
69
|
-
:VALUE />/ { [:tCHILD, text] }
|
70
|
-
:VALUE /~/ { [:tSUBSEQUENT_SIBLING, text] }
|
71
|
-
:VALUE /\+/ { [:tNEXT_SIBLING, text] }
|
72
69
|
:VALUE /#{OPEN_ATTRIBUTE}/ { @nested_count += 1; @state = :KEY; [:tOPEN_ATTRIBUTE, text] }
|
73
70
|
:VALUE /#{IDENTIFIER_VALUE}/ { [:tIDENTIFIER_VALUE, text] }
|
74
71
|
:DYNAMIC_ATTRIBUTE /#{CLOSE_DYNAMIC_ATTRIBUTE}/ { @state = :VALUE; [:tCLOSE_DYNAMIC_ATTRIBUTE, text] }
|
@@ -24,17 +24,17 @@ class Synvert::Core::NodeQuery::Lexer
|
|
24
24
|
CLOSE_DYNAMIC_ATTRIBUTE = /}}/
|
25
25
|
NODE_TYPE = /\.[a-z]+/
|
26
26
|
IDENTIFIER = /[\.\w]+/
|
27
|
-
IDENTIFIER_VALUE = /[\.\w
|
27
|
+
IDENTIFIER_VALUE = /[\.\w!&:\?<>=]+/
|
28
28
|
FALSE = /false/
|
29
29
|
FLOAT = /\d+\.\d+/
|
30
30
|
INTEGER = /\d+/
|
31
31
|
NIL = /nil/
|
32
32
|
REGEXP_BODY = /(?:[^\/]|\\\/)*/
|
33
33
|
REGEXP = /\/(#{REGEXP_BODY})(?<!\\)\/([imxo]*)/
|
34
|
-
SYMBOL = /:[\w
|
34
|
+
SYMBOL = /:[\w!\?<>=]+/
|
35
35
|
TRUE = /true/
|
36
|
-
SINGLE_QUOTE_STRING = /'(
|
37
|
-
DOUBLE_QUOTE_STRING = /"(
|
36
|
+
SINGLE_QUOTE_STRING = /'(.*?)'/
|
37
|
+
DOUBLE_QUOTE_STRING = /"(.*?)"/
|
38
38
|
# :startdoc:
|
39
39
|
# :stopdoc:
|
40
40
|
class LexerError < StandardError ; end
|
@@ -215,12 +215,6 @@ class Synvert::Core::NodeQuery::Lexer
|
|
215
215
|
action { [:tSTRING, text[1...-1]] }
|
216
216
|
when text = ss.scan(/#{NODE_TYPE}/) then
|
217
217
|
action { [:tNODE_TYPE, text[1..]] }
|
218
|
-
when text = ss.scan(/>/) then
|
219
|
-
action { [:tCHILD, text] }
|
220
|
-
when text = ss.scan(/~/) then
|
221
|
-
action { [:tSUBSEQUENT_SIBLING, text] }
|
222
|
-
when text = ss.scan(/\+/) then
|
223
|
-
action { [:tNEXT_SIBLING, text] }
|
224
218
|
when text = ss.scan(/#{OPEN_ATTRIBUTE}/) then
|
225
219
|
action { @nested_count += 1; @state = :KEY; [:tOPEN_ATTRIBUTE, text] }
|
226
220
|
when text = ss.scan(/#{IDENTIFIER_VALUE}/) then
|
data/lib/synvert/core/version.rb
CHANGED
@@ -152,6 +152,54 @@ module Synvert::Core::NodeQuery
|
|
152
152
|
assert_tokens source, expected_tokens
|
153
153
|
end
|
154
154
|
|
155
|
+
it 'identifier can contain <, >, =' do
|
156
|
+
source = '.send[message=<]'
|
157
|
+
expected_tokens = [
|
158
|
+
[:tNODE_TYPE, "send"],
|
159
|
+
[:tOPEN_ATTRIBUTE, "["],
|
160
|
+
[:tKEY, "message"],
|
161
|
+
[:tEQUAL, "="],
|
162
|
+
[:tIDENTIFIER_VALUE, "<"],
|
163
|
+
[:tCLOSE_ATTRIBUTE, "]"]
|
164
|
+
]
|
165
|
+
assert_tokens source, expected_tokens
|
166
|
+
|
167
|
+
source = '.send[message==]'
|
168
|
+
expected_tokens = [
|
169
|
+
[:tNODE_TYPE, "send"],
|
170
|
+
[:tOPEN_ATTRIBUTE, "["],
|
171
|
+
[:tKEY, "message"],
|
172
|
+
[:tEQUAL, "="],
|
173
|
+
[:tIDENTIFIER_VALUE, "="],
|
174
|
+
[:tCLOSE_ATTRIBUTE, "]"]
|
175
|
+
]
|
176
|
+
assert_tokens source, expected_tokens
|
177
|
+
|
178
|
+
source = '.send[message=>]'
|
179
|
+
expected_tokens = [
|
180
|
+
[:tNODE_TYPE, "send"],
|
181
|
+
[:tOPEN_ATTRIBUTE, "["],
|
182
|
+
[:tKEY, "message"],
|
183
|
+
[:tEQUAL, "="],
|
184
|
+
[:tIDENTIFIER_VALUE, ">"],
|
185
|
+
[:tCLOSE_ATTRIBUTE, "]"]
|
186
|
+
]
|
187
|
+
assert_tokens source, expected_tokens
|
188
|
+
end
|
189
|
+
|
190
|
+
it 'matches empty string' do
|
191
|
+
source = ".send[arguments.first='']"
|
192
|
+
expected_tokens = [
|
193
|
+
[:tNODE_TYPE, "send"],
|
194
|
+
[:tOPEN_ATTRIBUTE, "["],
|
195
|
+
[:tKEY, "arguments.first"],
|
196
|
+
[:tEQUAL, "="],
|
197
|
+
[:tSTRING, ""],
|
198
|
+
[:tCLOSE_ATTRIBUTE, "]"]
|
199
|
+
]
|
200
|
+
assert_tokens source, expected_tokens
|
201
|
+
end
|
202
|
+
|
155
203
|
it 'matches attribute value' do
|
156
204
|
source = '.pair[key={{value}}]'
|
157
205
|
expected_tokens = [
|
@@ -108,6 +108,11 @@ module Synvert::Core::NodeQuery
|
|
108
108
|
assert_parser(source)
|
109
109
|
end
|
110
110
|
|
111
|
+
it 'parses empty string' do
|
112
|
+
source = '.send[arguments.first=""]'
|
113
|
+
assert_parser(source)
|
114
|
+
end
|
115
|
+
|
111
116
|
describe '#query_nodes' do
|
112
117
|
let(:node) {
|
113
118
|
parse(<<~EOS)
|