all repos — min @ 682c0d05f1ebfbb832ffe7dc7fe4cbd0f65c1e4d

A small but practical concatenative programming language.

Added expect-empty-stack symbol.
h3rald h3rald@h3rald.com
Thu, 24 Dec 2020 14:33:29 +0100
commit

682c0d05f1ebfbb832ffe7dc7fe4cbd0f65c1e4d

parent

dba628cbfded94e7d84ae6aff7d4acb0919bfe73

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

jump to
M lib/min_lang.nimlib/min_lang.nim

@@ -178,6 +178,11 @@ qscope.scope.symbols[sym] = MinOperator(kind: minProcOp, prc: op)

### End of symbols not present in minimin + def.symbol("expect-empty-stack") do (i: In): + let l = i.stack.len + if l != 0: + raiseInvalid("Expected empty stack, found $# elements instead" % $l) + def.symbol("exit") do (i: In): let vals = i.expect("int") quit(vals[0].intVal.int)

@@ -915,6 +920,9 @@ i.push("quote-bind".newSym)

def.symbol("=") do (i: In): i.push("quote-define".newSym) + + def.symbol("=-=") do (i: In): + i.push("expect-empty-stack".newSym) def.symbol(":") do (i: In): i.push("define".newSym)
M next-release.mdnext-release.md

@@ -5,3 +5,4 @@ * Added **invoke** symbol (and **\*** sigil) to easily call a symbol defined in a module or dictionary, e.g. `*mymodule/mymethod`.

* Fixed library installation via nimble * Fixed error handling and stack trace for **start-server** symbol. * Added the possibility to bundle assets in a compiled min program by specifying tbe **-a** (or **--asset-path**) option. +* Added **expect-empty-stack** (**=-=**) symbol.
M site/contents/reference-lang.mdsite/contents/reference-lang.md

@@ -38,6 +38,8 @@ {#alias||><||infix-dequote#}

{#alias||=>||apply#} +{#alias||=-=||expect-empty-stack#} + {#sig||#||quote-bind#} {#alias||#||quote-bind#}

@@ -139,6 +141,10 @@ > >

> > the following program evaluates to `true`: > > > > `(int string num) expect (3.4 "test" 1) ==`#} + +{#op||expect-empty-stack||{{null}}||{{null}}|| +Raises an error if the stack is not empty.#} + {#op||float||{{any}}||{{flt}}|| > Converts {{any}} to an integer value based on the following rules: