summaryrefslogtreecommitdiff
path: root/projects/hackc/classes.py
diff options
context:
space:
mode:
authorFrederick Yin <fkfd@fkfd.me>2022-09-03 11:46:10 +0800
committerFrederick Yin <fkfd@fkfd.me>2022-09-03 11:46:10 +0800
commitdfb5ee45fb68aca09bd0ac9967c6b574f932d39f (patch)
treea137350c895d6d1a1ff1d9f7ae4db080e07ef877 /projects/hackc/classes.py
parentb1794edb3d76db7c1a86fc14a60bc95b833bc7c7 (diff)
hackc: While statement
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}")