Skip to content
Snippets Groups Projects
Commit 8a5a3d8d authored by pycsham's avatar pycsham
Browse files

fixed the integer checking code

parent ea048b93
No related branches found
No related tags found
No related merge requests found
......@@ -494,6 +494,12 @@ def scan(input):
if index < indexRange-1:
if tokens[index+1].name == 'NUM':
return (None, "wrong integer literal: starts with 0")
# Checking integer range (does not cover all edge cases)
elif token.name == 'NUM' and index > 0 and tokens[index-1].name == 'SUB' and int(token.lex) > 2147483648:
return (None, "integer too small")
elif token.name == 'NUM' and int(token.lex) > 2147483647 and (index is 0 or tokens[index-1].name is not 'SUB'):
return (None, "interger too large")
# dealing with keywords in Java but not in Joos
elif token.name == 'ID' and token.lex in wrongJavaKeyWordDict:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment