diff --git a/compiler.rb b/compiler.rb index 98be766..b64c38e 100644 --- a/compiler.rb +++ b/compiler.rb @@ -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. diff --git a/test.rb b/test.rb index 5c9aaf1..247d8f8 100644 --- a/test.rb +++ b/test.rb @@ -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")