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 +8 -8
- data/README.md +14 -0
- data/bin/uby +7 -0
- data/example.rb +52 -0
- data/lib/uby_interpreter.rb +25 -1
- data/test/uby_interpreter_test.rb +14 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NTFiNjFkNzUwOWQzMDY4ZTVjMWM4MTJlYTg2ZjlhZWJiMjBlNDVmNQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NThkNzdlYTJkMzYzMzAwNmNhNTI0MTExMDc3NTQwMWYyNzJmYjEwNQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
M2E0NGQwN2M1NzBiOWUyMTk2OWJjOTQ4YWQ5MzQ2NDlmMTkxMTQwOWI4YTUw
|
10
|
+
OTM0NzY4OGE4N2VkMzRlZmYwYjE2MDFmMDdlZGI4YjVhOGZmODUwNjlhYzA2
|
11
|
+
MzJiY2UzNGJkNDJmODkyNzdmYTM1Y2M4YTg3NDg2NzYwOWExZjU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
data/example.rb
ADDED
@@ -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!!!!!!!!!!!!!!!!!!!!X'
|
15
|
+
:!!t?!!!@!!!!W?!!!!XWWUX!!!!!!!!!!!t
|
16
|
+
4!!$!!!M!!!!8!!!!!@$$$$$$NX!!!!!!!!-
|
17
|
+
*P*!!!$!!!!E!!!!9$$$$$$$$%!!!!!!!K
|
18
|
+
'H*'X!!X&!!!!R**$$$*#!!!!!!!!!>
|
19
|
+
'TT!?W!!9!!!!!!!!!!!!!!!!M
|
20
|
+
'!!!!!!!!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
+
%!!!!!!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, "=")
|
data/lib/uby_interpreter.rb
CHANGED
@@ -3,7 +3,9 @@ require "ruby19_parser"
|
|
3
3
|
|
4
4
|
class UbyInterpreter < SexpInterpreter
|
5
5
|
|
6
|
-
VERSION = "1.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.
|
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-
|
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
|