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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a14bfef61961e4ccc91ad40f9e695ec5c66e7ca58038075daeeef24ce1c9d131
4
- data.tar.gz: d60742f61e14b47908f9a60b223840d392206f08f5c565fed9b95d9acc6b4592
3
+ metadata.gz: efc87f91a3f7fe8066e6899401d7401f31530fac3a24369d1beff0d38eb65234
4
+ data.tar.gz: 89cbb7f57e4bbaf5db8c5b1315e2f033265b62c0f413e2239b4b992e71d3703c
5
5
  SHA512:
6
- metadata.gz: 9125118d12ab8f11b787b09d60876a7f53a8ae694e60e36a9eb21c290228ea6f092ccf201c55d59e3c9271b4bf6e735457b0d883b684b5c764341310ab1cf3b7
7
- data.tar.gz: ea51aa9be5cd74ce33499b704d77fffdbc42d866ccd2ee56eae755e07acfc60904f246883b5530b892da5a90408e17019550f6d9614e7c211ff186cd9983c75f
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/parser/functions.md
21
- `](https://github.com/sudoio/ascode/blob/master/lib/ascode/parser/functions.md).
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
- `C`|`env`|`copy`|`a`|`a`, `a`|Duplicates first element in the stack
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 copy
43
+ def duplicate
35
44
  a = pop false
36
45
  push a
37
46
  push a
@@ -6,7 +6,7 @@ module Ascode
6
6
  def initialize
7
7
  @csv_data = []
8
8
 
9
- filename = File.join(File.dirname(__FILE__), "functions.md")
9
+ filename = File.join(File.dirname(__FILE__), "../functions.md")
10
10
  File.open(filename, "r") do |file|
11
11
  read_csv file
12
12
  end
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.0
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