all repos — min @ 16a2b9fe00331f30c5ab2e8c34bdbb924902c702

A small but practical concatenative programming language.

fix(stack) Renamed stack to getstack; added setstack.
h3rald h3rald@h3rald.com
Sun, 29 May 2016 17:20:46 +0200
commit

16a2b9fe00331f30c5ab2e8c34bdbb924902c702

parent

bb5621bf2575abb079f6ba73081a67928de528bc

4 files changed, 16 insertions(+), 6 deletions(-)

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

@@ -201,9 +201,12 @@

proc eval*(i: var MinInterpreter, s: string) = let fn = i.filename try: - i.open(newStringStream(s), "eval") - discard i.parser.getToken() - i.interpret() + var i2 = i.copy("eval") + i2.open(newStringStream(s), "eval") + discard i2.parser.getToken() + i2.interpret() + i.stack = i2.stack + i.scope = i2.scope except: stderr.writeLine getCurrentExceptionMsg() finally:
M lib/lang.nimlib/lang.nim

@@ -220,9 +220,14 @@

.symbol("dump") do (i: In): echo i.dump - .symbol("stack") do (i: In): - var s = i.stack - i.push s + .symbol("getstack") do (i: In): + i.push i.stack.newVal + + .symbol("setstack") do (i: In): + let q = i.pop + if not q.isQuotation: + i.error errNoQuotation + i.stack = q.qVal # Operations on quotations or strings
M lib/prelude.minlib/prelude.min

@@ -12,6 +12,7 @@

; Common sigils (bind) (:) sigil (let) (.) sigil +(delete) (~) sigil (getenv) ($) sigil (system) (!) sigil (run) (&) sigil
M tests/io.mintests/io.min

@@ -11,3 +11,4 @@ "test.txt" fread "TEST - TEST" ==) assert

"test.txt" rm report + clear