mirror of
https://github.com/samsonjs/compiler.git
synced 2026-03-25 08:45:52 +00:00
[NEW] Parse numbers of any length, instead of only one digit.
This commit is contained in:
parent
42ca4451a8
commit
c008ed007a
2 changed files with 7 additions and 4 deletions
|
|
@ -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.
|
||||
|
|
|
|||
2
test.rb
2
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")
|
||||
|
|
|
|||
Loading…
Reference in a new issue