Exemple #1
0
def _lift_procedure_decl(location, *args):
    assert len(args) in (1, 2)
    if len(args) == 2:
        id, procedure_defn = args
        return Procedure(id, procedure_defn.includes, procedure_defn.methods,
                         procedure_defn.attributes, location)
    return args[0]
Exemple #2
0
def dummy_ast():
    '''
    A simple AST we can use for testing basic functionality.
    '''
    p = Procedure()
    l = LiftedAST([p])
    return l
Exemple #3
0
def p_procedure_block(t):
    '''procedure_block : LBRACE procedure_defn RBRACE'''
    includes, methods, attributes = t[2]
    assert isinstance(methods, list)
    for i in methods: assert isinstance(i, Method)
    assert isinstance(attributes, list)
    for i in attributes: assert isinstance(i, Attribute)
    t[0] = Procedure(None, includes, methods, attributes, filename=t.lexer.filename, \
        lineno=t.lexer.lineno)
Exemple #4
0
def _lift_procedure_defn(location, *args):
    return Procedure(includes=[x for x in args if isinstance(x, Include)],
                     methods=[x for x in args if isinstance(x, Method)],
                     attributes=[x for x in args if isinstance(x, Attribute)],
                     location=location)