mal: Step 0

This step is the “Hello, world!” of the process, setting up a repl. Going by the architecture diagram, this stage it only needs to echo the input it receives

read

mal-py step0_repl.py
import typing

def read(ins: str):
    return ins

eval

mal-py step0_repl.py
def evaluate(ins: str):
    return ins

print

mal-py step0_repl.py
def printit(ins: str):
    return ins

rep

mal-py step0_repl.py
def rep(ins: str):
    return printit(evaluate(read(ins)))

repl

mal-py step0_repl.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)