all repos — min @ 588d21699763d0c7e769c8bcbce82d50514fe2d0

A small but practical concatenative programming language.

Automatically converting JSON keys to valid symbols.
h3rald h3rald@h3rald.com
Sat, 02 Jun 2018 15:36:59 +0200
commit

588d21699763d0c7e769c8bcbce82d50514fe2d0

parent

72fe18d527b65e73605c84e3bfce8603b41f9230

2 files changed, 14 insertions(+), 4 deletions(-)

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

@@ -634,9 +634,13 @@ return q

of minDictionary: var d = "{" for i in a.dVal.pairs: - var v = $i.val.val - if (not i.val.quotation): - v = v[1 .. v.len-2] + var v = "" + if i.val.kind == minProcOp: + v = "<compiled>" + else: + v = $i.val.val + if (not i.val.quotation): + v = v[1 .. v.len-2] d = d & v & " :" & $i.key & " " if not a.objType.isNil: d = d & ";" & a.objType
M core/utils.nimcore/utils.nim

@@ -170,7 +170,13 @@ result = json.getStr.newVal

of JObject: var res = newDict(i.scope) for key, value in json.pairs: - discard i.dset(res, key, i.fromJson(value)) + var first = $key[0] + var rest = "" + if key.len > 1: + rest = key[1..key.len-1] + first = sgregex.replace(first, "[^a-zA-Z_]", "_") + rest = sgregex.replace(rest, "[^a-zA-Z0-9/!?+*._-]", "_") + discard i.dset(res, first&rest, i.fromJson(value)) return res of JArray: var res = newSeq[MinValue](0)