Exemple #1
0
def maybe_oop_invoke(form):
    head = rt.first(form)
    if isinstance(rt.first(form), symbol.Symbol) and rt.name(head).startswith(".-"):
        postfix = rt.next(form)
        affirm(rt.count(postfix) == 1, u" Attribute lookups must only have one argument")
        subject = rt.first(postfix)
        kw = keyword(rt.name(head)[2:])
        fn = symbol.symbol(u"pixie.stdlib/-get-attr")
        return create_from_list([fn, subject, kw])

    elif isinstance(rt.first(form), symbol.Symbol) and rt.name(head).startswith("."):
        subject = rt.first(rt.next(form))
        postfix = rt.next(rt.next(form))
        form = cons(keyword(rt.name(head)[1:]), postfix)
        form = cons(subject, form)
        form = cons(symbol.symbol(u"pixie.stdlib/-call-method"), form)
        return form

    else:
        return form
Exemple #2
0
    def invoke(self, rdr, ch):
        lst = []
        while True:
            eat_whitespace(rdr)
            ch = rdr.read()
            if ch == u")":
                acc = nil
                for x in range(len(lst) - 1, -1, -1):
                    acc = cons(lst[x], acc)
                return acc

            rdr.unread(ch)
            lst.append(read(rdr, True))
Exemple #3
0
    def invoke(self, rdr, ch):
        lst = []
        while True:
            try:
                eat_whitespace(rdr)
            except EOFError:
                throw_syntax_error_with_data(rdr, u"Unmatched list open '('")
            ch = rdr.read()

            if ch == u")":
                if len(lst) == 0:
                    return EmptyList()
                acc = nil
                for x in range(len(lst) - 1, -1, -1):
                    acc = cons(lst[x], acc)
                return acc
            
            rdr.unread()

            itm = read_inner(rdr, True, always_return_form=False)
            if itm != rdr:
                lst.append(itm)
Exemple #4
0
 def invoke(self, rdr, ch):
     itm = read(rdr, True)
     return cons(symbol(u"quote"), cons(itm))
Exemple #5
0
 def invoke(self, rdr, ch):
     itm = read_inner(rdr, True)
     return cons(symbol(u"quote"), cons(itm))