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
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)
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)
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)
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)
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)
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:])
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:])
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)
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:])
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)
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)
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:])
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)
def __init__(self): TreeNode.__init__(self, 'EmptyStatement') self.dict = None
def __init__(self, expression): TreeNode.__init__(self, 'OddStatement') self.dict = { 'Expression': expression } self.child = expression
def __init__(self): TreeNode.__init__(self, 'ConstDeclaration') self.child = None self.dict = { 'Declarations': [] }
def __init__(self, identifier): TreeNode.__init__(self, 'VaraibleDeclarator') self.dict = { 'Identifier': identifier } self.child = identifier