Example #1
0
def _import(context, source_file):
    global import_cache
    canonical_module_name = os.path.abspath(source_file.v)

    if canonical_module_name not in import_cache:
        try:
            program = parse_program(open(canonical_module_name, 'r').read())
        except IOError:
            raise LispRuntimeError('IMPORT: invalid file to load "%s"' % canonical_module_name)
        eval_library(context, canonical_module_name, program)

    context.update(import_cache[canonical_module_name])
    return NIL()
Example #2
0
from parse import parse_program

if __name__ == "__main__":
    import sys

    fn = sys.argv[1]
    inp = open(fn, "r").read()
    print repr(parse_program(inp))