Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

35 lines (29 sloc) 0.52 kb
class Reader
def initialize(expression)
@tokens = expression.scan /[()]|\w+|".*?"|'.*?'/
end
def peek
@tokens.first
end
def next_token
@tokens.shift
end
def read
return :"no more forms" if @tokens.empty?
if (token = next_token) == '('
read_list
elsif token =~ /['"].*/
token[1..-2]
elsif token =~ /\d+/
token.to_i
else
token.to_sym
end
end
def read_list
list = []
list << read until peek == ')'
next_token
list
end
end
Jump to Line
Something went wrong with that request. Please try again.