uby_interpreter 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- N2EwYzRjY2ZhMDhkMDhjZjgzZWIzMTBlNjE4ZWQ2MmM0YTQ4NGJiYg==
4
+ NTFiNjFkNzUwOWQzMDY4ZTVjMWM4MTJlYTg2ZjlhZWJiMjBlNDVmNQ==
5
5
  data.tar.gz: !binary |-
6
- OWU5MWNhOTA4MDEwNDdlNTBjZWJlOThiMDRkMjE0YzBkMzgxMDUwOA==
6
+ NThkNzdlYTJkMzYzMzAwNmNhNTI0MTExMDc3NTQwMWYyNzJmYjEwNQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NWE1MDUyNGY5MjFjMGY4MjEwMTk5M2FhMmU4MzNiNDc3MjJkNDAxY2QxM2Q0
10
- MDJiNTI0ZDVkMjMwYTUyOWU2MDY2YzFiNjRmMGQ2ZTg2NDUyZjg3MGQwNTVm
11
- MDk2NzU2OTI1ZGIxNDMzNTFjNmFlZDA5NWQzZDNiY2JjMmNhZWY=
9
+ M2E0NGQwN2M1NzBiOWUyMTk2OWJjOTQ4YWQ5MzQ2NDlmMTkxMTQwOWI4YTUw
10
+ OTM0NzY4OGE4N2VkMzRlZmYwYjE2MDFmMDdlZGI4YjVhOGZmODUwNjlhYzA2
11
+ MzJiY2UzNGJkNDJmODkyNzdmYTM1Y2M4YTg3NDg2NzYwOWExZjU=
12
12
  data.tar.gz: !binary |-
13
- OTE2NDhmZDUzMTU0OWI4MjU0OWE3ZTkxMWExN2NhMmQ3NTczOGY1MTMwYTE1
14
- OTU0MGM1NWQ2YTZmYmE3YzNkZmViMGM0YjQxNjI0YzI0OWQ0ODliYTI3Zjk1
15
- YWFmZDJlYjRiOGUwMWQzZGU3NDE2MGM2MzA5OTdkNWViYTI0MmQ=
13
+ YWNlMmUwODhkODc0ZWRiMjUxMmFhZjdiOTRjYzNjMDgyNzc3NTUyYzBjYTc4
14
+ NmNlNDM3MzE5ZGNhNTZlZjIwODc0Mjg4NzVkZGNjYzE4ZWNiYTQ1ZmUzYTIz
15
+ N2NlY2YzZWE5YmMyZGQ4ZWYyZWQ1ZjFhZDJiM2Q2ODY4M2M2OGM=
data/README.md CHANGED
@@ -28,6 +28,20 @@ Or install it yourself as:
28
28
 
29
29
  $ gem install uby_interpreter
30
30
 
31
+ ## Usage
32
+
33
+ Comes with executable.
34
+
35
+ Run a file with
36
+
37
+ $ uby /path/to/your/file
38
+
39
+ Or simply run
40
+
41
+ $ ./bin/uby example.rb
42
+
43
+ to see what this little fellow can do!
44
+
31
45
  ## Running tests
32
46
 
33
47
  $ rake
data/bin/uby ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "uby_interpreter"
4
+
5
+ interpreter = UbyInterpreter.new
6
+ file = File.read(ARGV.first)
7
+ interpreter.eval file
@@ -0,0 +1,52 @@
1
+ puts "
2
+ xmHTTTTT%ms.
3
+ z?!!!!!!!!!!!!!!?m
4
+ z!!!!!!!!!!!!!!!!!!!!%
5
+ eHT!!!!!!!!!!!!!!!!!!!!!!!L
6
+ EXAMPLE?? WHY NOT ZOIDBERG???? M!!!!!!!!!!!!!!!!!!!!!!!!!!!>
7
+ z!!!!!!!!!!XH!!!!!!!!!!!!!!!!!!X
8
+ '$$F*tX!!W?!!!!!!!!!!!!!!!!!!!!!
9
+ > M!!! 4$$NX!!!!!!!!!!!!!t
10
+ tmem?!!!!? '' 'X!!!!!!!!!!F
11
+ um@T!!!!!!!!!!!!s. M!!!!!!!!!!F
12
+ .#!!!!!!!!!!!!!!!XX!!!!?mM!!!!!!!!!!t~
13
+ M!!!@!!!!X!!!!!!!!!!*U!!!!!!!!!!!!!!@
14
+ M!!t%!!!W?!!!XX!!!!!!!!!!!!!!!!!!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!!?!!?X!!!!!!!!!!!!!!!!!!!!!!!!!Z
46
+ X!!!!!!t H!!!!!!!!!!!!!!!!!!!!!!!!> !!!!!!!!!!!W!!!!!!!!!!!!!!!!!!!!!!!t
47
+ %!!!!!!F :!!!!!!!!!!!!!!!!!!!!!!!!!> !!!!!!!!!!!!#X!!!!!!!!!!!!!!!!!!!!X
48
+ '!!!!!!X K!!!!!!!!!!!!!!!!!!!!!!!!!> K!!!!!!!!!!!!!?W!!!!!!!!!!!!!!!!X' "
49
+
50
+
51
+ puts "\n\n"
52
+ puts "YES, IT SUPPORTS PRINTING OF ASCII ZOIDBERGS".center(100, "=")
@@ -3,7 +3,9 @@ require "ruby19_parser"
3
3
 
4
4
  class UbyInterpreter < SexpInterpreter
5
5
 
6
- VERSION = "1.0.0"
6
+ VERSION = "1.0.1"
7
+
8
+ INTERNAL_METHODS = %w.print puts p.
7
9
 
8
10
  class Environment
9
11
  def [] k
@@ -85,6 +87,12 @@ class UbyInterpreter < SexpInterpreter
85
87
  if recv then
86
88
  recv.send(msg, *args)
87
89
  else
90
+
91
+ if INTERNAL_METHODS.include? "#{msg}"
92
+ process_internal(msg, args)
93
+ return
94
+ end
95
+
88
96
  self.env.scope do
89
97
  decls, body = self.env[msg]
90
98
 
@@ -155,4 +163,20 @@ class UbyInterpreter < SexpInterpreter
155
163
  hash
156
164
  end
157
165
  end
166
+
167
+ def process_internal(msg, *args)
168
+ send("process_#{msg}", args.join)
169
+ end
170
+
171
+ def process_puts s
172
+ puts s
173
+ end
174
+
175
+ def process_print s
176
+ print s
177
+ end
178
+
179
+ def process_p s
180
+ p s
181
+ end
158
182
  end
@@ -87,4 +87,18 @@ class UbyInterpreterTest < MiniTest::Test
87
87
  hash = {:foo => :bar, :baz => :biz}
88
88
  assert_eval hash, "{:foo => :bar, :baz => :biz}"
89
89
  end
90
+
91
+ def test_printing
92
+ assert_output "I can has puts\n" do
93
+ assert_eval nil, "puts \"I can has puts\""
94
+ end
95
+
96
+ assert_output "I can has print" do
97
+ assert_eval nil, "print \"I can has print\""
98
+ end
99
+
100
+ assert_output "I can has p" do
101
+ assert_eval nil, "print \"I can has p\""
102
+ end
103
+ end
90
104
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uby_interpreter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hrvoje Šimić
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-29 00:00:00.000000000 Z
11
+ date: 2013-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby_parser
@@ -83,7 +83,8 @@ dependencies:
83
83
  description: Simple Ruby interpreter
84
84
  email:
85
85
  - shime.ferovac@gmail.com
86
- executables: []
86
+ executables:
87
+ - uby
87
88
  extensions: []
88
89
  extra_rdoc_files: []
89
90
  files:
@@ -92,6 +93,8 @@ files:
92
93
  - LICENSE.txt
93
94
  - README.md
94
95
  - Rakefile
96
+ - bin/uby
97
+ - example.rb
95
98
  - lib/uby_interpreter.rb
96
99
  - test/uby_interpreter_test.rb
97
100
  - uby_interpreter.gemspec