all repos — min @ 744b29f644ebb8dfb50776237de4c0e8ed35235d

A small but practical concatenative programming language.

Fixed require (now including only new symbols) and invoke.
h3rald h3rald@h3rald.com
Mon, 28 Dec 2020 16:26:52 +0100
commit

744b29f644ebb8dfb50776237de4c0e8ed35235d

parent

001fe20961dccac9bbea9735db8a56bf12d77f9e

2 files changed, 11 insertions(+), 18 deletions(-)

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

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

else: contents = fileLines.join("\n") var i2 = i.copy(s) - i2.open(newStringStream(contents), s) - discard i2.parser.getToken() - discard i2.interpret(parseOnly) - result = newDict(i2.scope) - result.objType = "module" - for key, value in i2.scope.symbols.pairs: - result.scope.symbols[key] = value + i2.withScope: + i2.open(newStringStream(contents), s) + discard i2.parser.getToken() + discard i2.interpret(parseOnly) + result = newDict(i2.scope) + result.objType = "module" + for key, value in i2.scope.symbols.pairs: + result.scope.symbols[key] = value proc parse*(i: In, s: string, name="<parse>"): MinValue = return i.eval(s, name, true)
M lib/min_lang.nimlib/min_lang.nim

@@ -559,19 +559,11 @@ let parts = s.split("/")

if parts.len < 2: raiseInvalid("Dictionary identifier not specified") var mdlId = parts[0] - i.apply i.scope.getSymbol(mdlId) + i.push mdlId.newSym for p in 0..parts.len-2: - let mdl = i.pop - if not mdl.isDictionary: - raiseInvalid("'$#' is not a dictionary" % mdlId) let symId = parts[p+1] - var sym: MinValue - try: - sym = i.dget(mdl, symId) - except: - raiseInvalid("Symbol '$#' not found in dictionary '$#'" % [symId, mdlId]) - mdlId = symId - i.dequote sym + i.push symId.newVal + i.push "dget".newSym def.symbol("set-type") do (i: In): let vals = i.expect("'sym", "dict")