mal: Step 1ΒΆ

project:

mal-py

filename:

step1_read_print.py

Not much to see here for this stage, most of the work happened in The mal Reader

read

mal-py step1_read_print.py
from reader import read_str

def read(ins):
    return read_str(ins)

eval

mal-py step1_read_print.py
def evaluate(form):
    return form

print

mal-py step1_read_print.py
from printer import print_form

def printit(form):
    return print_form(form)

rep

mal-py step1_read_print.py
def rep(ins: str):
    try:
        return printit(evaluate(read(ins)))
    except EOFError:
        return f"EOF"

repl

mal-py step1_read_print.py
def repl(ins: io.TextIO):
    print("user> ", end='', flush=True)
    while (line := ins.readline()) != "":
        print(rep(line))
        print("user> ", end='', flush=True)


if __name__ == "__main__":
    import sys
    repl(sys.stdin)