Exemplo n.º 1
0
def compile_(output, filename):
    env = Env()
    with open(output, "w") as outfile:
        outfile.write(
            compile_list(parse(lex(pycell.library.as_text(env))), env))
        with open(filename, encoding="ascii") as infile:
            outfile.write(
                compile_list(parse(lex(chars_in_file(infile))), env))
Exemplo n.º 2
0
def repl(stdin, stdout, stderr):
    env = Env(parent=None, stdin=stdin, stdout=stdout, stderr=stderr)
    pycell.library.import_(env)
    while True:
        try:
            p = Prompt(stdout)
            for value in eval_iter(
                    parse(lex(p.handle_chars(chars_in_file(stdin)))), env):
                p.value(value)
            break
        except Exception as e:
            stderr.write(str(e))
            stderr.write("\n")
    stdout.write("\n")
    stdout.flush()
Exemplo n.º 3
0
def repl(stdin, stdout, stderr):
    env = Env(parent=None, stdin=stdin, stdout=stdout, stderr=stderr)
    pycell.library.import_(env)
    while True:
        try:
            p = Prompt(stdout)
            for value in eval_iter(
                    parse(lex(p.handle_chars(chars_in_file(stdin)))), env):
                p.value(value)
            break
        except Exception as e:
            stderr.write(str(e))
            stderr.write("\n")
    stdout.write("\n")
    stdout.flush()
Exemplo n.º 4
0
def All_examples_lex():
    from pycell.chars_in_file import chars_in_file
    for example in all_examples():
        with open(example, encoding="ascii") as f:
            lexed(chars_in_file(f))
Exemplo n.º 5
0
def run(filename, stdin, stdout, stderr):
    env = Env(stdin=stdin, stdout=stdout, stderr=stdout)
    pycell.library.import_(env)
    with open(filename, encoding="ascii") as f:
        eval_list(parse(lex(chars_in_file(f))), env)
Exemplo n.º 6
0
def All_examples_parse():
    from pycell.chars_in_file import chars_in_file
    for example in all_examples():
        with open(example, encoding="ascii") as f:
            parsed(chars_in_file(f))