示例#1
0
 def test_named_parameters(self):
     self.check_parser('%s(ala: %s)' % (PATH_STR, INVOCATION_STR),
                       AST.Invocation(PATH_AST, [(AST.Name('ala'), INVOCATION_AST)]))
     self.check_parser('%s(ala : %s, ola :%s)' % ((DATE_STR,) * 3),
                       AST.Invocation(DATE_AST,
                                      [(AST.Name('ala'), DATE_AST), (AST.Name('ola'), DATE_AST)]))
示例#2
0
DISJUNCTION_AST = AST.Disjunction(CONJUNCTION_AST, operator_ast_gen(AST.Lte))

QUANTIFIED_STR = 'some  ala  in %s satisfies %s' % (DISJUNCTION_STR, CONJUNCTION_STR)
QUANTIFIED_AST = AST.QuantifiedExpr(True, [(AST.Name('ala'), DISJUNCTION_AST)], CONJUNCTION_AST)

IF_STR = 'if  %s  then %s else %s' % (QUANTIFIED_STR, DISJUNCTION_STR, CONJUNCTION_STR)
IF_AST = AST.If(QUANTIFIED_AST, DISJUNCTION_AST, CONJUNCTION_AST)

FOR_STR = 'for  ala  in  %s  return  %s' % (IF_STR, QUANTIFIED_STR)
FOR_AST = AST.For([(AST.Name('ala'), IF_AST)], QUANTIFIED_AST)

PATH_STR = '%s.ala' % DATE_STR
PATH_AST = AST.Path(DATE_AST, AST.Name('ala'))

INVOCATION_STR = '%s(%s, %s)' % (PATH_STR, FOR_STR, IF_STR)
INVOCATION_AST = AST.Invocation(PATH_AST, [FOR_AST, IF_AST])

NEGATION_STR = '-?A_zÊÝĄͼൺ⁶Ⰲ〠邏2𐎅'
NEGATION_AST = AST.Negation(AST.Name('?A_zÊÝĄͼൺ⁶Ⰲ〠邏2𐎅'))

ARITHMETIC_EXPRESSION_STR = '1.2-%s  /true  **%s' % (NEGATION_STR, NAME_STR)
ARITHMETIC_EXPRESSION_AST = AST.Dif(AST.Number(1.2), AST.Div(NEGATION_AST, AST.Exp(AST.Boolean(True), NAME_AST)))

NOT_STR = 'not (null)'
NOT_AST = AST.Not(AST.PositiveUnaryTests([AST.Null()]))

POSITIVE_UNARY_TESTS_STR = '%s  in (null, null)' % ARITHMETIC_EXPRESSION_STR
POSITIVE_UNARY_TESTS_AST = AST.In(ARITHMETIC_EXPRESSION_AST, AST.PositiveUnaryTests([AST.Null()] * 2))

POSITIVE_UNARY_TEST_STR = '%s in (null, %s)' % (POSITIVE_UNARY_TESTS_STR, DATE_STR)
POSITIVE_UNARY_TEST_AST = AST.In(POSITIVE_UNARY_TESTS_AST, AST.PositiveUnaryTests([AST.Null(), AST.Endpoint(DATE_AST)]))
示例#3
0
 def test_positional_parameters(self):
     self.check_parser('%s()       ' % PATH_STR,
                       AST.Invocation(PATH_AST, []))
     self.check_parser('%s(%s)    ' % (PATH_STR, FOR_STR),
                       AST.Invocation(PATH_AST, [FOR_AST]))
     self.check_parser(INVOCATION_STR, INVOCATION_AST)
示例#4
0
 def p_function_invocation(self, p):
     """function_invocation : expression parameters"""
     p[0] = AST.Invocation(p[1], p[2])