aboutsummaryrefslogtreecommitdiff
path: root/crowbar_reference_compiler/ast.py
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2020-12-28 18:01:13 -0700
committerMelody Horn <melody@boringcactus.com>2020-12-28 18:01:13 -0700
commit02f896ed7d1a088def0d12c7a55a6f67c034ab21 (patch)
tree6095938f15eb8fb0cf16ef078c3e88b6b90f8f90 /crowbar_reference_compiler/ast.py
parentd24baa5a06d1ed235bb6cfb1c35b8490c18a3175 (diff)
downloadreference-compiler-02f896ed7d1a088def0d12c7a55a6f67c034ab21.tar.gz
reference-compiler-02f896ed7d1a088def0d12c7a55a6f67c034ab21.zip
implement while loops
Diffstat (limited to 'crowbar_reference_compiler/ast.py')
-rw-r--r--crowbar_reference_compiler/ast.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/crowbar_reference_compiler/ast.py b/crowbar_reference_compiler/ast.py
index 142fa8e..7ae7ff9 100644
--- a/crowbar_reference_compiler/ast.py
+++ b/crowbar_reference_compiler/ast.py
@@ -531,6 +531,13 @@ class ASTBuilder(NodeVisitor):
assert kwd.type == 'else'
return IfStatement(condition, then, els)
+ def visit_WhileStatement(self, node, visited_children):
+ kwd, lparen, condition, rparen, body = visited_children
+ assert kwd.type == 'while'
+ assert lparen.type == '('
+ assert rparen.type == ')'
+ return WhileStatement(condition, body)
+
def visit_ReturnStatement(self, node, visited_children):
ret, body, semi = visited_children
assert ret.type == 'return'