ascode 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ascode/functions.rb +3 -3
- data/lib/ascode/interpreter.rb +3 -3
- data/lib/ascode/parser.rb +15 -15
- data/lib/ascode.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8e23bc6e653965a74e847c726fd2475c9d80787d36eef439b68a8d4f9ad7f6f
|
4
|
+
data.tar.gz: 2e99a66181a565e217e3820fb18da9a44710dea2e91fb84b6e6dc838b880003d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c8680657e8d13ac141d4f7499f79f522a8b496b86dc28a62f9bc4594f6e3811b493be98a7cadf87f0a5694bb7e5bf02c22f445cd30ed89c990567a84593fa25
|
7
|
+
data.tar.gz: 00fb2ca59f0e7b23d3070b503be1472b338acf6a5cd8be40a6de6d1b9e95c6e673e3112cf488a358094ceb7e7ed49cd3b5290c8f3d43f54a93e5d14241cea51c
|
data/lib/ascode/functions.rb
CHANGED
@@ -5,7 +5,7 @@ module Ascode
|
|
5
5
|
def initialize
|
6
6
|
@csv_data = []
|
7
7
|
|
8
|
-
file = File.open(File.join(File.dirname(__FILE__),
|
8
|
+
file = File.open(File.join(File.dirname(__FILE__), "functions.md"), "r")
|
9
9
|
read_csv file
|
10
10
|
file.close
|
11
11
|
|
@@ -15,7 +15,7 @@ module Ascode
|
|
15
15
|
|
16
16
|
def read_csv(file)
|
17
17
|
until (line = file.gets).nil?
|
18
|
-
src = line.strip.split(
|
18
|
+
src = line.strip.split("|")
|
19
19
|
|
20
20
|
@csv_data.push(
|
21
21
|
short: clear_quotes(src[0]),
|
@@ -29,7 +29,7 @@ module Ascode
|
|
29
29
|
|
30
30
|
def clear_quotes(str)
|
31
31
|
return str unless str
|
32
|
-
str.delete(
|
32
|
+
str.delete("`")
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
data/lib/ascode/interpreter.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative "converter"
|
2
2
|
|
3
3
|
module Ascode
|
4
4
|
class Interpreter
|
@@ -12,9 +12,9 @@ module Ascode
|
|
12
12
|
@ast.each do |action|
|
13
13
|
name = action[:action]
|
14
14
|
|
15
|
-
if name ==
|
15
|
+
if name == "push"
|
16
16
|
push(action[:what])
|
17
|
-
elsif name ==
|
17
|
+
elsif name == "condition"
|
18
18
|
condition_begin action[:true_block], action[:false_block]
|
19
19
|
else
|
20
20
|
send(name)
|
data/lib/ascode/parser.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require_relative
|
2
|
-
require_relative
|
1
|
+
require_relative "functions"
|
2
|
+
require_relative "converter"
|
3
3
|
|
4
4
|
module Ascode
|
5
5
|
class Parser
|
@@ -16,7 +16,7 @@ module Ascode
|
|
16
16
|
@skip_chars = 0
|
17
17
|
@implicit_output = @do_implicit_output
|
18
18
|
|
19
|
-
@code.split(
|
19
|
+
@code.split("").to_enum.each_with_index do |char, index|
|
20
20
|
if @skip_chars > 0
|
21
21
|
@skip_chars -= 1
|
22
22
|
next
|
@@ -26,7 +26,7 @@ module Ascode
|
|
26
26
|
end
|
27
27
|
ast_add_buffer
|
28
28
|
|
29
|
-
ast_add_action
|
29
|
+
ast_add_action "output" if @implicit_output
|
30
30
|
|
31
31
|
@ast
|
32
32
|
end
|
@@ -52,15 +52,15 @@ module Ascode
|
|
52
52
|
false_block_ast = (Parser.new block_code[(split_pos + 1)..-1], false).parse
|
53
53
|
end
|
54
54
|
|
55
|
-
@ast.push(action:
|
55
|
+
@ast.push(action: "condition", true_block: true_block_ast, false_block: false_block_ast )
|
56
56
|
|
57
57
|
end_index + 2
|
58
58
|
end
|
59
59
|
|
60
60
|
def find_block_end(block)
|
61
61
|
end_index = -1
|
62
|
-
block.split(
|
63
|
-
if char ==
|
62
|
+
block.split("").to_enum.with_index.reverse_each do |char, index|
|
63
|
+
if char == "]"
|
64
64
|
end_index = index
|
65
65
|
break
|
66
66
|
end
|
@@ -72,12 +72,12 @@ module Ascode
|
|
72
72
|
def find_block_split(block)
|
73
73
|
level = 0
|
74
74
|
split_pos = -1
|
75
|
-
block.split(
|
76
|
-
if char ==
|
75
|
+
block.split("").to_enum.each_with_index do |char, index|
|
76
|
+
if char == "["
|
77
77
|
level += 1
|
78
|
-
elsif char ==
|
78
|
+
elsif char == "]"
|
79
79
|
level -= 1
|
80
|
-
elsif char ==
|
80
|
+
elsif char == "~" && level.zero?
|
81
81
|
split_pos = index
|
82
82
|
end
|
83
83
|
end
|
@@ -86,12 +86,12 @@ module Ascode
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def parse_character(char, index)
|
89
|
-
if char ==
|
89
|
+
if char == "["
|
90
90
|
end_index = parse_condition_block index
|
91
91
|
@skip_chars = end_index - index
|
92
92
|
elsif char =~ /[\w.,:;!?]/
|
93
93
|
buffer_push char
|
94
|
-
elsif char ==
|
94
|
+
elsif char == " "
|
95
95
|
ast_add_buffer
|
96
96
|
else
|
97
97
|
ast_add_buffer
|
@@ -121,12 +121,12 @@ module Ascode
|
|
121
121
|
|
122
122
|
@push_buffer = Converter.convert @push_buffer
|
123
123
|
|
124
|
-
ast_add_action
|
124
|
+
ast_add_action "push", @push_buffer
|
125
125
|
@push_buffer = false
|
126
126
|
end
|
127
127
|
|
128
128
|
def ast_add_action(name, what = nil)
|
129
|
-
@implicit_output = false if name ==
|
129
|
+
@implicit_output = false if name == "output"
|
130
130
|
|
131
131
|
data = { action: name }
|
132
132
|
data[:what] = what if what
|
data/lib/ascode.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ascode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Artem Varaksa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Esoteric golfing language. In active development, so behavior may be
|
14
14
|
changed without prior notice.
|