Ejemplo n.º 1
0
def symtree(t):
    if not isinstance(t, list):
        return t
    if t[0] in sym_name:
        return [(sym_name.get(t[0]), t[0])] + list(map(symtree, t[1:]))
    elif t[0] in tok_name:
        return [(tok_name.get(t[0]), t[0])] + list(map(symtree, t[1:]))
    else:
        assert 0, t
Ejemplo n.º 2
0
def name(elt):
    return "%s[%s]"% (sym_name.get(elt,elt),elt)