all repos — min @ c087434a201a518167dca3247260ae4a2077802c

A small but practical concatenative programming language.

Added line-info, dswrite!, dsdelete!
h3rald h3rald@h3rald.com
Fri, 08 Jan 2021 20:34:27 +0100
commit

c087434a201a518167dca3247260ae4a2077802c

parent

ca018c34568d8abae090a61bfc43ca37e3ddc46d

M minpkg/lib/min_dstore.nimminpkg/lib/min_dstore.nim

@@ -20,7 +20,7 @@ i.dset(d, "data", newDict(i.scope))

i.dset(d, "path", p.newVal) d.objType = "datastore" i.push d - + def.symbol("dsread") do (i: In): let vals = i.expect("'sym") let p = vals[0].getString

@@ -38,6 +38,10 @@ let p = i.dget(ds, "path".newVal).getString

let data = i%(i.dget(ds, "data".newVal)) p.writeFile(data.pretty) i.push ds + + def.symbol("dswrite!") do (i: In): + i.pushSym "dswrite" + i.pushSym "pop" def.symbol("dshas?") do (i: In): let vals = i.expect("'sym", "dict:datastore")

@@ -103,9 +107,8 @@ if not dhas(data, collection):

i.dset(data, collection, newDict(i.scope)) var cll = i.dget(data, collection) i.dset(cll, id, d) - #i.dset(ds, "data", data) i.push ds - + def.symbol("dsput") do (i: In): let vals = i.expect("dict", "'sym", "dict:datastore") var d = vals[0]

@@ -138,5 +141,9 @@ raiseInvalid("Collection '$#' does not exist" % collection)

var cll = i.dget(data, collection) i.ddel(cll, id) i.push ds + + def.symbol("dsdelete!") do (i: In): + i.pushSym "dsdelete" + i.pushSym "pop" def.finalize("dstore")
M minpkg/lib/min_lang.nimminpkg/lib/min_lang.nim

@@ -931,6 +931,13 @@

def.symbol("compiled?") do (i: In): i.push MINCOMPILED.newVal + def.symbol("line-info") do (i: In): + var d = newDict(i.scope) + i.dset(d, "filename", i.currSym.filename.newVal) + i.dset(d, "line", i.currSym.line.newVal) + i.dset(d, "column", i.currSym.column.newVal) + i.push d + # Converters def.symbol("string") do (i: In):
M next-release.mdnext-release.md

@@ -4,4 +4,5 @@ * Fixed detection of musl executables when running build task.

* Added **union**, **intersection**, **difference**, **symmetric-difference**, **one?** symbols to **seq** module. * Fixed compilation for loaded files and assets. * Refacored code to satisfy nimble package structure. -* Now caching required modules so that their code is executed only once.+* Now caching required modules so that their code is executed only once. +* Added **line-info** symbol returning a dictionary containing the current filename, line and column numbers.
M site/contents/reference-io.mdsite/contents/reference-io.md

@@ -21,7 +21,7 @@

{#op||confirm||{{s}}||{{b}}|| > Prints {{s}} (prompt) appending `" [yes/no]: "`, reads a line from STDIN and: > -> * if it matches `/^y(es)$/i`, puts {{t}} on the stack. +> * if it matches `/^y(es)?$/i`, puts {{t}} on the stack. > * if it matches `/^no?$/i`, puts {{f}} on the stack. > * Otherwise, it prints `Invalid answer. Please enter 'yes' or 'no': ` and waits for a new answer. #}
M site/contents/reference-lang.mdsite/contents/reference-lang.md

@@ -235,6 +235,9 @@ > >

> > {{100 :b} :a} :test *test/a/b #} +{#op||line-info||{{none}}||{{d}}|| +Returns a dictionary {{d}} containing a **filename**, **line**, and **column** properties identifying the filename, line and column of the current symbol.#} + {#op||linrec||{{q1}} {{q2}} {{q3}} {{q4}}||{{a0p}}|| > Implements linear recursions as follows: >