[NEW] Parse numbers of any length, instead of only one digit.

This commit is contained in:
sjs 2009-05-13 23:29:52 -07:00
parent 42ca4451a8
commit c008ed007a
2 changed files with 7 additions and 4 deletions

View file

@ -89,9 +89,12 @@ class Compiler
# Get a number.
def get_num
expected('integer') unless digit?(@look)
c = @look
get_char
return c
value = ''
while digit?(@look)
value << @look
get_char
end
value
end
# Define a constant in the .data section.

View file

@ -25,7 +25,7 @@ def main(arg)
File.open(arg)
else
# StringIO.new("5*(3-5)*2+2-9/3-8/2-4*(5+5+5)\n")
StringIO.new("abc=9\nabc-9\n")
StringIO.new("abc=999\nabc-888\n")
end
data, bss, code = *parse(input)
template = File.read("template.asm")