Fixed sorting in completions.
h3rald h3rald@h3rald.com
Mon, 08 Dec 2014 17:35:31 +0100
3 files changed,
7 insertions(+),
7 deletions(-)
M
interpreter.nim
→
interpreter.nim
@@ -34,7 +34,7 @@ "Two numbers are required on the stack",
"Division by zero" ] -var SYMBOLS* = initTable[string, TMinOperator]() +var SYMBOLS* = initOrderedTable[string, TMinOperator]() var ALIASES* = newSeq[string](0) proc newMinInterpreter*(debugging = false): TMinInterpreter =
M
minim.nim
→
minim.nim
@@ -30,10 +30,6 @@ discard i.parser.getToken()
i.interpret() i.close() -proc handleReplCtrlC() {.noconv.}= - echo "\n-> Exiting..." - quit(0) - proc minimString*(buffer: string) = minimStream(newStringStream(buffer), "input")@@ -60,11 +56,10 @@ proc minimRepl*() =
var i = newMinInterpreter(debugging) var s = newStringStream("") i.open(s, "") - setControlCHook(handleReplCtrlC) echo "MiNiM v"&version&" - REPL initialized." i.eval prelude echo "Prelude loaded." - echo "-> Press Ctrl+C to exit." + echo "-> Type 'exit' or 'quit' to exit." discard linenoiseSetCompletionCallback completionCallback var line: cstring while true:
M
utils.nim
→
utils.nim
@@ -1,13 +1,18 @@
import tables, strutils import parser, interpreter +proc sortSymbols() = + SYMBOLS.sort(proc (a, b):int = return a.key.cmpIgnoreCase(b.key)) + template minsym*(name: string, body: stmt): stmt {.immediate.} = SYMBOLS[name] = proc (i: var TMinInterpreter) = body + sortSymbols() proc minalias*(newname: string, oldname: string) = SYMBOLS[newname] = SYMBOLS[oldname] ALIASES.add newname + sortSymbols() proc isSymbol*(s: TMinValue): bool = return s.kind == minSymbol