nondescript/src/ndspkg/config.nim

33 lines
1.0 KiB
Nim
Raw Normal View History

2022-01-20 21:54:11 +01:00
type
LineEditorChoice = enum
leBasic, leRdstdin
ReadlineInterruptedException* = object of CatchableError
# compiler debug options
2022-01-20 21:54:11 +01:00
const debugScanner* = false
const debugCompiler* = false
2022-01-28 22:00:21 +01:00
const debugDumpChunk* = defined(debug)
const assertionsCompiler* = true # sanity checks in the compiler
# vm debug options (setting any to true will slow runtime down!)
2022-01-29 07:24:58 +01:00
const debugVM* = defined(debug)
const assertionsVM* = defined(debug) # sanity checks in the VM, such as the stack being empty at the end
2022-01-29 22:33:34 +01:00
const profileInstructions* = defined(ndsprofile) # if true, the time spent on every opcode is measured
2022-01-28 22:00:21 +01:00
2022-01-20 21:54:11 +01:00
# choose a line editor for the repl
const lineEditor = leRdstdin
when lineEditor == leRdstdin:
import rdstdin
2022-01-27 05:56:09 +01:00
proc ndLineEditor*: string =
2022-01-20 21:54:11 +01:00
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