all repos — min @ e4e29fa4052a2d02450371e862688db6d4d6488d

A small but practical concatenative programming language.

Merge branch 'next' of github.com:h3rald/min into next
h3rald h3rald@h3rald.com
Wed, 30 Dec 2020 15:31:54 +0000
commit

e4e29fa4052a2d02450371e862688db6d4d6488d

parent

6004384e7aa43dd6104109acb78734f5cc94e6f9

3 files changed, 19 insertions(+), 3 deletions(-)

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

@@ -229,9 +229,19 @@

proc push*(i: In, val: MinValue) {.gcsafe, extern:"min_exported_symbol_$1".}= if val.kind == minSymbol: i.debug(val) - i.trace.add val if not i.evaluating: - i.currSym = val + if val.line == 0 and val.column == 0 and val.filename == "": + # Simbol was added via min code, get data from previous min symbol + var nval = deepCopy(val) + let pval = i.trace[i.trace.len-1] + nval.symVal = pval.symVal & " > " & nval.symVal + nval.filename = pval.filename + nval.column = pval.column + nval.line = pval.line + i.currSym = nval + else: + i.currSym = val + i.trace.add val let symbol = val.symVal if symbol == "return": raise MinReturnException(msg: "return symbol found")

@@ -389,10 +399,13 @@ contents = ";;\n" & fileLines[1..fileLines.len-1].join("\n")

else: contents = fileLines.join("\n") var i2 = i.copy(s) + let snapshot = deepCopy(i.stack) i2.withScope: i2.open(newStringStream(contents), s) discard i2.parser.getToken() discard i2.interpret(parseOnly) + if snapshot != i2.stack: + raiseInvalid("Code in required file '$#' is polluting the stack" % s) result = newDict(i2.scope) result.objType = "module" for key, value in i2.scope.symbols.pairs:
M lib/min_lang.nimlib/min_lang.nim

@@ -393,7 +393,7 @@ let pair = line.split(":")

if pair.len == 1 and pair[0].len == 0: continue i.dset(dict, pair[0].strip, pair[1].strip.newVal) - i.push(dict) + i.push(dict) except: raiseInvalid("Invalid/unsupported YAML object (only dictionaries with string values are supported)")
M next-release.mdnext-release.md

@@ -2,3 +2,6 @@ * **REMOVED** support for creating dynamic libraries (it never worked properly anyway)

* Added **operator** symbol to define symbols and sigils in a more controlled way. * Added **expect-all** and **expect-any** symbols. * Fixed behavior of **require** and **invoke** ensuring that operators are evaluated in the correct scopes. +* Improved diagnostics of exceptions occurring in native code. +* Fixed unwanted stack pollution in **to-yaml** operator. +* Added check to prevent required modules from polluting the stack.