summaryrefslogtreecommitdiff
path: root/projects/hackc/classes.py
diff options
context:
space:
mode:
Diffstat (limited to 'projects/hackc/classes.py')
-rw-r--r--projects/hackc/classes.py16
1 files changed, 5 insertions, 11 deletions
diff --git a/projects/hackc/classes.py b/projects/hackc/classes.py
index f1358f6..ed69810 100644
--- a/projects/hackc/classes.py
+++ b/projects/hackc/classes.py
@@ -1,4 +1,4 @@
-from .statements import Statement
+from .statements import StatementList
from .tokens import Token
from .utils import *
@@ -210,7 +210,7 @@ class Subroutine:
name: Token,
params: ParamList,
variables: list,
- statements: list,
+ statements: StatementList,
):
self.category = category
self.type = type
@@ -266,13 +266,8 @@ class Subroutine:
variables.append(variable)
t += dt
- statements = []
- while t < len(tokens):
- statement, dt = Statement.from_tokens(tokens[t:])
- if statement is None:
- break
- statements.append(statement)
- t += dt
+ statements, dt = StatementList.from_tokens(tokens[t:])
+ t += dt
body_close = tokens[t]
if body_close != RIGHT_BRACE:
@@ -289,6 +284,5 @@ class Subroutine:
self.params.print_verbose()
for variable in self.variables:
variable.print_verbose()
- for statement in self.statements:
- statement.print_verbose()
+ self.statements.print_verbose()
print(f"End of {self.category} {self.name}")