39 lines
1.3 KiB
Nim
39 lines
1.3 KiB
Nim
type
|
|
LineEditorChoice = enum
|
|
leBasic, leRdstdin
|
|
ReadlineInterruptedException* = object of CatchableError
|
|
|
|
const debugDumpChunk* = defined(debug)
|
|
# 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
|
|
|
|
type compMode* = enum
|
|
cmOne, cmAst, cmTwo
|
|
const compilerChoice* = cmTwo
|
|
# choose a compiler: cmOne - version 1, deprecated
|
|
# cmAst - version 2, but only use parser and print AST produced
|
|
# cmOne will be removed once compv2 is done
|
|
# cmTwo - compv2 + execute
|
|
|
|
# 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 |