ascode 0.0.3 → 0.0.4

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: 36af2df326ac831127e898ba681041454b8c04d05c64c5014691d3258274578e
4
- data.tar.gz: 23630fab5a5ce66c39997c6ac162b48857db43862433933af26920342b9236f3
3
+ metadata.gz: 6d5613388e1c1d1ed16df6f3a7dffc7cda13942828766e128686657c1c79e516
4
+ data.tar.gz: deea5d3e304c6b0a57e2f644d19fe403a48d4b0a97eaf939591de46a470267f8
5
5
  SHA512:
6
- metadata.gz: 74fd97af1f93c65bf953de537860dfb97b4fb2b3259152ae5691dddfe0b5c9dd754648cfc4fe96b6e275a9e63497c33df844b4d8765d2aacf58c6942826d34e5
7
- data.tar.gz: 845a14e78448d55d440f4f7adfcb5de0846ded75b00bb306a26ed43f2404e5730e6760c2e53da8a5806c601a6572458e729a41cc8c659e26a201206e47f3166c
6
+ metadata.gz: 81de49c8a02e3168dda1eea4fad57da817a925ccf1db0b259e3e286cedba9a446a7383a6cc42e6aa7c9843670f66b2ec81a213d28623cc3ad8443a7c2cd2878e
7
+ data.tar.gz: b1ab700a996cab9d82f1bf3b42ea4569eebee10340a37a468c195fa6c2f2374a9fe886d51a618ea0753f7e202d220ff39b5de21ed105cc50158c205ff11f439f
@@ -0,0 +1,2 @@
1
+ short,long,pop,push,description
2
+ ➤,output,`a`,,Prints `a` to stdout
@@ -0,0 +1,26 @@
1
+ module Ascode
2
+ class Functions
3
+ attr_reader :csv_data
4
+
5
+ def initialize
6
+ @csv_data = []
7
+ read_csv
8
+ end
9
+
10
+ def read_csv
11
+ file = File.open('ascode/functions.csv', 'r')
12
+
13
+ until (line = file.gets).nil?
14
+ src = line.strip.split(',')
15
+ data = { short: src[0], long: src[1],
16
+ pop: src[2], push: src[3],
17
+ desc: src[4] }
18
+
19
+ @csv_data.push data
20
+ end
21
+
22
+ file.close
23
+ @csv_data.delete_at 0
24
+ end
25
+ end
26
+ end
@@ -2,11 +2,19 @@ module Ascode
2
2
  class Interpreter
3
3
  def initialize(ast)
4
4
  @ast = ast
5
+
6
+ @stack = []
5
7
  end
6
8
 
7
9
  def run
8
- # TODO: Implement Ascode::Interpreter::run
9
- # Run using @ast
10
+ @ast.each do |action|
11
+ name = action[:action]
12
+ send(name)
13
+ end
14
+ end
15
+
16
+ def output
17
+ puts @stack.pop
10
18
  end
11
19
  end
12
20
  end
data/lib/ascode/parser.rb CHANGED
@@ -1,14 +1,25 @@
1
+ require_relative 'functions'
2
+
1
3
  module Ascode
2
4
  class Parser
3
5
  def initialize(code)
6
+ @fun = Functions.new
4
7
  @code = code
5
8
  end
6
9
 
7
10
  def parse
11
+ ast = []
8
12
  @code.split('').to_enum.each do |char|
9
- # TODO: Implement Ascode::Parser::parse
10
- # Parse @code and return an AST
13
+ name = (@fun.csv_data.each { |value| value[:short] == char })[0]
14
+ data = {
15
+ action: name[:long]
16
+ # TODO: also add :what (when 'push')
17
+ }
18
+
19
+ ast.push data
11
20
  end
21
+
22
+ ast
12
23
  end
13
24
  end
14
25
  end
data/lib/ascode.rb CHANGED
@@ -12,4 +12,4 @@ module Ascode
12
12
  end
13
13
 
14
14
  # Test
15
- Ascode.run('!')
15
+ Ascode.run('')
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.0.3
4
+ version: 0.0.4
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-12 00:00:00.000000000 Z
11
+ date: 2018-01-13 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -19,6 +19,8 @@ files:
19
19
  - LICENSE.md
20
20
  - README.md
21
21
  - lib/ascode.rb
22
+ - lib/ascode/functions.csv
23
+ - lib/ascode/functions.rb
22
24
  - lib/ascode/interpreter.rb
23
25
  - lib/ascode/parser.rb
24
26
  homepage: https://github.com/sudoio/ascode