ascode 0.5.3 → 0.5.4
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 +4 -4
- data/lib/ascode/parser/condition_block.rb +15 -4
- data/lib/ascode/parser/literal.rb +2 -1
- data/lib/ascode/parser/main.rb +4 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56d53aec79abb0959c5e34c61b0f537013168b6ad79bde7a2480472f5259b7a1
|
4
|
+
data.tar.gz: b574b6f1f4ff79a222a11a482dead059dd1a1f8f78b3f5eef6d0c5130584286e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16b9ce147aa1a3cdfa24f46884ba9a0d6a16e0c4650a55dab82f30d90360a877aabfc996ad11bd022c37adc9b62ec4779a16c45df197651f2d2658ddd5309a12
|
7
|
+
data.tar.gz: dd356e67eba3f008bba0a8e1838f0b45171be8ce2c08e8b7a972e2b44f92cea402fff096df928b1d90e6e74ee075adbcbc385a84d2416826189726f1e6e667a0
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require_relative "literal"
|
2
|
+
|
1
3
|
module Ascode
|
2
4
|
module Parser
|
3
5
|
class ConditionBlock
|
@@ -26,12 +28,21 @@ module Ascode
|
|
26
28
|
end
|
27
29
|
|
28
30
|
def find(what)
|
29
|
-
# TODO: Ignore '[', ':', ']' when in string
|
30
31
|
level = 0
|
32
|
+
skip = 0
|
31
33
|
@block.split("").to_enum.each_with_index do |char, index|
|
32
|
-
|
33
|
-
|
34
|
-
|
34
|
+
if skip > 0
|
35
|
+
skip -= 1
|
36
|
+
next
|
37
|
+
elsif char == "\""
|
38
|
+
literal = Literal.new @block, index
|
39
|
+
literal.parse
|
40
|
+
skip = literal.length
|
41
|
+
else
|
42
|
+
return index if char == what && level.zero?
|
43
|
+
level += 1 if char == "["
|
44
|
+
level -= 1 if char == "]"
|
45
|
+
end
|
35
46
|
end
|
36
47
|
|
37
48
|
-1
|
@@ -3,7 +3,7 @@ require_relative "../converter"
|
|
3
3
|
module Ascode
|
4
4
|
module Parser
|
5
5
|
class Literal
|
6
|
-
attr_reader :
|
6
|
+
attr_reader :length
|
7
7
|
|
8
8
|
def initialize(code, literal_begin)
|
9
9
|
@code = code
|
@@ -19,6 +19,7 @@ module Ascode
|
|
19
19
|
@literal = @literal[0..(@end - 1)]
|
20
20
|
|
21
21
|
@literal = Converter.convert @literal
|
22
|
+
@length = @literal.to_s.length + (@quoted ? 1 : -1)
|
22
23
|
ast
|
23
24
|
end
|
24
25
|
|
data/lib/ascode/parser/main.rb
CHANGED
@@ -32,10 +32,8 @@ module Ascode
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def character(char, index)
|
35
|
-
if char == "\""
|
36
|
-
literal
|
37
|
-
elsif char =~ /[0-9.]/
|
38
|
-
literal(index, true)
|
35
|
+
if char == "\"" || char =~ /[0-9.]/
|
36
|
+
literal index
|
39
37
|
elsif char == "["
|
40
38
|
block index
|
41
39
|
else
|
@@ -43,12 +41,10 @@ module Ascode
|
|
43
41
|
end
|
44
42
|
end
|
45
43
|
|
46
|
-
def literal(index
|
47
|
-
add = num ? -1 : 1
|
48
|
-
|
44
|
+
def literal(index)
|
49
45
|
literal = Literal.new @code, index
|
50
46
|
@ast.push literal.parse
|
51
|
-
@skip_chars = literal.
|
47
|
+
@skip_chars = literal.length
|
52
48
|
end
|
53
49
|
|
54
50
|
def block(index)
|