Beispiel #1
0
def SpecificImport():
    yield ps.token(TOKEN.FROM)
    found_name = yield ps.token(TOKEN.FILENAME)
    yield ps.token(TOKEN.IMPORT)
    found_importlist = yield ImportListStrict
    return AST.IMPORT(name=found_name, importlist=found_importlist)
Beispiel #2
0
def AllImport():
    yield ps.token(TOKEN.IMPORTALL)
    found_name = yield ps.token(TOKEN.FILENAME)
    return AST.IMPORT(name=found_name, importlist=None)
Beispiel #3
0

def indent_print(temp, level):
    res = ""
    for el in temp:
        if type(el) == list:
            res += indent_print(el, level + 1)
        else:
            res += level * INDENT_CHARS + el + "\n"
    return res


if __name__ == "__main__":
    test = AST.SPL(
        imports=[
            AST.IMPORT(name=Token(None, TOKEN.IDENTIFIER, "stdlib"),
                       importlist=None),
            AST.IMPORT(name=Token(None, TOKEN.IDENTIFIER, "math"),
                       importlist=[
                           AST.IMPORTNAME(name=Token(None, TOKEN.IDENTIFIER,
                                                     "power"),
                                          alias=Token(None, TOKEN.IDENTIFIER,
                                                      "pow"))
                       ])
        ],
        decls=[
            AST.VARDECL(
                type=None,
                id=Token(None, TOKEN.IDENTIFIER, "temp"),
                expr=AST.DEFERREDEXPR(contents=[Token(None, TOKEN.INT, 2)])),
            AST.VARDECL(
                type=AST.TYPE(val=AST.BASICTYPE(