lib/sexpistol/parser.rb in sexpistol-0.1.0 vs lib/sexpistol/parser.rb in sexpistol-0.1.1

- old
+ new

@@ -4,11 +4,11 @@ class Sexpistol class Parser < StringScanner PARANTHESES = /[()]/.freeze STRING = /"([^"\\]|\\.)*"/.freeze - FLOAT = /[\-+]? [0-9]+ ((e[0-9]+) | (\.[0-9]+(e[0-9]+)?)) [\s()]/x.freeze - INTEGER = /[\-+]?[0-9]+[\s()]/.freeze + FLOAT = /[\-+]? [0-9]+ ((e[0-9]+) | (\.[0-9]+(e[0-9]+)?)) (?=[\s()])/x.freeze + INTEGER = /([\-+]?[0-9]+)(?=[\s()])/.freeze SYMBOL = /[^0-9()\s]+[^()\s]*/.freeze def initialize(string) raise 'String given is not an s-expression' if string.strip[0] != '(' raise 'Invalid s-expression' if string.count('(') != string.count(')')