From b1794edb3d76db7c1a86fc14a60bc95b833bc7c7 Mon Sep 17 00:00:00 2001 From: Frederick Yin Date: Sat, 3 Sep 2022 11:22:20 +0800 Subject: hackc: more statements; UnexpectedToken --- projects/hackc/parser.py | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) (limited to 'projects/hackc/parser.py') diff --git a/projects/hackc/parser.py b/projects/hackc/parser.py index 188bddc..406c139 100644 --- a/projects/hackc/parser.py +++ b/projects/hackc/parser.py @@ -2,32 +2,6 @@ from .tokens import Token from .classes import Class from .utils import * -KEYWORDS = [ - "class", - "constructor", - "function", - "method", - "field", - "static", - "var", - "int", - "char", - "boolean", - "void", - "true", - "false", - "null", - "this", - "let", - "do", - "if", - "else", - "while", - "return", -] - -SYMBOLS = "{}()[].,;+-*/&|<>=~" - class Parser: def __init__(self, fp, extensions=[]): @@ -82,6 +56,8 @@ class Parser: break rem = line[pos:] # remainder of line + if not rem: + continue token = Token.from_line(rem, line_no, pos, extensions=self._extensions) if token is not None: self.tokens.append(token) -- cgit v1.2.3