Ejemplo n.º 1
0

DATE_STR = 'date("1")'
DATE_AST = AST.Date('1')

NAME_STR = 'ala ma kota'
NAME_AST = AST.Name(NAME_STR)

CONTEXT_STR = '{%s:%s}' % (NAME_STR, DATE_STR)
CONTEXT_AST = AST.Context([(NAME_AST, DATE_AST)])

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)
Ejemplo n.º 2
0
 def test_list(self):
     self.check_parser(LIST_STR, LIST_AST)
     self.check_parser('[]', AST.List([]))
Ejemplo n.º 3
0
 def p_list(self, p):
     """list : '[' positional_parameters ']'"""
     p[0] = AST.List(p[2])