MCPcopy Create free account
hub / github.com/NICUP14/MiniLang / while_statement

Method while_statement

src/Parser.py:1431–1448  ·  view source on GitHub ↗
(self, add_predef: bool)

Source from the content-addressed store, hash-verified

1429 return Node(NodeKind.OP_EQ, bool_type, '==', node, Node(NodeKind.TRUE_LIT, bool_type, 'true'))
1430
1431 def while_statement(self, add_predef: bool) -> Optional[Node]:
1432 cond_node = self.token_list_to_tree()
1433 if cond_node.ntype not in (any_type, bool_type):
1434 print_error('while_statement',
1435 f'Expected a boolean expression, got type {rev_type_of(cond_node.ntype)}', self)
1436
1437 self.next_line()
1438 cond_node = self.inject_cond(cond_node)
1439
1440 predef = Def.predeferred
1441 Def.predeferred = None
1442 body = self.compound_statement()
1443 Def.predeferred = predef
1444
1445 node = Node(NodeKind.GLUE, void_type, '', Node(
1446 NodeKind.WHILE, void_type, '', cond_node, body), Node(NodeKind.END, void_type, 'end'))
1447
1448 return node
1449
1450 def for_statement(self, add_predef: bool) -> Optional[Node]:
1451 iter_name = full_name_of_var(

Callers 1

statementMethod · 0.95

Calls 7

token_list_to_treeMethod · 0.95
next_lineMethod · 0.95
inject_condMethod · 0.95
compound_statementMethod · 0.95
print_errorFunction · 0.90
rev_type_ofFunction · 0.90
NodeClass · 0.90

Tested by

no test coverage detected