nondescript/src/ndspkg/config.nim

32 lines
1.1 KiB
Nim

type
LineEditorChoice = enum
leBasic, leRdstdin
ReadlineInterruptedException* = object of CatchableError
const debugDumpAst* = defined(debug) # dump AST after parsing
const debugDumpChunk* = defined(debug) # dump emitted chunk
# vm debug options (setting any to true will slow runtime down!)
const debugVM* = defined(debug)
const assertionsVM* = defined(debug) or defined(release) # sanity checks in the VM, such as the stack being empty at the end
const boundsChecks* = defined(debug) or defined(release)
const profileInstructions* = defined(ndsprofile) # if true, the time spent on every opcode is measured
const debugClosures* = defined(debug) # specific closure debug switches
# 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