From 02f896ed7d1a088def0d12c7a55a6f67c034ab21 Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Mon, 28 Dec 2020 18:01:13 -0700 Subject: implement while loops --- crowbar_reference_compiler/ast.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'crowbar_reference_compiler/ast.py') 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' -- cgit v1.2.3