예제 #1
0
    def _select_expression(self):
        """
        SelectExpression : SELECT Condition (Expression)
        """

        self.consume(SELECT)
        condition = self._condition()
        # Bool operation
        bool_op = None
        if self.token.type in (AND, OR):
            bool_op = BoolOp()
            bool_op.conditions.append(condition)

            while self.token.type in (AND, OR):
                op = self.token.value
                self.consume(KEYWORDS.get(op))
                bool_op.ops.append(op)
                bool_op.conditions.append(self._condition())

        if bool_op is not None:
            condition = bool_op
        # FIXME: puede venir otra CONDITION
        self.consume(LPAREN)
        expression = self._expression()
        self.consume(RPAREN)
        return SelectExpr(condition, expression)
예제 #2
0
    def _select_expression(self):
        """
        SelectExpression : SELECT Condition (Expression)
        """

        self.consume(SELECT)
        condition = self._condition()
        # Bool operation
        bool_op = None
        if self.token.type in (AND, OR):
            bool_op = BoolOp()
            bool_op.conditions.append(condition)

            while self.token.type in (AND, OR):
                op = self.token.value
                self.consume(KEYWORDS.get(op))
                bool_op.ops.append(op)
                bool_op.conditions.append(self._condition())

        if bool_op is not None:
            condition = bool_op
        # FIXME: puede venir otra CONDITION
        self.consume(LPAREN)
        expression = self._expression()
        self.consume(RPAREN)
        return SelectExpr(condition, expression)
예제 #3
0
    def _binary_expression(self, left_node):
        """
        BinaryExpression : (Expression) BinaryOp (Expression)
        """

        operator = self.token
        self.consume(KEYWORDS.get(operator.value))
        right_node = self._expression()
        return BinaryOp(left_node, operator, right_node)
예제 #4
0
    def _binary_expression(self, left_node):
        """
        BinaryExpression : (Expression) BinaryOp (Expression)
        """

        operator = self.token
        self.consume(KEYWORDS.get(operator.value))
        right_node = self._expression()
        return BinaryOp(left_node, operator, right_node)