Exemplo n.º 1
0
 def __init__(self, const_decl=None, var_decl=None, proc_decl=None, stmt=None):
     TreeNode.__init__(self, 'SubRoutine')
     self.dict = {
         'ConstDeclaration': const_decl,
         'VariableDeclaration': var_decl,
         'ProcDeclaration': proc_decl,
         'Statement': stmt
     }
     if const_decl is not None:
         self.child = const_decl
     if var_decl is not None:
         if self.child is not None:
             self.child.sublings.append(var_decl)
         else:
             self.child = var_decl
     if proc_decl is not None:
         if self.child is not None:
             self.child.sublings.append(proc_decl)
         else:
             self.child = proc_decl
     if stmt is not None:
         if self.child is not None:
             self.child.sublings.append(stmt)
         else:
             self.child = stmt
Exemplo n.º 2
0
 def __init__(self, condition=None, statement=None):
     TreeNode.__init__(self, 'DoWhileStatement')
     self.dict = {
         'Condition': condition,
         'Statement': statement
     }
     self.child = copy.deepcopy(condition)
     self.child.sublings.extend(statement)
Exemplo n.º 3
0
 def __init__(self, condition=None, statement=None):
     TreeNode.__init__(self, 'WhileStatement')
     self.dict = {
         'Condition': condition,
         'Statement': statement
     }
     self.child = condition
     self.child.sublings.append(statement)
Exemplo n.º 4
0
 def __init__(self, io_type, arguments: Arguments):
     TreeNode.__init__(self, 'IOStatement')
     self.dict = {
         'IOType': io_type,
         'Arguments': arguments
     }
     self.child = io_type
     self.child.sublings.append(arguments)
Exemplo n.º 5
0
 def __init__(self, lhs, rhs):
     TreeNode.__init__(self, 'AssignExpression')
     self.dict = {
         'Lhs': lhs,
         'Rhs': rhs
     }
     self.child = copy.deepcopy(lhs)
     self.child.sublings.append(rhs)
Exemplo n.º 6
0
 def __init__(self, oprator, lhs, rhs):
     TreeNode.__init__(self, oprator)
     self.dict = {
         'Lhs': lhs,
         'Rhs': rhs
     }
     self.child = copy.deepcopy(lhs)
     self.child.sublings.append(rhs)
Exemplo n.º 7
0
 def __init__(self, *stmt_list):
     TreeNode.__init__(self, 'BlockStatement')
     self.dict = {
         'StatementList': stmt_list
     }
     self.child = stmt_list[0]
     if len(stmt_list) > 1:
         self.child.sublings.extend(stmt_list[1:])
Exemplo n.º 8
0
 def __init__(self, *arg_list):
     TreeNode.__init__(self, 'Arguments')
     self.dict = {
         'Arguments': arg_list
     }
     self.child = arg_list[0]
     if len(arg_list) > 1:
         self.child.sublings.extend(arg_list[1:])
Exemplo n.º 9
0
 def __init__(self, ast_proc_head, ast_subroutine):
     TreeNode.__init__(self, 'ProcDeclarator')
     self.dict = {
         'ProcHead': ast_proc_head,
         'SubRoutine': ast_subroutine
     }
     self.child = ast_proc_head
     self.child.sublings.append(ast_subroutine)
Exemplo n.º 10
0
 def __init__(self, *args):
     TreeNode.__init__(self, 'ProcDeclaration')
     self.dict = {
         'Declarations': args
     }
     self.child = args[0]
     if len(args) > 1:
         self.child.sublings.extend(args[1:])
Exemplo n.º 11
0
 def __init__(self, identifier, number):
     TreeNode.__init__(self, 'ConstDeclarator')
     self.dict = {
         'Identifier': identifier,
         'Number': number
     }
     self.child = copy.deepcopy(identifier)
     self.child.sublings.append(number)
Exemplo n.º 12
0
 def __init__(self, identifier, *arguments):
     TreeNode.__init__(self, 'CallExpression')
     self.dict = {
         'Identifier': identifier,
         'Arguments': arguments,
     }
     self.child = identifier
     if arguments is not None and len(arguments) > 0:
         self.child.sublings.append(arguments)
Exemplo n.º 13
0
 def __init__(self, *args):
     #super(TreeNode, self).__init__('VariableDeclaration')
     TreeNode.__init__(self, 'VariableDeclaration')
     self.dict = {
         'Declarations': args
     }
     self.child = args[0]
     if len(args) > 1:
         self.child.sublings.extend(args[1:])
Exemplo n.º 14
0
 def __init__(self, condition, true_stmt, false_stmt=EmptyStatement()):
     TreeNode.__init__(self, 'IfStatement')
     self.dict = {
         'Condition': condition, # condition is a binary operator
         'TrueStatement': true_stmt,
         'FalseStatement': false_stmt
     }
     self.child = copy.deepcopy(condition)
     self.child.sublings.append(true_stmt)
     self.child.sublings.append(false_stmt)
Exemplo n.º 15
0
 def __init__(self):
     TreeNode.__init__(self, 'EmptyStatement')
     self.dict = None
Exemplo n.º 16
0
 def __init__(self, expression):
     TreeNode.__init__(self, 'OddStatement')
     self.dict = {
         'Expression': expression
     }
     self.child = expression
Exemplo n.º 17
0
 def __init__(self):
     TreeNode.__init__(self, 'ConstDeclaration')
     self.child = None
     self.dict = {
         'Declarations': []
     }
Exemplo n.º 18
0
 def __init__(self, identifier):
     TreeNode.__init__(self, 'VaraibleDeclarator')
     self.dict = {
         'Identifier': identifier
     }
     self.child = identifier