src/parser.py
def insert_op(self, op):
        ''' Pop stack and make new operator ast '''
        #TODO: designate t as the root of the tree;
        # overwrite child nodes if they are specified as the root
        t = ast.AST(op)
        if op == '~':
            if self.tree_stack:
                # if it is a negation, put as right child
                tree = self.tree_stack.pop()
                tree.root = False
                t.right = tree
                self.tree_stack.append(t)
            else:
                self.tree_stack.append(op)
        elif op in self.lexer.binary_op:
            if self.tree_stack:
                tree = self.tree_stack.pop()
                tree.root = False
                t.right = tree
                tree = self.tree_stack.pop()
                tree.root = False
                t.left = tree
                self.tree_stack.append(t)
            else:
                raise Exception('Stack empty')
 Pop stack and make new operator ast 
Pop stack and make new operator ast
Pop stack and make new operator ast
def insert_op(self, op):
        t = ast.AST(op)
        if op == '~':
            if self.tree_stack:
                tree = self.tree_stack.pop()
                tree.root = False
                t.right = tree
                self.tree_stack.append(t)
            else:
                self.tree_stack.append(op)
        elif op in self.lexer.binary_op:
            if self.tree_stack:
                tree = self.tree_stack.pop()
                tree.root = False
                t.right = tree
                tree = self.tree_stack.pop()
                tree.root = False
                t.left = tree
                self.tree_stack.append(t)
            else:
                raise Exception('Stack empty')
def insert_op ( self , op ) : t = ast . AST ( op ) if op == '~' : if self . tree_stack : tree = self . tree_stack . pop ( ) tree . root = False t . right = tree self . tree_stack . append ( t ) else : self . tree_stack . append ( op ) elif op in self . lexer . binary_op : if self . tree_stack : tree = self . tree_stack . pop ( ) tree . root = False t . right = tree tree = self . tree_stack . pop ( ) tree . root = False t . left = tree self . tree_stack . append ( t ) else : raise Exception ( 'Stack empty' )
Pop stack and make new operator ast
Pop stack and make new operator ast
''' Pop stack and make new operator ast ''' #TODO: designate t as the root of the tree; # overwrite child nodes if they are specified as the root # if it is a negation, put as right child
self
op