コード例 #1
0
    def parse(tokens):
        expr = RelationalExpression.parse(tokens)
        if expr is None:
            return None

        while True:
            peek = tokens.peek()
            if peek == 'and' or peek == 'or':
                tokens.getNext()
                rhs = RelationalExpression.parse(tokens)
                if rhs is None:
                    raise error.SyntaxError, 'Expected expression, got %r' % tokens.peek()
                expr = LogicalExpression(expr, rhs, peek)
            return expr
コード例 #2
0
 def testGreaterThanEqualTo(self):
     tokens = lex('1 >= 2')
     r = RelationalExpression.parse(tokens)
     self.failUnless(isinstance(r,RelationalExpression), r)
コード例 #3
0
 def testNotEqualTo(self):
     tokens = lex('1 != 2')
     r = RelationalExpression.parse(tokens)
     self.failUnless(isinstance(r,RelationalExpression), r)
コード例 #4
0
 def testLessThan(self):
     tokens = lex('1 < 2')
     r = RelationalExpression.parse(tokens)
     self.failUnless(isinstance(r,RelationalExpression), r)