mal: Step 1ΒΆ
- in-project:
mal-py
- in-file:
step1_read_print.py
Not much to see here for this stage, most of the work happened in The mal Reader
read
step1_read_print.py
mal-py r1
from reader import read_str
def read(ins):
return read_str(ins)
eval
step1_read_print.py
mal-py r1
def evaluate(form):
return form
step1_read_print.py
mal-py r1
from printer import print_form
def printit(form):
return print_form(form)
rep
step1_read_print.py
mal-py r1
def rep(ins: str):
try:
return printit(evaluate(read(ins)))
except EOFError:
return f"EOF"
repl
step1_read_print.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)