turmali 0.0.5 → 0.0.6

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
  SHA1:
3
- metadata.gz: 50dd915336d790bddf699cd67b7797adfe1bba8c
4
- data.tar.gz: cee91a42f507574fade6bed46169ac6989ce7d8e
3
+ metadata.gz: 6eb7aee973033aa6925875937fdca4a3f21e2902
4
+ data.tar.gz: aad52d9f7be8d0ddadd844e2ce76ada0d4101ce1
5
5
  SHA512:
6
- metadata.gz: ad708d750e12f349a327f455bfc556063b7c8956ca397d7737c57e3f27a9eb792fb761b788064c912cdb668b5ed7b2cd696bc8c62da3b15c863fb82dd3a138ce
7
- data.tar.gz: 3157d41c7af42ad24c94fad99c840449f9250b6a6a37bbb054a03e656eed85a9a5f7ae2389b627947f95c63347ff2b060d47854235263c3afbc1e9de7fa6658a
6
+ metadata.gz: 58d829d8755dbe10338c329b3279792b2171c062617d7b4d0b0ba61f76116eabe1663aa8d62371a24e4df581b0bf1cfbb46a09af85ed0fc00c8abdc15dbc799d
7
+ data.tar.gz: c38c4b0fc63a18e38df086a312c0eecba03785527ce04d5fa3445becf933dcc548638c2b8492c013ff1da45f971c574aefdbec4708120ee4782de8e321424c32
data/bin/tml CHANGED
@@ -3,6 +3,10 @@
3
3
  require "bundler/setup"
4
4
  require "turmali"
5
5
  require "readline"
6
+ require "racc/parser"
7
+
8
+ stty_save = %x`stty -g`.chomp
9
+ trap("INT") { system "stty", stty_save; exit }
6
10
 
7
11
  interpreter = Interpreter.new
8
12
 
@@ -10,12 +14,16 @@ if file = ARGV.first
10
14
  interpreter.eval File.read(file)
11
15
  else
12
16
  puts "Turmali (#{Turmali::VERSION}) REPL, Type 'quit' or 'exit' to exit"
13
- loop do
14
- line = Readline::readline(">> ")
15
- exit if line == 'quit'
16
- exit if line == 'exit'
17
- Readline::HISTORY.push(line)
18
- value = interpreter.eval(line)
19
- puts "=> #{value.ruby_value.inspect}"
20
- end
21
- end
17
+ begin
18
+ while line = Readline::readline("tml >> ")
19
+ exit if line == 'quit'
20
+ exit if line == 'exit'
21
+ Readline::HISTORY.push(line)
22
+ value = interpreter.eval(line)
23
+ puts "=> #{value.ruby_value.inspect}"
24
+ end
25
+ rescue Racc::ParseError => e
26
+ puts e.inspect
27
+ retry
28
+ end
29
+ end
@@ -5,14 +5,20 @@ class TurmaliClass < TurmaliObject
5
5
 
6
6
  attr_reader :runtime_methods
7
7
 
8
- def initialize
8
+ def initialize(superclass=Constants["Class"])
9
9
  @runtime_methods = {}
10
- @runtime_class = Constants["Class"]
10
+ @runtime_class = superclass
11
11
  end
12
12
 
13
13
  def lookup(method_name)
14
14
  method = @runtime_methods[method_name]
15
- raise "Method not found: #{method_name}" if method.nil?
15
+ unless method
16
+ puts "superclass #{@runtime_superclass}"
17
+ if @runtime_superclass
18
+ return @runtime_superclass.lookup(method_name)
19
+ else
20
+ raise "Method not found: #{method_name}"
21
+ end end
16
22
  method
17
23
  end
18
24
 
@@ -27,4 +33,5 @@ class TurmaliClass < TurmaliObject
27
33
  def new_with_value(value)
28
34
  TurmaliObject.new(self, value)
29
35
  end
36
+
30
37
  end
@@ -9,4 +9,5 @@ class TurmaliObject
9
9
  def call(method, arguments=[])
10
10
  @runtime_class.lookup(method).call(self, arguments)
11
11
  end
12
+
12
13
  end
@@ -1,3 +1,3 @@
1
1
  module Turmali
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turmali
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eiffel Qiu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-27 00:00:00.000000000 Z
11
+ date: 2017-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler