37 lines
1.2 KiB
Nim
37 lines
1.2 KiB
Nim
type
|
|
LineEditorChoice = enum
|
|
leBasic, leRdstdin
|
|
ReadlineInterruptedException* = object of CatchableError
|
|
|
|
# compiler debug options
|
|
const debugScanner* = false
|
|
const debugCompiler* = false
|
|
const debugDumpChunk* = defined(debug)
|
|
const assertionsCompiler* = true # sanity checks in the compiler
|
|
# vm debug options (setting any to true will slow runtime down!)
|
|
const debugVM* = defined(debug)
|
|
const assertionsVM* = defined(debug) # sanity checks in the VM, such as the stack being empty at the end
|
|
const profileInstructions* = false # if true, the time spent on every opcode is measured
|
|
|
|
const compileTests* = defined(debug)
|
|
# if true, the nim part of the test suite will be compiled in main
|
|
# it will be possible to start it using ./nds --test
|
|
|
|
# choose a line editor for the repl
|
|
const lineEditor = leRdstdin
|
|
|
|
when lineEditor == leRdstdin:
|
|
import rdstdin
|
|
|
|
proc ndLineEditor*: string =
|
|
proc ctrlc =
|
|
raise newException(ReadlineInterruptedException, "Ctrl+C/D pressed.")
|
|
when lineEditor == leBasic:
|
|
write stdout, "\r-> "
|
|
result = stdin.readLine()
|
|
when lineEditor == leRdstdin:
|
|
var line: string
|
|
let ok = readLineFromStdin("-> ", line)
|
|
if not ok:
|
|
ctrlc()
|
|
return line |