all repos — min @ 41b52be62aae2151f7d1d02fb2d7b493d979ea88

A small but practical concatenative programming language.

Added !!, fixed dequote etc.
h3rald h3rald@h3rald.com
Sat, 03 Oct 2020 11:46:33 +0200
commit

41b52be62aae2151f7d1d02fb2d7b493d979ea88

parent

ad916c3071da3f0b689d6a0f46c8b1e6f2435161

M core/interpreter.nimcore/interpreter.nim

@@ -183,8 +183,10 @@

proc dequote*(i: In, q: var MinValue) {.extern:"min_exported_symbol_$1".}= if q.kind == minQuotation: i.withScope(): + let qqval = deepCopy(q.qVal) for v in q.qVal: i.push v + q.qVal = qqval else: i.push(q)
M lib/min_lang.nimlib/min_lang.nim

@@ -520,7 +520,8 @@ raiseUndefined("Symbol '$1' not found." % sym)

let val = i.fromJson(json[sym]) i.scope.symbols[sym] = MinOperator(kind: minValOp, val: val, quotation: true) - def.symbol("stored-symbols") do (i: In): + + def.symbol("saved-symbols") do (i: In): var q = newSeq[MinValue](0) let json = MINSYMBOLS.readFile.parseJson for k,v in json.pairs:
M lib/min_sys.nimlib/min_sys.nim

@@ -53,6 +53,11 @@ def.symbol("system") do (i: In):

let vals = i.expect("'sym") let a = vals[0] i.push execShellCmd(a.getString).newVal + + def.symbol("system!") do (i: In): + let vals = i.expect("'sym") + let a = vals[0] + discard execShellCmd(a.getString) def.symbol("run") do (i: In): let vals = i.expect("'sym")

@@ -193,6 +198,9 @@ i.push("get-env".newSym)

def.symbol("!") do (i: In): i.push("system".newSym) + + def.symbol("!!") do (i: In): + i.push("system!".newSym) def.symbol("&") do (i: In): i.push("run".newSym)
M site/contents/reference-lang.mdsite/contents/reference-lang.md

@@ -92,9 +92,9 @@ {#op||delete||{{sl}}||{{null}}||

Deletes the specified symbol {{sl}}.#} {#op||dequote||{{q}}||{{a0p}}|| -Pushes the contents of quotation {{q}} on the stack. - -Each element is pushed on the stack one by one. If any error occurs, {{q}} is restored on the stack.#} +> Pushes the contents of quotation {{q}} on the stack. +> +> Each element is pushed on the stack one by one. If any error occurs, {{q}} is restored on the stack.#} {#op||eval||{{s}}||{{a0p}}|| Parses and interprets {{s}}. #}

@@ -274,6 +274,9 @@ > >

> > {} :myscope (2 :due scope @myscope) -> #} +{#op||saved-symbols||{{null}}||({{s0p}})|| +Returns a quotation containing all symbols saved in the [.min\_symbols](class:file) file. #} + {#op||scope-sigils||{{d}}||({{s0p}})|| Returns a list of all sigils defined in dictionary {{d}}.#}

@@ -291,9 +294,6 @@ Returns a list of all sigils defined in the [ROOT](class:kwd) scope.#}

{#op||source||{{sl}}||{{q}}|| Display the source code of symbol {{sl}} (if it has been implemented a {{m}} quotation). #} - -{#op||stored-symbols||{{null}}||({{s0p}})|| -Returns a quotation containing all symbols stored in the [.min\_symbols](class:file) file. #} {#op||string||{{any}}||{{s}}|| Converts {{any}} to its string representation.#}
M site/contents/reference-sys.mdsite/contents/reference-sys.md

@@ -12,6 +12,8 @@ {#sig||\!||system#}

{#alias||\!||system#} +{#alias||\!\!||system!#} + {#sig||&||run#} {#alias||&||run#}

@@ -103,6 +105,9 @@ Returns {{t}} if the specified path {{sl}} exists and is a symbolic link. #}

{#op||system||{{sl}}||{{i}}|| Executes the external command {{sl}} in the current directory and pushes its return code on the stack. #} + +{#op||system!||{{sl}}||{{null}}|| +Executes the external command {{sl}} in the current directory without pushing its return code on the stack. #} {#op||unzip||{{sl1}} {{sl2}}||{{null}}|| Decompresses zip file {{sl1}} to directory {{sl2}} (created if not present).#}