diff --git a/Scanning.py b/Scanning.py index 9462dd993703b53752a0c3ad2097629452133716..61a7b38de02b62362fe8dbeb8724b21caed2429f 100644 --- a/Scanning.py +++ b/Scanning.py @@ -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: