synvert-core 1.0.1 → 1.0.4
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: e0554ef349e1fe725c68cd277b40751ca7373b04fe118313bf70fdf307852e01
|
4
|
+
data.tar.gz: 283a4ca6bf2d0fc09ba1f63bb5831524dc0634184072c340d7092a9253a93700
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9152e5eea03cbc9a842fdad557cc8ea9ecb2e7d3dc3480708b886100393c0167a804f3cd0f4fd5aca968c4992ce85b0b604d36ab6beabe9ac4023e6102e2c05e
|
7
|
+
data.tar.gz: 4b35baab2ebe3c76a9151e0148dc185a8e6776d4dd6ece7abcd2cb3cd4ad21bc63b5cc68b75d6410827ef9089bf52fc6871bacb1e44c39cffce36faef07b9a8f
|
@@ -11,14 +11,14 @@ 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
23
|
SINGLE_QUOTE_STRING /'(.+?)'/
|
24
24
|
DOUBLE_QUOTE_STRING /"(.+?)"/
|
@@ -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,14 +24,14 @@ 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
36
|
SINGLE_QUOTE_STRING = /'(.+?)'/
|
37
37
|
DOUBLE_QUOTE_STRING = /"(.+?)"/
|
@@ -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
@@ -139,6 +139,54 @@ module Synvert::Core::NodeQuery
|
|
139
139
|
assert_tokens source, expected_tokens
|
140
140
|
end
|
141
141
|
|
142
|
+
it 'identifier can contain ?' do
|
143
|
+
source = '.send[message=empty?]'
|
144
|
+
expected_tokens = [
|
145
|
+
[:tNODE_TYPE, "send"],
|
146
|
+
[:tOPEN_ATTRIBUTE, "["],
|
147
|
+
[:tKEY, "message"],
|
148
|
+
[:tEQUAL, "="],
|
149
|
+
[:tIDENTIFIER_VALUE, "empty?"],
|
150
|
+
[:tCLOSE_ATTRIBUTE, "]"]
|
151
|
+
]
|
152
|
+
assert_tokens source, expected_tokens
|
153
|
+
end
|
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
|
+
|
142
190
|
it 'matches attribute value' do
|
143
191
|
source = '.pair[key={{value}}]'
|
144
192
|
expected_tokens = [
|