ascode 0.3.2 → 0.4.0
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/README.md +6 -4
- data/lib/ascode/functions.rb +5 -7
- data/lib/ascode/parser.rb +15 -3
- 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: 5cd39a387db21b65e74bf8617268f265998de21ad229e34bd39c035ac340fcbc
|
4
|
+
data.tar.gz: 92a4c0f8331707b07e71956960c706a34d64f4ba08cb055b5038d5378bd07f45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14a8a972f71267ff6f38d01903d79f3848f49dea8434dd6af168e72645a2e17fbc09e72da1d3662e6df1350f869b4f2552b2ef7d44181166071fe950a7e0ae86
|
7
|
+
data.tar.gz: 75adb189e94e30df9459dbacc96f537659658a7ab30e9831eddab6d6f8a6b957951c8cdb12d99eaa9fc315da3de5c33ddd553cdf113a180cb45d17e340dc941c
|
data/README.md
CHANGED
@@ -25,12 +25,14 @@ At this moment, the only way to play with `ascode` is `irb`.
|
|
25
25
|
|
26
26
|
```bash
|
27
27
|
$ irb
|
28
|
-
irb(main):001:0> require
|
28
|
+
irb(main):001:0> require "ascode"
|
29
29
|
=> true
|
30
|
-
irb(main):002:0> Ascode.run '
|
31
|
-
Number:
|
30
|
+
irb(main):002:0> Ascode.run 'ê["Even"~"Odd"]"It is "+'
|
32
31
|
10
|
33
|
-
Even
|
32
|
+
It is Even
|
33
|
+
irb(main):003:0> Ascode.run "1.1*"
|
34
|
+
5
|
35
|
+
5.5
|
34
36
|
```
|
35
37
|
|
36
38
|
### Features
|
data/lib/ascode/functions.rb
CHANGED
@@ -5,9 +5,10 @@ module Ascode
|
|
5
5
|
def initialize
|
6
6
|
@csv_data = []
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
filename = File.join(File.dirname(__FILE__), "functions.md")
|
9
|
+
File.open(filename, "r") do |file|
|
10
|
+
read_csv file
|
11
|
+
end
|
11
12
|
|
12
13
|
@csv_data.delete_at 0
|
13
14
|
@csv_data.delete_at 0
|
@@ -19,10 +20,7 @@ module Ascode
|
|
19
20
|
|
20
21
|
@csv_data.push(
|
21
22
|
short: clear_quotes(src[0]),
|
22
|
-
long: clear_quotes(src[1])
|
23
|
-
pop: clear_quotes(src[2]),
|
24
|
-
push: clear_quotes(src[3]),
|
25
|
-
desc: clear_quotes(src[4])
|
23
|
+
long: clear_quotes(src[1])
|
26
24
|
)
|
27
25
|
end
|
28
26
|
end
|
data/lib/ascode/parser.rb
CHANGED
@@ -14,6 +14,8 @@ module Ascode
|
|
14
14
|
@ast = []
|
15
15
|
@push_buffer = false
|
16
16
|
@skip_chars = 0
|
17
|
+
@is_quoted = false
|
18
|
+
@escape = false
|
17
19
|
@implicit_output = @do_implicit_output
|
18
20
|
|
19
21
|
@code.split("").to_enum.each_with_index do |char, index|
|
@@ -86,17 +88,27 @@ module Ascode
|
|
86
88
|
end
|
87
89
|
|
88
90
|
def parse_character(char, index)
|
89
|
-
if char == "
|
91
|
+
if char == "\\"
|
92
|
+
@escape = true
|
93
|
+
return
|
94
|
+
end
|
95
|
+
|
96
|
+
if char == "\"" && !@escape
|
97
|
+
ast_add_buffer if @is_quoted
|
98
|
+
@is_quoted = !@is_quoted
|
99
|
+
elsif @is_quoted || char =~ /[0-9.]/
|
100
|
+
buffer_push char
|
101
|
+
elsif char == "["
|
90
102
|
end_index = parse_condition_block index
|
91
103
|
@skip_chars = end_index - index
|
92
|
-
elsif char =~ /[\w.,:;!?]/
|
93
|
-
buffer_push char
|
94
104
|
elsif char == " "
|
95
105
|
ast_add_buffer
|
96
106
|
else
|
97
107
|
ast_add_buffer
|
98
108
|
parse_function char
|
99
109
|
end
|
110
|
+
|
111
|
+
@escape = false
|
100
112
|
end
|
101
113
|
|
102
114
|
def parse_function(char)
|