all repos — min @ a1baec676ce0944b024991f88fdcecbc69875277

A small but practical concatenative programming language.

Added quote-bind and quote-define; changed module sigil to "+".
h3rald h3rald@h3rald.com
Mon, 07 Nov 2016 16:47:09 +0100
commit

a1baec676ce0944b024991f88fdcecbc69875277

parent

784bef71668872e14122f0e10d2fecf01b1d2872

3 files changed, 31 insertions(+), 7 deletions(-)

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

@@ -740,6 +740,22 @@ var s = i.scope.getSymbol(sym.getString)

s.sealed = true i.scope.setSymbol(sym.getString, s) + .symbol("quote-bind") do (i: In): + var s, m: MinValue + i.reqString(s) + m = i.pop + i.push @[m].newVal(i.scope) + i.push s + i.push "bind".newSym + + .symbol("quote-define") do (i: In): + var s, m: MinValue + i.reqString(s) + m = i.pop + i.push @[m].newVal(i.scope) + i.push s + i.push "define".newSym + # Sigils .sigil("'") do (i: In):

@@ -765,7 +781,7 @@

.sigil("@") do (i: In): i.push("bind".newSym) - .sigil("=") do (i: In): + .sigil("+") do (i: In): i.push("module".newSym) .sigil("^") do (i: In):

@@ -782,6 +798,14 @@ i.push("load-symbol".newSym)

.sigil("*") do (i: In): i.push("seal".newSym) + + .sigil("#") do (i: In): + i.push("quote-bind".newSym) + + .sigil("=") do (i: In): + i.push("quote-define".newSym) + + # Shorthand symbol aliases .symbol(":") do (i: In): i.push("define".newSym)
M tests/lang.mintests/lang.min

@@ -51,7 +51,7 @@ (symbols "five" contains false ==) assert

( (+) :myplus - ) =mymath + ) +mymath (symbols "mymath" contains) assert

@@ -157,9 +157,9 @@ (((a 1)(b 2)(c 3)) dictionary?) assert

(((a 1)(b 2)(c 3)) 'b dget 2 ==) assert - (((a 1)(b 2)(c 3)) ' :dict dict 5 'b dset 7 'd dset ' :newdict newdict ((a 1)(b 5)(c 3)(d 7)) == dict ((a 1)(b 2)(c 3)) == and) assert + (((a 1)(b 2)(c 3)) ' :dict dict 5 'b dset 7 'd dset =newdict newdict ((a 1)(b 5)(c 3)(d 7)) == dict ((a 1)(b 2)(c 3)) == and) assert - (((a 1)(b 2)(c 3)) ' :dict dict 'b ddel ' :newdict newdict ((a 1)(c 3)) == dict ((a 1)(b 2)(c 3)) == and) assert + (((a 1)(b 2)(c 3)) ' :dict dict 'b ddel =newdict newdict ((a 1)(c 3)) == dict ((a 1)(b 2)(c 3)) == and) assert (((a 1)(b 2)(c 3)) keys (a b c) ==) assert
M tests/test.mintests/test.min

@@ -1,6 +1,6 @@

;; test module ( - 'OK ' :ok + 'OK =ok (" " print!) :padding ;; describe

@@ -46,7 +46,7 @@ (ok !=) (failed succ @failed) () ifte

) map padding total print! " tests executed - " print! failed print! " failed." puts! ( - ' :result + =result result (ok !=) (padding "FAILED: " print! result puts!)

@@ -57,4 +57,4 @@ map

pop ;Remove results accomulator from stack ) :report -) =test +) +test