lib/vendor/sexpistol/sexpistol/sexpistol_parser.rb in qcmd-0.1.11 vs lib/vendor/sexpistol/sexpistol/sexpistol_parser.rb in qcmd-0.1.12
- old
+ new
@@ -50,34 +50,34 @@
when :"'"
case fetch_token
when '(' then exp << [:quote].concat([parse])
else exp << [:quote, @token]
end
- when String, Fixnum, Float, Symbol
+ when String, Fixnum, Float, Symbol
exp << @token
- when nil
+ when nil
break
end
end
exp
end
-
+
def fetch_token
skip(/\s+/)
return nil if(eos?)
-
- @token =
+
+ @token =
# Match parentheses
- if scan(/[\(\)]/)
+ if scan(/[\(\)]/)
matched
# Match a string literal
elsif scan(/"([^"\\]|\\.)*"/)
eval(matched)
# Match a float literal
- elsif scan(/[\-\+]? [0-9]+ ((e[0-9]+) | (\.[0-9]+(e[0-9]+)?))/x)
+ elsif scan(/[\-\+]? [0-9]+ ((e[0-9]+) | (\.[0-9]+(e[0-9]+)?)) (\s|$)/x)
matched.to_f
# Match an integer literal
- elsif scan(/[\-\+]?[0-9]+/)
+ elsif scan(/[\-\+]?[0-9]+ (\s|$)/x)
matched.to_i
# Match a comma (for comma quoting)
elsif scan(/'/)
matched.to_sym
# Match a symbol