Пример #1
0
    def invoke(self, rdr, ch):
        form = read(rdr, True)

        with code.bindings(GEN_SYM_ENV, EMPTY_MAP):
            result = self.syntax_quote(form)

        return result
Пример #2
0
def _load_file(filename, compile=False):
    from pixie.vm.string import String
    from pixie.vm.util import unicode_from_utf8
    import pixie.vm.reader as reader
    import pixie.vm.libs.pxic.writer as pxic_writer


    affirm(isinstance(filename, String), u"filename must be a string")
    filename = str(rt.name(filename))

    if filename.endswith(".pxic"):
        load_pxic_file(filename)
        return nil

    if path.isfile(filename + "c") and not compile:
        load_pxic_file(filename + "c")
        return nil

    affirm(path.isfile(filename), unicode(filename) + u" does not exist")

    f = open(filename)
    data = f.read()
    f.close()



    if data.startswith("#!"):
        newline_pos = data.find("\n")
        if newline_pos > 0:
            data = data[newline_pos:]

    if compile:
        pxic_f = open(filename + "c", "wb")
        wtr = pxic_writer.Writer(pxic_f, True)
        with code.bindings(PXIC_WRITER, pxic_writer.WriterBox(wtr)):
            rt.load_reader(reader.MetaDataReader(reader.StringReader(unicode_from_utf8(data)), unicode(filename)))
        wtr.finish()
        pxic_f.close()
    else:
        with code.bindings(PXIC_WRITER, nil):
            rt.load_reader(reader.MetaDataReader(reader.StringReader(unicode_from_utf8(data)), unicode(filename)))


    return nil