Exemplo n.º 1
0
def parse_alias_import_star(s):
    alias_import_star = (pseq("import") >> spc1 >> one(__ == "*") >> spc1 >>
                         pseq("as") >> spc1 >> symbolname)
    from_file = spc1 >> pseq("from") >> spc1 >> filename << spc << one(
        __ == ";")
    sym, rest < -alias_import_star(s)
    fname, _ < -from_file(rest)
    return AliasImport(fname, sym)
Exemplo n.º 2
0
def parse_sym_lst_import(s):
    symlst, rest < -(pseq("import") >> spc >> one(__ == "{") >> spc >>
                     parse_sym_lst << spc << one(__ == "}"))(s)
    fname, _ < -(
        spc >> pseq("from") >> spc1 >> filename << spc << one(__ == ";"))(rest)
    return SymImport(fname, symlst)
Exemplo n.º 3
0
def parse_sym_import(s):
    sym, rest < -symbolname(s)
    alias, rest < -(pmaybe(spc1 >> pseq("as") >> spc1 >> symbolname))(rest)
    if alias:
        return [AliasSym(sym, alias)], rest
    return [PlainSym(sym)], rest
Exemplo n.º 4
0
def parse_alias_import_as(s):
    from_file = pseq("import") >> spc1 >> filename << spc << pseq("as")
    symname = spc1 >> symbolname << spc << one(__ == ";")
    fname, rest < -from_file(s)
    sym, _ < -symname(rest)
    return AliasImport(fname, sym)
Exemplo n.º 5
0
def parse_pure_import(s):
    pure_import = pseq("import") >> spc1 >> filename << spc << one(__ == ";")
    fname, rest < -pure_import(s)
    return PureImport(fname)