Added init parameter to register custom native modules.
h3rald h3rald@h3rald.com
Sun, 06 Nov 2016 10:42:07 +0100
1 files changed,
8 insertions(+),
7 deletions(-)
jump to
M
minim.nim
→
minim.nim
@@ -116,10 +116,11 @@ if not MINIMRC.fileExists:
MINIMRC.writeFile("") i.eval MINIMRC.readFile() -proc minimStream(s: Stream, filename: string, debugging = false) = +proc minimStream(s: Stream, filename: string, debugging = false, init = proc(i: In) = discard) = var i = newMinInterpreter(debugging) i.pwd = filename.parentDir i.stdLib() + i.init() i.open(s, filename) discard i.parser.getToken() try:@@ -128,22 +129,22 @@ except:
discard i.close() -proc minimString*(buffer: string, debugging = false) = - minimStream(newStringStream(buffer), "input", debugging) +proc minimString*(buffer: string, debugging = false, init = proc(i: In) = discard) = + minimStream(newStringStream(buffer), "input", debugging, init) -proc minimFile*(filename: string, debugging = false) = +proc minimFile*(filename: string, debugging = false, init = proc(i: In) = discard) = var stream = newFileStream(filename, fmRead) if stream == nil: stderr.writeLine("Error - Cannot read from file: "& filename) stderr.flushFile() - minimStream(stream, filename, debugging) + minimStream(stream, filename, debugging, init) -proc minimFile*(file: File, filename="stdin", debugging = false) = +proc minimFile*(file: File, filename="stdin", debugging = false, init = proc(i: In) = discard) = var stream = newFileStream(stdin) if stream == nil: stderr.writeLine("Error - Cannot read from "& filename) stderr.flushFile() - minimStream(stream, filename, debugging) + minimStream(stream, filename, debugging, init) proc printResult(i: In, res: MinValue) = if res.isNil: