Ejemplo n.º 1
0
 def parseTerm(self):
     left = self.parseFactor()
     oplex = self.lexAnalizer.getLex()
     leftpoints = [left]
     if oplex.type == "Delimiter" and oplex.lex == ".":
         self.curlex = self.lexAnalizer.nextLex()
         right = self.parseTerm()
         leftpoints = [Node.RecordNode(oplex, leftpoints, right)]
     while oplex.type == "Operator" or oplex.type == "Key Word":
         if oplex.lex.lower() in [
                 '*', '/', 'div', 'mod', 'as', 'is', 'and'
         ]:
             self.curlex = self.lexAnalizer.nextLex()
             right = self.parseFactor()
             self.checkNodeType([Node.NullNode], right)
             leftpoints = [Node.BinOpNode(oplex, leftpoints, right)]
             oplex = self.lexAnalizer.getLex()
         else:
             return leftpoints[0]
     return leftpoints[0]
Ejemplo n.º 2
0
 def parseExpression(self):
     left = self.parseTerm()
     oplex = self.lexAnalizer.getLex()
     leftpoints = left
     while (oplex.type == "Operator" or oplex.type
            == "Key Word") and oplex.lex.lower() in ['+', '-', 'or', 'xor']:
         self.curlex = self.lexAnalizer.nextLex()
         right = self.parseTerm()
         self.checkNodeType([Node.NullNode], right)
         leftpoints = Node.BinOpNode(oplex, [leftpoints], right)
         oplex = self.lexAnalizer.getLex()
     if (oplex.type == "Operator"
             or oplex.type == "Key Word") and oplex.lex.lower() in [
                 '=', '<>', '<', '>', '>=', '<=', 'in'
             ]:
         self.curlex = self.lexAnalizer.nextLex()
         right = self.parseExpression()
         self.checkNodeType([Node.NullNode], right)
         return Node.BoolOpNode(oplex, [leftpoints], [right])
     return leftpoints