all repos — min @ 77b753fe9ce03c03e6ba5c02e5e8057c75a44076

A small but practical concatenative programming language.

Fixed sorting in completions.
h3rald h3rald@h3rald.com
Mon, 08 Dec 2014 17:35:31 +0100
commit

77b753fe9ce03c03e6ba5c02e5e8057c75a44076

parent

292224a42ebc3e1e47d3b1501d032a65ee3e7c66

3 files changed, 7 insertions(+), 7 deletions(-)

jump to
M interpreter.niminterpreter.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.nimminim.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.nimutils.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