all repos — min @ fa95bff79d6259fe18ef6aa1233bd212657e21bd

A small but practical concatenative programming language.

Fixed dget to always unquote value.
h3rald h3rald@h3rald.com
Sat, 26 May 2018 18:09:00 +0200
commit

fa95bff79d6259fe18ef6aa1233bd212657e21bd

parent

964bf6a67ec832713a3aec5eaa8eaa4173886ffc

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

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

@@ -50,8 +50,7 @@

proc dget*(q: MinValue, s: MinValue): MinValue {.extern:"min_exported_symbol_$1".}= if not q.isDictionary: raiseInvalid("Value is not a dictionary") - let val = q.dVal[s.getString] - return val.val.qVal[0] + return q.dVal[s.getString].val proc dhas*(q: MinValue, s: MinValue): bool {.extern:"min_exported_symbol_$1".}= if not q.isDictionary:
M lib/min_seq.nimlib/min_seq.nim

@@ -352,7 +352,8 @@ def.symbol("dget") do (i: In):

let vals = i.expect("'sym", "dict") let k = vals[0] let d = vals[1] - i.push d.dget(k) + var val = d.dget(k) + i.dequote val # Dictionary values are always quoted def.symbol("dset") do (i: In): let vals = i.expect("'sym", "a", "dict")
M min.nimmin.nim

@@ -218,6 +218,18 @@ echo " ".repeat(n.len) & " )"

else: echo " ".repeat(n.len) & " ;" & res.objType echo " ".repeat(n.len) & " )" + elif res.isDictionary and res.dVal.len > 1: + echo "{$1} -> {" % n + for item in res.dVal.pairs: + var v = $item.val.val + if (not item.val.quotation): + v = v[1 .. v.len-2] + echo " " & v & " :" & $item.key + if res.objType.isNil: + echo " ".repeat(n.len) & " }" + else: + echo " ".repeat(n.len) & " ;" & res.objType + echo " ".repeat(n.len) & " }" else: echo "{$1} -> $2" % [$i.stack.len, $i.stack[i.stack.len - 1]]