class parseInput:
    
    # Lists used to place parsed objects
    objects = []
    seperators = []
    parsedObjects = [] # Parsed objects multidimential array containing number, variable, exponent

    def __init__(self, equation):
        self.equation = equation

    def parseInput(self): 
        theEq = self.equation.replace(" ", "")
        errorOccured = False

        symbols = []
        allowedSymbols = ["x", "^", "+", "-", "*", "/"]

        # Check if symbols are allowed or if there is an error
        for symbol in theEq:
            try:
                if (int(symbol) >= 0 or int(symbol) <= 0):
                    symbols.append(symbol)

                else:
                    print("error")

            except ValueError:
                # Check if the symbol is in the allowed symbols, otherwise ignore it and display error
                if (symbol in allowedSymbols):
                    symbols.append(symbol)

                else:
                    print ("Error symbol " + symbol + " is undefined")
                    errorOccured = True
        
        # If there were no errors continue to parse the symbols into objects and seperators
        if not (errorOccured):
            seperatingSymbols = ["+", "-", "/", "*"]
            objectString = ""

            for symbol in symbols:
                if (symbol not in seperatingSymbols):
                    objectString += symbol
                else:
                    self.objects.append(objectString)
                    self.seperators.append(symbol)
                    objectString = ""
            
            self.objects.append(objectString)
    
    # Parse the objects and place them in parsedObjects array
    def parseObjects(self):
        for obj in self.objects:
            print (obj)

        number = None
        variable = None
        exponent = None
        
       

# Calculate an indefinite derivative
class indefinite:
    # Functions that return solutions based on the rule
    def solveNormal(self, equation):
        if ("x" in equation):
            print ("contains x")
            print (equation)
        else:
            print ("no variable contained")
            print (equation)
    
    # Calculate an indefinite derivative
    def calcDivI(self):
        print (self.objects)
        print (self.seperators)
        
        # Order of operations needs to be implemented here
        for count, sep in enumerate(self.seperators):
            if sep == "+":
                self.solveNormal(self.objects[count])
            elif sep == "-":
                print ("-")

            self.calcDivI()

    # When the class is created, initiate it by setting the equation equal to the paremeter sent
    def __init__ (self, equation):
        self.equation = equation

# Calculate the definite integral
class definiteIntegral:
    def __init__ (self, string):
        print (string)

# tests
def tests():
#    t = indefinite("55x + 5x * 5x")
#    t.parseInput()
    t = parseInput("55x + 5x * 5x")   
    t.parseInput()
    t.parseObjects()
tests()
