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
step0_repl.py
mal-py r1
import typing
def read(ins: str):
return ins
eval
step0_repl.py
mal-py r1
def evaluate(ins: str):
return ins
step0_repl.py
mal-py r1
def printit(ins: str):
return ins
rep
step0_repl.py
mal-py r1
def rep(ins: str):
return printit(evaluate(read(ins)))
repl
step0_repl.py
mal-py r1
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)