Exemplo n.º 1
0
def fnReader(rdr, lparen):
    from py.clojure.lang.persistenthashmap import EMPTY
    from py.clojure.lang.var import popThreadBindings, pushThreadBindings

    if ARG_ENV.deref() is not None:
        raise IllegalStateException("Nested #()s are not allowed")
        #try:
    pushThreadBindings(RT.map(ARG_ENV, EMPTY))
    rdr.back()
    form = read(rdr, True, None, True)
    drefed = ARG_ENV.deref()
    sargs = sorted(list(filter(lambda x: x != -1, drefed)))
    args = []
    if len(sargs):
        for x in range(int(str(sargs[-1]))):
            if x in drefed:
                args.append(drefed[x])
            else:
                args.append(garg(x))
        retsym = drefed[-1]
        if retsym is not None:
            args.append(_AMP_)
            args.append(retsym)

    vargs = RT.vector(args)
    popThreadBindings()
    return RT.list(_FN_, vargs, form)
Exemplo n.º 2
0
 def __call__(self, r, backquote):
     pushThreadBindings(RT.map(GENSYM_ENV, EMPTY_MAP))
     try:
         self.rdr = r
         form = read(r, True, None, True)
         return self.syntaxQuote(form)
     finally:
         popThreadBindings()