Exemple #1
0
FUNCTION_STR = 'function()%s' % CONTEXT_STR
FUNCTION_AST = AST.FunctionDefinition([], False, CONTEXT_AST)

LIST_STR = '[%s, %s]' % (FUNCTION_STR, CONTEXT_STR)
LIST_AST = AST.List([FUNCTION_AST, CONTEXT_AST])

INSTANCE_OF_STR = '%s  instance  of  ala.ma.kota' % LIST_STR
# INSTANCE_OF_STR = '%s instance of ala.ma.kota' % LIST_STR
INSTANCE_OF_AST = AST.InstanceOf(LIST_AST, AST.Type([AST.Name('ala.ma.kota')]))

FILTER_EXPRESSION_STR = '%s [%s]' % (LIST_STR, INSTANCE_OF_STR)
FILTER_EXPRESSION_AST = AST.FilterExpression(LIST_AST, INSTANCE_OF_AST)

CONJUNCTION_STR = '%s and %s' % (operator_str_gen('='), INSTANCE_OF_STR)
CONJUNCTION_AST = AST.Conjunction(operator_ast_gen(AST.Eq), INSTANCE_OF_AST)

DISJUNCTION_STR = '%s  or %s' % (CONJUNCTION_STR, operator_str_gen('<='))
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'))
Exemple #2
0
 def test_conjunction(self):
     self.check_parser(CONJUNCTION_STR,
                       CONJUNCTION_AST)
     self.check_parser('%s and  %s' % (DATE_STR, DATE_STR),
                       AST.Conjunction(DATE_AST, DATE_AST))
Exemple #3
0
 def p_conjunction(self, p):
     """conjunction : expression AND expression"""
     p[0] = AST.Conjunction(p[1], p[3])