def visit_else_condition(self, node: ParseTreeNode, children: Tuple[StrMatch, Union[List[ast.Statement], ast.Statement]] ) -> ast.ControlStructure: body = children[1] if isinstance(body, ast.Statement): body = [body] return ast.ControlStructure(node.position, 'else', None, body)
def visit_switch(self, node: ParseTreeNode, children: Tuple[StrMatch, ast.Expression, ast.Statement] ) -> ast.ControlStructure: return ast.ControlStructure(node.position, 'switch', children[1], list(children[2:]))
def visit_while_loop(self, node: ParseTreeNode, children: Tuple[StrMatch, ControlStructureArgs]) -> ast.ControlStructure: return ast.ControlStructure(node.position, 'while', children[1][0], children[1][1])
def visit_elif_condition(self, node: ParseTreeNode, children: Tuple[StrMatch, ControlStructureArgs] ) -> ast.ControlStructure: return ast.ControlStructure(node.position, 'elif', children[1][0], children[1][1])