aboutsummaryrefslogtreecommitdiff
path: root/ruby
diff options
context:
space:
mode:
Diffstat (limited to 'ruby')
-rw-r--r--ruby/reader.rb3
-rw-r--r--ruby/step9_try.rb2
2 files changed, 1 insertions, 4 deletions
diff --git a/ruby/reader.rb b/ruby/reader.rb
index eb9ae7b..641e65c 100644
--- a/ruby/reader.rb
+++ b/ruby/reader.rb
@@ -31,7 +31,7 @@ def read_atom(rdr)
return case token
when /^-?[0-9]+$/ then token.to_i # integer
when /^-?[0-9][0-9.]*$/ then token.to_f # float
- when /^"/ then parse_str(token) # string
+ when /^".*"$/ then parse_str(token) # string
when /^:/ then "\u029e" + token[1..-1] # keyword
when "nil" then nil
when "true" then true
@@ -57,7 +57,6 @@ def read_list(rdr, klass, start="(", last =")")
end
def read_form(rdr)
- token = rdr.peek
return case rdr.peek
when ";" then nil
when "'" then rdr.next; List.new [:quote, read_form(rdr)]
diff --git a/ruby/step9_try.rb b/ruby/step9_try.rb
index eecba9c..74d0f59 100644
--- a/ruby/step9_try.rb
+++ b/ruby/step9_try.rb
@@ -155,7 +155,6 @@ repl_env.set(:eval, lambda {|ast| EVAL(ast, repl_env)})
repl_env.set(:"*ARGV*", List.new(ARGV.slice(1,ARGV.length) || []))
# core.mal: defined using the language itself
-RE["(def! *host-language* \"ruby\")"]
RE["(def! not (fn* (a) (if a false true)))"]
RE["(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\")))))"]
RE["(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))"]
@@ -167,7 +166,6 @@ if ARGV.size > 0
end
# repl loop
-RE["(println (str \"Mal [\" *host-language* \"]\"))"]
while line = _readline("user> ")
begin
puts REP[line]