summaryrefslogtreecommitdiff
path: root/projects/hackc/parser.py
diff options
context:
space:
mode:
Diffstat (limited to 'projects/hackc/parser.py')
-rw-r--r--projects/hackc/parser.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/projects/hackc/parser.py b/projects/hackc/parser.py
index f73c3d1..9a927c6 100644
--- a/projects/hackc/parser.py
+++ b/projects/hackc/parser.py
@@ -1,4 +1,5 @@
from .tokens import Token
+from .syntax import Class
from .utils import *
KEYWORDS = [
@@ -37,7 +38,7 @@ class Parser:
def print_tokens(self):
print("LINE\tCOL\tTYPE\tTOKEN")
for token in self.tokens:
- print(f"{token.line_no + 1}\t{token.column + 1}\t{token.type[:3]}\t{token.token}")
+ print(f"{token.line_no + 1}\t{token.column + 1}\t{token.type[:3]}\t{token}")
print(f"===== {len(self.tokens)} tokens =====")
def tokenize(self):
@@ -91,3 +92,6 @@ class Parser:
print_err(line)
print_err(" " * pos + f"^ Invalid token")
exit(EXIT_CODE_INVALID_TOKEN)
+
+ def parse(self):
+ syntax_tree = Class.from_tokens(self.tokens)