~deciduously/nlox

ref: 6dc0caee503234b11cc7f326eee36e66e02baa7e nlox/src/nloxpkg/lox.nim -rw-r--r-- 374 bytes
6dc0caeeBen Lovy CLI 5 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#! The top-level of the Lox interpreter.

# Interpret Lox input, results to stdout
proc run(source: string) =
    echo source

# Interpret a source file
proc run_file*(path: string) =
    run(readFile(path))

# Open a REPL
proc run_prompt*() =
    while true:
        stdout.write("> ")
        let line = stdin.readLine()
        if line.len() == 0: break
        run(line)