all repos — min @ 3d1459a90e6ebb13dd9bd60dab55531ab85f36a1

A small but practical concatenative programming language.

Removed coroutines for now; implemented reg and unreg.
h3rald h3rald@h3rald.com
Sun, 10 Jul 2016 13:15:31 +0200
commit

3d1459a90e6ebb13dd9bd60dab55531ab85f36a1

parent

27dc3b13e3ec84460db5ddc8a134e9d4a30f400d

5 files changed, 21 insertions(+), 7 deletions(-)

jump to
M core/server.nimcore/server.nim

@@ -70,10 +70,11 @@

proc syncHosts*(i: MinInterpreter): CritBitTree[string] {.gcsafe.}= var cmd = "" for key, val in i.link.hosts.pairs: - cmd = cmd & """ ('$1 '$2)""" % [key, val] + cmd = cmd & """ ($1 "$2")""" % [key, val] cmd = "(" & cmd.strip & ") set-hosts" for key, val in i.link.hosts.pairs: - result[key] = i.remoteExec(key, cmd) + if key != i.link.name: + result[key] = i.remoteExec(key, cmd) proc newMinLink*(name, address: string, port: int, i: var MinInterpreter): ref MinLink = var link: ref MinLink = new MinLink
M core/utils.nimcore/utils.nim

@@ -95,6 +95,11 @@ return scope #### was: ROOT

else: return scope.parent +proc replace*[T](c: var CritBitTree, s: string, v: T): T {.discardable.}= + if c.hasKey(s): + c.excl(s) + c[s] = v + proc define*(i: In, name: string): ref MinScope = var scope = new MinScope scope.name = name
M lib/min_comm.nimlib/min_comm.nim

@@ -18,15 +18,22 @@ i.reqTwoStringLike(host, address)

i.link.hosts[host.getString] = address.getString for host, response in i.syncHosts().pairs: echo host, ": ", response + + .symbol("unreg") do (i: In): + i.link.hosts.excl(i.link.name) + for host, response in i.syncHosts().pairs: + echo host, ": ", response .symbol("set-hosts") do (i: In): var q: MinValue i.reqQuotation(q) + for key, val in i.link.hosts.pairs: + i.link.hosts.excl(key) for pair in q.qVal: let vals = pair.qVal if not pair.isQuotation or vals.len != 2 or not vals[0].isStringLike or not vals[1].isStringLike: raiseInvalid("Invalid host quotation") - i.link.hosts[vals[0].getString] = vals[1].getString + i.link.hosts.replace(vals[0].getString, vals[1].getString) i.push("OK".newVal) .symbol("hosts") do (i: In):

@@ -36,6 +43,6 @@ q.qVal.add(@[key.newSym, val.newSym].newVal)

i.push q .symbol("host") do (i: In): - i.push i.link.name.newVal + i.push i.link.name.newSym .finalize()
M lib/min_lang.nimlib/min_lang.nim

@@ -4,8 +4,8 @@ ../core/types,

../core/parser, ../core/interpreter, ../core/utils, - ../core/regex, - ../vendor/routine + ../core/regex + #../vendor/routine proc lang_module*(i: In) =
M minim.nimminim.nim

@@ -51,7 +51,8 @@ -v, --version Print the program version

-i, --interactive Start MiNiM's Read Eval Print Loop""" proc completionCallback*(str: cstring, completions: ptr linenoiseCompletions) {.cdecl.}= - var words = ($str).split(" ") + discard + #var words = ($str).split(" ") #var w = if words.len > 0: words.pop else: "" #var sep = "" #if words.len > 0: