aboutsummaryrefslogtreecommitdiff
path: root/nim/step1_read_print.nim
blob: 4be58984a43db3d2aebe912d056bf4128f39e51d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import rdstdin, types, reader, printer

proc read(str: string): MalType = str.read_str

proc eval(ast: MalType): MalType = ast

proc print(exp: MalType): string = exp.pr_str

while true:
  try:
    let line = readLineFromStdin("user> ")
    echo line.read.eval.print
  except:
    echo getCurrentExceptionMsg()