# Path: lems/base/base.py
# class LEMSBase(object):
#     """
#     Base object for PyLEMS.
#     """
# 
#     def copy(self):
#         return copy.deepcopy(self)
# 
#     def toxml(self):
#         return ""
# 
# Path: lems/base/stack.py
# class Stack(LEMSBase):
#     """
#     Basic stack implementation.
#     """
# 
#     def __init__(self):
#         """
#         Constructor.
#         """
# 
#         self.stack = []
#         """ List used to store the stack contents.
#         :type: list """
# 
#     def push(self, val):
#         """
#         Pushed a value onto the stack.
# 
#         :param val: Value to be pushed.
#         :type val: *
#         """
# 
#         self.stack = [val] + self.stack
# 
#     def pop(self):
#         """
#         Pops a value off the top of the stack.
# 
#         :return: Value popped off the stack.
#         :rtype: *
# 
#         :raises StackError: Raised when there is a stack underflow.
#         """
# 
#         if self.stack:
#             val = self.stack[0]
#             self.stack = self.stack[1:]
#             return val
#         else:
#             raise StackError("Stack empty")
# 
#     def top(self):
#         """
#         Returns the value off the top of the stack without popping.
# 
#         :return: Value on the top of the stack.
#         :rtype: *
# 
#         :raises StackError: Raised when there is a stack underflow.
#         """
# 
#         if self.stack:
#             return self.stack[0]
#         else:
#             raise StackError("Stack empty")
# 
#     def is_empty(self):
#         """
#         Checks if the stack is empty.
# 
#         :return: True if the stack is empty, otherwise False.
#         :rtype: Boolean
#         """
# 
#         return self.stack == []
# 
#     def __str__(self):
#         """
#         Returns a string representation of the stack.
# 
#         @note: This assumes that the stack contents are capable of generating
#         string representations.
#         """
# 
#         if len(self.stack) == 0:
#             s = "[]"
#         else:
#             s = "[" + str(self.stack[0])
#             for i in range(1, len(self.stack)):
#                 s += ", " + str(self.stack[i])
#             s += "]"
#         return s
# 
#     def __repr__(self):
#         return self.__str__()


from lems.base.base import LEMSBase
from lems.base.stack import Stack
                % (self.op_stack, self.val_stack, self.node_stack)
            )
        if self.debug:
            print("<<<<< Depth: %s, returning: %s" % (ExprParser.depth, ret))
        ExprParser.depth = ExprParser.depth - 1
        if self.debug:
            print("")
        return ret

    def parse(self):
        """
        Tokenizes and parses an arithmetic expression into a parse tree.

        :return: Returns a token string.
        :rtype: lems.parser.expr.ExprNode
        """
        # print("Parsing: %s"%self.parse_string)
        self.tokenize()
        if self.debug:
            print("Tokens found: %s" % self.token_list)

        try:
            parse_tree = self.parse2()
        except Exception as e:
            raise e
        return parse_tree

    def parse2(self):
        self.op_stack = Stack()
        self.val_stack = Stack()

# Path: lems/base/base.py
# class LEMSBase(object):
#     """
#     Base object for PyLEMS.
#     """
# 
#     def copy(self):
#         return copy.deepcopy(self)
# 
#     def toxml(self):
#         return ""
# 
# Path: lems/base/stack.py
# class Stack(LEMSBase):
#     """
#     Basic stack implementation.
#     """
# 
#     def __init__(self):
#         """
#         Constructor.
#         """
# 
#         self.stack = []
#         """ List used to store the stack contents.
#         :type: list """
# 
#     def push(self, val):
#         """
#         Pushed a value onto the stack.
# 
#         :param val: Value to be pushed.
#         :type val: *
#         """
# 
#         self.stack = [val] + self.stack
# 
#     def pop(self):
#         """
#         Pops a value off the top of the stack.
# 
#         :return: Value popped off the stack.
#         :rtype: *
# 
#         :raises StackError: Raised when there is a stack underflow.
#         """
# 
#         if self.stack:
#             val = self.stack[0]
#             self.stack = self.stack[1:]
#             return val
#         else:
#             raise StackError("Stack empty")
# 
#     def top(self):
#         """
#         Returns the value off the top of the stack without popping.
# 
#         :return: Value on the top of the stack.
#         :rtype: *
# 
#         :raises StackError: Raised when there is a stack underflow.
#         """
# 
#         if self.stack:
#             return self.stack[0]
#         else:
#             raise StackError("Stack empty")
# 
#     def is_empty(self):
#         """
#         Checks if the stack is empty.
# 
#         :return: True if the stack is empty, otherwise False.
#         :rtype: Boolean
#         """
# 
#         return self.stack == []
# 
#     def __str__(self):
#         """
#         Returns a string representation of the stack.
# 
#         @note: This assumes that the stack contents are capable of generating
#         string representations.
#         """
# 
#         if len(self.stack) == 0:
#             s = "[]"
#         else:
#             s = "[" + str(self.stack[0])
#             for i in range(1, len(self.stack)):
#                 s += ", " + str(self.stack[i])
#             s += "]"
#         return s
# 
#     def __repr__(self):
#         return self.__str__()


# Path: lems/parser/expr.py
from lems.base.base import LEMSBase
from lems.base.stack import Stack

                % (self.op_stack, self.val_stack, self.node_stack)
            )
        if self.debug:
            print("<<<<< Depth: %s, returning: %s" % (ExprParser.depth, ret))
        ExprParser.depth = ExprParser.depth - 1
        if self.debug:
            print("")
        return ret

    def parse(self):
        """
        Tokenizes and parses an arithmetic expression into a parse tree.

        :return: Returns a token string.
        :rtype: lems.parser.expr.ExprNode
        """
        # print("Parsing: %s"%self.parse_string)
        self.tokenize()
        if self.debug:
            print("Tokens found: %s" % self.token_list)

        try:
            parse_tree = self.parse2()
        except Exception as e:
            raise e
        return parse_tree

    def parse2(self):
        self.op_stack = Stack()
        self.val_stack = Stack()

        self.node_stack = Stack()