diff options
author | Frederick Yin <fkfd@fkfd.me> | 2022-09-03 11:22:20 +0800 |
---|---|---|
committer | Frederick Yin <fkfd@fkfd.me> | 2022-09-03 11:22:20 +0800 |
commit | b1794edb3d76db7c1a86fc14a60bc95b833bc7c7 (patch) | |
tree | 582288c1618a74405d3c183410d7525b8d6aa31f /projects/hackc/parser.py | |
parent | bed429a1d17b43678a70bc286aac12a0bd6e387d (diff) |
hackc: more statements; UnexpectedToken
Diffstat (limited to 'projects/hackc/parser.py')
-rw-r--r-- | projects/hackc/parser.py | 28 |
1 files changed, 2 insertions, 26 deletions
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) |