Ejemplo n.º 1
0
def read_inner(rdr, error_on_eof, always_return_form=True):
    try:
        eat_whitespace(rdr)
    except EOFError as ex:
        if error_on_eof:
            runtime_error(u"Unexpected EOF while reading",
                          u"pixie.stdlib/EOFWhileReadingException")
        return eof



    ch = rdr.read()
    if isinstance(rdr, MetaDataReader):
        meta = rdr.get_metadata()
    else:
        meta = nil

    macro = handlers.get(ch, None)
    if macro is not None:
        itm = macro.invoke(rdr, ch)
        if always_return_form and itm == rdr:
            return read_inner(rdr, error_on_eof, always_return_form=always_return_form)


    elif is_digit(ch):
        itm = read_number(rdr, ch)

    elif ch == u"-":
        ch2 = rdr.read()
        if is_digit(ch2):
            rdr.unread()
            itm = read_number(rdr, ch)

        else:
            rdr.unread()
            itm = read_symbol(rdr, ch)

    else:
        itm = read_symbol(rdr, ch)

    if itm != rdr:
        if rt.has_meta_QMARK_(itm):
            itm = rt.with_meta(itm, rt.merge(meta, rt.meta(itm)))

    return itm
Ejemplo n.º 2
0
def read(rdr, error_on_eof):
    try:
        eat_whitespace(rdr)
    except EOFError as ex:
        if error_on_eof:
            raise ex
        return eof



    ch = rdr.read()
    if isinstance(rdr, MetaDataReader):
        meta = rdr.get_metadata()
    else:
        meta = nil

    macro = handlers.get(ch, None)
    if macro is not None:
        itm = macro.invoke(rdr, ch)

    elif is_digit(ch):
        itm = read_number(rdr, ch)

    elif ch == u"-":
        ch2 = rdr.read()
        if is_digit(ch2):
            rdr.unread(ch2)
            itm = read_number(rdr, ch)

        else:
            rdr.unread(ch2)
            itm = read_symbol(rdr, ch)

    else:
        itm = read_symbol(rdr, ch)

    if rt.has_meta_QMARK_(itm):
        itm = rt.with_meta(itm, rt.merge(meta, rt.meta(itm)))

    return itm
Ejemplo n.º 3
0
def read(rdr, error_on_eof):
    try:
        eat_whitespace(rdr)
    except EOFError as ex:
        if error_on_eof:
            raise ex
        return eof

    ch = rdr.read()
    if isinstance(rdr, MetaDataReader):
        meta = rdr.get_metadata()
    else:
        meta = nil

    macro = handlers.get(ch, None)
    if macro is not None:
        itm = macro.invoke(rdr, ch)

    elif is_digit(ch):
        itm = read_number(rdr, ch)

    elif ch == u"-":
        ch2 = rdr.read()
        if is_digit(ch2):
            rdr.unread(ch2)
            itm = read_number(rdr, ch)

        else:
            rdr.unread(ch2)
            itm = read_symbol(rdr, ch)

    else:
        itm = read_symbol(rdr, ch)

    if rt.has_meta_QMARK_(itm):
        itm = rt.with_meta(itm, rt.merge(meta, rt.meta(itm)))

    return itm