ascode 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/ascode/{parser/functions.md → functions.md} +3 -1
- data/lib/ascode/interpreter/environment.rb +11 -2
- data/lib/ascode/parser/function.rb +1 -1
- 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: efc87f91a3f7fe8066e6899401d7401f31530fac3a24369d1beff0d38eb65234
|
4
|
+
data.tar.gz: 89cbb7f57e4bbaf5db8c5b1315e2f033265b62c0f413e2239b4b992e71d3703c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03ecf1fb448b88373fa111500acb703d050c88f5e61a19f0cdaf1c9447920f9a919a50193599dfe5a5639533aaa1e18ad83a3776c1fe0f1e29b66e4007d684ff
|
7
|
+
data.tar.gz: 7cb80f53c982fd467f776223ef5c6358bee51cf63d73210d0c54e2944d67922b803017f935203241269c3e0f2ba990e90da5cb8e37774765b9c233122d18b4bc
|
data/README.md
CHANGED
@@ -17,8 +17,8 @@ gem install ascode
|
|
17
17
|
|
18
18
|
###### Run
|
19
19
|
|
20
|
-
> Function reference is available in [`lib/ascode/
|
21
|
-
`](https://github.com/sudoio/ascode/blob/master/lib/ascode/
|
20
|
+
> Function reference is available in [`lib/ascode/functions.md
|
21
|
+
`](https://github.com/sudoio/ascode/blob/master/lib/ascode/functions.md).
|
22
22
|
|
23
23
|
```bash
|
24
24
|
$ ascode '"Number: "Oe["Even":"Odd"]O'
|
@@ -11,8 +11,10 @@ Character|Type|Name|`pop`s|`push`es|Description
|
|
11
11
|
Character|Type|Name|`pop`s|`push`es|Description
|
12
12
|
---|---|---|---|---|---
|
13
13
|
`P`|`env`|`pop`|`a`||
|
14
|
+
`C`|`env`|`reg_copy`|`a`||`a` -> `Register`
|
15
|
+
`V`|`env`|`reg_paste`||`a`|`Register` -> `a`
|
14
16
|
`S`|`env`|`swap`|`a`, `b`|`a`, `b`|Swaps first two elements in the stack
|
15
|
-
`
|
17
|
+
`D`|`env`|`duplicate`|`a`|`a`, `a`|Duplicates first element in the stack
|
16
18
|
|
17
19
|
#### Condition
|
18
20
|
|
@@ -3,17 +3,26 @@ require_relative "io"
|
|
3
3
|
module Ascode
|
4
4
|
module Interpreter
|
5
5
|
class Environment
|
6
|
-
attr_accessor :ast, :stack
|
6
|
+
attr_accessor :ast, :stack, :register
|
7
7
|
|
8
8
|
def initialize(ast = "")
|
9
9
|
@ast = ast
|
10
10
|
@stack = []
|
11
|
+
@register = nil
|
11
12
|
end
|
12
13
|
|
13
14
|
def push(what)
|
14
15
|
@stack.push what
|
15
16
|
end
|
16
17
|
|
18
|
+
def reg_copy
|
19
|
+
@register = pop
|
20
|
+
end
|
21
|
+
|
22
|
+
def reg_paste
|
23
|
+
push @register
|
24
|
+
end
|
25
|
+
|
17
26
|
def pop(ask = true)
|
18
27
|
value = @stack.pop
|
19
28
|
if value
|
@@ -31,7 +40,7 @@ module Ascode
|
|
31
40
|
push b
|
32
41
|
end
|
33
42
|
|
34
|
-
def
|
43
|
+
def duplicate
|
35
44
|
a = pop false
|
36
45
|
push a
|
37
46
|
push a
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ascode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Artem Varaksa
|
@@ -23,6 +23,7 @@ files:
|
|
23
23
|
- bin/ascode
|
24
24
|
- lib/ascode.rb
|
25
25
|
- lib/ascode/converter.rb
|
26
|
+
- lib/ascode/functions.md
|
26
27
|
- lib/ascode/interpreter/condition.rb
|
27
28
|
- lib/ascode/interpreter/environment.rb
|
28
29
|
- lib/ascode/interpreter/io.rb
|
@@ -30,7 +31,6 @@ files:
|
|
30
31
|
- lib/ascode/interpreter/math.rb
|
31
32
|
- lib/ascode/parser/condition_block.rb
|
32
33
|
- lib/ascode/parser/function.rb
|
33
|
-
- lib/ascode/parser/functions.md
|
34
34
|
- lib/ascode/parser/literal.rb
|
35
35
|
- lib/ascode/parser/main.rb
|
36
36
|
homepage: https://github.com/sudoio/ascode
|