From 8a5a3d8d63c6479d0423fc6c9047ae7b8c2fb6cc Mon Sep 17 00:00:00 2001 From: pycsham <shampuiyanchloe@gmail.com> Date: Mon, 10 Feb 2020 21:25:02 -0500 Subject: [PATCH] fixed the integer checking code --- Scanning.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Scanning.py b/Scanning.py index 9462dd9..61a7b38 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: -- GitLab