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: f889cb977b7bf6e847bdeeac011ee0d23210ae8db7a0652e8c00d5d98c72a701
4
- data.tar.gz: 46d220401cc8c9c0422428c2915862148b4ad8dc236f637ed52dbc45207de742
3
+ metadata.gz: e0554ef349e1fe725c68cd277b40751ca7373b04fe118313bf70fdf307852e01
4
+ data.tar.gz: 283a4ca6bf2d0fc09ba1f63bb5831524dc0634184072c340d7092a9253a93700
5
5
  SHA512:
6
- metadata.gz: 926df3dd8aa3689938e90c530fb432e0703cff2f89f35f46950b3630eb98b8da6de0e0d5eb75c5c24262f3712400d4570ac05abd5ebbbe6c6954d6c997048432
7
- data.tar.gz: 321fb626763ca31e6156c462bb6846ce73d00639a620b0b7048b024fbe50d14f63f6d3209e3a534b0475c29c29e74dcf0a7c204f14ad0927244bd5cbb157b3d6
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Synvert
4
4
  module Core
5
- VERSION = '1.0.1'
5
+ VERSION = '1.0.4'
6
6
  end
7
7
  end
@@ -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 = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: synvert-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang