Exemple #1
0
 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)
Exemple #2
0
 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:]))
Exemple #3
0
 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])
Exemple #4
0
 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])