all repos — min @ 19e85fea3b0b8b20436ffff05504e8dea1073a66

A small but practical concatenative programming language.

Modified extern value for exported symbols; re-added passL if not on
windows.
h3rald h3rald@h3rald.com
Sat, 28 Oct 2017 22:09:03 +0200
commit

19e85fea3b0b8b20436ffff05504e8dea1073a66

parent

267c507c1fc6fcc85b99ec5f8b3ac14a9139d9d3

M core/fileutils.nimcore/fileutils.nim

@@ -3,7 +3,7 @@ os

# Filetype and permissions -proc filetype*(p: PathComponent): string = +proc filetype*(p: PathComponent): string {.extern:"min_exported_symbol_$1".}= case p of pcFile: return "file"

@@ -14,7 +14,7 @@ return "dir"

of pcLinkToDir: return "dirlink" -proc unixPermissions*(s: set[FilePermission]): int = +proc unixPermissions*(s: set[FilePermission]): int {.extern:"min_exported_symbol_$1".}= result = 0 for p in s: case p:

@@ -37,7 +37,7 @@ result += 2

of fpOthersExec: result += 1 -proc toFilePermissions*(p: BiggestInt): set[FilePermission] = +proc toFilePermissions*(p: BiggestInt): set[FilePermission] {.extern:"min_exported_symbol_$1".}= let user = ($p)[0].int let group = ($p)[1].int let others = ($p)[2].int

@@ -97,4 +97,4 @@ result.incl fpOthersWrite

if others == 7: result.incl fpOthersRead result.incl fpOthersWrite - result.incl fpOthersExec+ result.incl fpOthersExec
M core/interpreter.nimcore/interpreter.nim

@@ -15,19 +15,19 @@ MinTrappedException* = ref object of SystemError

MinRuntimeError* = ref object of SystemError qVal*: seq[MinValue] -proc raiseRuntime*(msg: string, qVal: var seq[MinValue]) = +proc raiseRuntime*(msg: string, qVal: var seq[MinValue]) {.extern:"min_exported_symbol_$1".}= raise MinRuntimeError(msg: msg, qVal: qVal) -proc dump*(i: MinInterpreter): string = +proc dump*(i: MinInterpreter): string {.extern:"min_exported_symbol_$1".}= var s = "" for item in i.stack: s = s & $item & " " return s -proc debug*(i: In, value: MinValue) = +proc debug*(i: In, value: MinValue) {.extern:"min_exported_symbol_$1".}= debug("{" & i.dump & $value & "}") -proc debug*(i: In, value: string) = +proc debug*(i: In, value: string) {.extern:"min_exported_symbol_$1_2".}= debug(value) template withScope*(i: In, q: MinValue, res:ref MinScope, body: untyped): untyped =

@@ -38,7 +38,7 @@ body

res = i.scope i.scope = origScope -proc newMinInterpreter*(filename = "input", pwd = ""): MinInterpreter = +proc newMinInterpreter*(filename = "input", pwd = ""): MinInterpreter {.extern:"min_exported_symbol_$1".}= var stack:MinStack = newSeq[MinValue](0) var trace:MinStack = newSeq[MinValue](0) var stackcopy:MinStack = newSeq[MinValue](0)

@@ -56,7 +56,7 @@ currSym: MinValue(column: 1, line: 1, kind: minSymbol, symVal: "")

) return i -proc copy*(i: MinInterpreter, filename: string): MinInterpreter = +proc copy*(i: MinInterpreter, filename: string): MinInterpreter {.extern:"min_exported_symbol_$1_2".}= result = newMinInterpreter() result.filename = filename result.pwd = filename.parentDir

@@ -66,13 +66,13 @@ result.stackcopy = i.stackcopy

result.scope = i.scope result.currSym = MinValue(column: 1, line: 1, kind: minSymbol, symVal: "") -proc formatError(sym: MinValue, message: string): string = +proc formatError(sym: MinValue, message: string): string {.extern:"min_exported_symbol_$1".}= if sym.filename.isNil or sym.filename == "": return "[$1]: $2" % [sym.symVal, message] else: return "$1($2,$3) [$4]: $5" % [sym.filename, $sym.line, $sym.column, sym.symVal, message] -proc formatTrace(sym: MinValue): string = +proc formatTrace(sym: MinValue): string {.extern:"min_exported_symbol_$1".}= if sym.filename.isNil or sym.filename == "": return "<native> in symbol: $1" % [sym.symVal] else:

@@ -87,16 +87,16 @@

proc error(i: In, message: string) = error(i.currSym.formatError(message)) -proc open*(i: In, stream:Stream, filename: string) = +proc open*(i: In, stream:Stream, filename: string) {.extern:"min_exported_symbol_$1_2".}= i.filename = filename i.parser.open(stream, filename) -proc close*(i: In) = +proc close*(i: In) {.extern:"min_exported_symbol_$1_2".}= i.parser.close(); -proc push*(i: In, val: MinValue) {.gcsafe.} +proc push*(i: In, val: MinValue) {.extern:"min_exported_symbol_$1".} -proc apply*(i: In, op: MinOperator) = +proc apply*(i: In, op: MinOperator) {.extern:"min_exported_symbol_$1".}= var newscope = newScopeRef(i.scope) case op.kind of minProcOp:

@@ -110,7 +110,7 @@ i.push e

else: i.push(op.val) -proc dequote*(i: In, q: var MinValue) = +proc dequote*(i: In, q: var MinValue) {.extern:"min_exported_symbol_$1".}= if not q.isQuotation: i.push(q) else:

@@ -118,7 +118,7 @@ i.withScope(q, q.scope):

for v in q.qVal: i.push v -proc apply*(i: In, q: var MinValue) = +proc apply*(i: In, q: var MinValue) {.extern:"min_exported_symbol_$1_2".}= var i2 = newMinInterpreter("<apply>") i2.trace = i.trace i2.scope = i.scope

@@ -136,7 +136,7 @@ i.trace = i2.trace

raise i.push i2.stack.newVal(i.scope) -proc push*(i: In, val: MinValue) = +proc push*(i: In, val: MinValue) {.extern:"min_exported_symbol_$1".}= if val.kind == minSymbol: i.debug(val) i.trace.add val

@@ -161,19 +161,19 @@ discard i.trace.pop

else: i.stack.add(val) -proc pop*(i: In): MinValue = +proc pop*(i: In): MinValue {.extern:"min_exported_symbol_$1".}= if i.stack.len > 0: return i.stack.pop else: raiseEmptyStack() -proc peek*(i: MinInterpreter): MinValue = +proc peek*(i: MinInterpreter): MinValue {.extern:"min_exported_symbol_$1".}= if i.stack.len > 0: return i.stack[i.stack.len-1] else: raiseEmptyStack() -proc interpret*(i: In): MinValue {.gcsafe, discardable.} = +proc interpret*(i: In): MinValue {.discardable, extern:"min_exported_symbol_$1".} = var val: MinValue while i.parser.token != tkEof: if i.trace.len == 0:

@@ -200,7 +200,7 @@ raise MinTrappedException(msg: msg)

if i.stack.len > 0: return i.stack[i.stack.len - 1] -proc eval*(i: In, s: string, name="<eval>") = +proc eval*(i: In, s: string, name="<eval>") {.extern:"min_exported_symbol_$1".}= var i2 = i.copy(name) i2.open(newStringStream(s), name) discard i2.parser.getToken()

@@ -210,7 +210,7 @@ i.stackcopy = i2.stackcopy

i.stack = i2.stack i.scope = i2.scope -proc load*(i: In, s: string) = +proc load*(i: In, s: string) {.extern:"min_exported_symbol_$1".}= var i2 = i.copy(s) i2.open(newStringStream(s.readFile), s) discard i2.parser.getToken()
M core/parser.nimcore/parser.nim

@@ -109,16 +109,16 @@ MinOutOfBoundsError* = ref object of ValueError

# Error Helpers -proc raiseInvalid*(msg: string) = +proc raiseInvalid*(msg: string) {.extern:"min_exported_symbol_$1".}= raise MinInvalidError(msg: msg) -proc raiseUndefined*(msg: string) = +proc raiseUndefined*(msg: string) {.extern:"min_exported_symbol_$1".}= raise MinUndefinedError(msg: msg) -proc raiseOutOfBounds*(msg: string) = +proc raiseOutOfBounds*(msg: string) {.extern:"min_exported_symbol_$1".}= raise MinOutOfBoundsError(msg: msg) -proc raiseEmptyStack*() = +proc raiseEmptyStack*() {.extern:"min_exported_symbol_$1".}= raise MinEmptyStackError(msg: "Insufficient items on the stack")

@@ -146,59 +146,60 @@ "true",

"false" ] -proc newScope*(parent: ref MinScope): MinScope = +proc newScope*(parent: ref MinScope): MinScope {.extern:"min_exported_symbol_$1".}= result = MinScope(parent: parent) -proc newScopeRef*(parent: ref MinScope): ref MinScope = +proc newScopeRef*(parent: ref MinScope): ref MinScope {.extern:"min_exported_symbol_$1".}= new(result) result[] = newScope(parent) -proc open*(my: var MinParser, input: Stream, filename: string) = +proc open*(my: var MinParser, input: Stream, filename: string) {.extern:"min_exported_symbol_$1".}= lexbase.open(my, input) my.filename = filename my.state = @[stateStart] my.kind = eMinError my.a = "" -proc close*(my: var MinParser) {.inline.} = +proc close*(my: var MinParser) {.inline, extern:"min_exported_symbol_$1".}= lexbase.close(my) -proc getInt*(my: MinParser): int {.inline.} = +proc getInt*(my: MinParser): int {.inline, extern:"min_exported_symbol_$1".}= assert(my.kind == eMinInt) return parseint(my.a) -proc getFloat*(my: MinParser): float {.inline.} = +proc getFloat*(my: MinParser): float {.inline, extern:"min_exported_symbol_$1".}= assert(my.kind == eMinFloat) return parseFloat(my.a) -proc kind*(my: MinParser): MinEventKind {.inline.} = +proc kind*(my: MinParser): MinEventKind {.inline, extern:"min_exported_symbol_$1".}= return my.kind -proc getColumn*(my: MinParser): int {.inline.} = +proc getColumn*(my: MinParser): int {.inline, extern:"min_exported_symbol_$1".}= result = getColNumber(my, my.bufpos) -proc getLine*(my: MinParser): int {.inline.} = +proc getLine*(my: MinParser): int {.inline, extern:"min_exported_symbol_$1".}= result = my.lineNumber -proc getFilename*(my: MinParser): string {.inline.} = +proc getFilename*(my: MinParser): string {.inline, extern:"min_exported_symbol_$1".}= result = my.filename -proc errorMsg*(my: MinParser, msg: string): string = +proc errorMsg*(my: MinParser, msg: string): string {.extern:"min_exported_symbol_$1".}= assert(my.kind == eMinError) result = "$1 [l:$2, c:$3] ERROR - $4" % [ my.filename, $getLine(my), $getColumn(my), msg] -proc errorMsg*(my: MinParser): string = +proc errorMsg*(my: MinParser): string {.extern:"min_exported_symbol_$1_2".}= assert(my.kind == eMinError) result = errorMsg(my, errorMessages[my.err]) -proc errorMsgExpected*(my: MinParser, e: string): string = +proc errorMsgExpected*(my: MinParser, e: string): string {.extern:"min_exported_symbol_$1".}= result = errorMsg(my, e & " expected") -proc raiseParsing*(p: MinParser, msg: string) {.noinline, noreturn.} = +proc raiseParsing*(p: MinParser, msg: string) {.noinline, noreturn, extern:"min_exported_symbol_$1".}= + raise MinParsingError(msg: errorMsgExpected(p, msg)) -proc raiseUndefined*(p:MinParser, msg: string) {.noinline, noreturn.} = +proc raiseUndefined*(p:MinParser, msg: string) {.noinline, noreturn, extern:"min_exported_symbol_$1_2".}= raise MinUndefinedError(msg: errorMsg(p, msg)) proc parseNumber(my: var MinParser) =

@@ -383,7 +384,7 @@ else:

break my.bufpos = pos -proc getToken*(my: var MinParser): MinTokenKind = +proc getToken*(my: var MinParser): MinTokenKind {.extern:"min_exported_symbol_$1".}= setLen(my.a, 0) skip(my) case my.buf[my.bufpos]

@@ -422,7 +423,7 @@ discard

my.token = result -proc next*(my: var MinParser) = +proc next*(my: var MinParser) {.extern:"min_exported_symbol_$1".}= var tk = getToken(my) var i = my.state.len-1 case my.state[i]

@@ -469,11 +470,11 @@ else:

my.kind = eMinError my.err = errExprExpected -proc eat(p: var MinParser, token: MinTokenKind) = +proc eat(p: var MinParser, token: MinTokenKind) {.extern:"min_exported_symbol_$1".}= if p.token == token: discard getToken(p) else: raiseParsing(p, tokToStr[token]) -proc parseMinValue*(p: var MinParser, i: In): MinValue = +proc parseMinValue*(p: var MinParser, i: In): MinValue {.extern:"min_exported_symbol_$1".}= #echo p.a, " (", p.token, ")" case p.token of tkTrue:

@@ -511,7 +512,7 @@ else:

raiseUndefined(p, "Undefined value: '"&p.a&"'") result.filename = p.filename -proc `$`*(a: MinValue): string = +proc `$`*(a: MinValue): string {.extern:"min_exported_symbol_$1".}= case a.kind: of minBool: return $a.boolVal

@@ -530,7 +531,7 @@ q = q & $i & " "

q = q.strip & ")" return q -proc `$$`*(a: MinValue): string = +proc `$$`*(a: MinValue): string {.extern:"min_exported_symbol_$1".}= case a.kind: of minBool: return $a.boolVal

@@ -549,10 +550,10 @@ q = q & $i & " "

q = q.strip & ")" return q -proc print*(a: MinValue) = +proc print*(a: MinValue) {.extern:"min_exported_symbol_$1".}= stdout.write($$a) -proc `==`*(a: MinValue, b: MinValue): bool = +proc `==`*(a: MinValue, b: MinValue): bool {.extern:"min_exported_symbol_eqeq".}= if a.kind == minSymbol and b.kind == minSymbol: return a.symVal == b.symVal elif a.kind == minInt and b.kind == minInt:
M core/scope.nimcore/scope.nim

@@ -4,13 +4,13 @@ critbits

import parser -proc copy*(s: ref MinScope): ref MinScope = +proc copy*(s: ref MinScope): ref MinScope {.extern:"min_exported_symbol_$1".}= var scope = newScope(s.parent) scope.symbols = s.symbols new(result) result[] = scope -proc getSymbol*(scope: ref MinScope, key: string): MinOperator = +proc getSymbol*(scope: ref MinScope, key: string): MinOperator {.extern:"min_exported_symbol_$1".}= if scope.symbols.hasKey(key): return scope.symbols[key] elif not scope.parent.isNil:

@@ -18,7 +18,7 @@ return scope.parent.getSymbol(key)

else: raiseUndefined("Symbol '$1' not found." % key) -proc hasSymbol*(scope: ref MinScope, key: string): bool = +proc hasSymbol*(scope: ref MinScope, key: string): bool {.extern:"min_exported_symbol_$1".}= if scope.isNil: return false elif scope.symbols.hasKey(key):

@@ -28,7 +28,7 @@ return scope.parent.hasSymbol(key)

else: return false -proc delSymbol*(scope: ref MinScope, key: string): bool {.discardable.}= +proc delSymbol*(scope: ref MinScope, key: string): bool {.discardable, extern:"min_exported_symbol_$1".}= if scope.symbols.hasKey(key): if scope.symbols[key].sealed: raiseInvalid("Symbol '$1' is sealed." % key)

@@ -36,7 +36,7 @@ scope.symbols.excl(key)

return true return false -proc setSymbol*(scope: ref MinScope, key: string, value: MinOperator, override = false): bool {.discardable.}= +proc setSymbol*(scope: ref MinScope, key: string, value: MinOperator, override = false): bool {.discardable, extern:"min_exported_symbol_$1".}= result = false # check if a symbol already exists in current scope if not scope.isNil and scope.symbols.hasKey(key):

@@ -49,7 +49,7 @@ # Go up the scope chain and attempt to find the symbol

if not scope.parent.isNil: result = scope.parent.setSymbol(key, value) -proc getSigil*(scope: ref MinScope, key: string): MinOperator = +proc getSigil*(scope: ref MinScope, key: string): MinOperator {.extern:"min_exported_symbol_$1".}= if scope.sigils.hasKey(key): return scope.sigils[key] elif not scope.parent.isNil:

@@ -57,7 +57,7 @@ return scope.parent.getSigil(key)

else: raiseUndefined("Sigil '$1' not found." % key) -proc hasSigil*(scope: ref MinScope, key: string): bool = +proc hasSigil*(scope: ref MinScope, key: string): bool {.extern:"min_exported_symbol_$1".}= if scope.isNil: return false elif scope.sigils.hasKey(key):

@@ -67,7 +67,7 @@ return scope.parent.hasSigil(key)

else: return false -proc previous*(scope: ref MinScope): ref MinScope = +proc previous*(scope: ref MinScope): ref MinScope {.extern:"min_exported_symbol_$1".}= if scope.parent.isNil: return scope else:
M core/utils.nimcore/utils.nim

@@ -18,27 +18,27 @@ result[^i-1] = x

# Library methods -proc define*(i: In): ref MinScope = +proc define*(i: In): ref MinScope {.extern:"min_exported_symbol_$1".}= var scope = new MinScope scope.parent = i.scope return scope -proc symbol*(scope: ref MinScope, sym: string, p: MinOperatorProc) = +proc symbol*(scope: ref MinScope, sym: string, p: MinOperatorProc) {.extern:"min_exported_symbol_$1".}= scope.symbols[sym] = MinOperator(prc: p, kind: minProcOp, sealed: true) -proc symbol*(scope: ref MinScope, sym: string, v: MinValue) = +proc symbol*(scope: ref MinScope, sym: string, v: MinValue) {.extern:"min_exported_symbol_$1_2".}= scope.symbols[sym] = MinOperator(val: v, kind: minValOp, sealed: true) -proc sigil*(scope: ref MinScope, sym: string, p: MinOperatorProc) = +proc sigil*(scope: ref MinScope, sym: string, p: MinOperatorProc) {.extern:"min_exported_symbol_$1".}= scope.sigils[sym] = MinOperator(prc: p, kind: minProcOp, sealed: true) -proc sigil*(scope: ref MinScope, sym: string, v: MinValue) = +proc sigil*(scope: ref MinScope, sym: string, v: MinValue) {.extern:"min_exported_symbol_$1_2".}= scope.sigils[sym] = MinOperator(val: v, kind: minValOp, sealed: true) -proc finalize*(scope: ref MinScope, name: string = "") = +proc finalize*(scope: ref MinScope, name: string = "") {.extern:"min_exported_symbol_$1".}= var mdl = newSeq[MinValue](0).newVal(nil) mdl.scope = scope - let op = proc(i: In) {.gcsafe, closure.} = + let op = proc(i: In) {.closure.} = i.evaluating = true i.push mdl i.evaluating = false

@@ -47,7 +47,7 @@ scope.previous.symbols[name] = MinOperator(kind: minProcOp, prc: op)

# Dictionary Methods -proc dget*(q: MinValue, s: MinValue): MinValue = +proc dget*(q: MinValue, s: MinValue): MinValue {.extern:"min_exported_symbol_$1".}= if not q.isDictionary: raiseInvalid("Value is not a dictionary") for v in q.qVal:

@@ -55,7 +55,7 @@ if v.qVal[0].getString == s.getString:

return v.qVal[1] raiseInvalid("Dictionary key '$1' not found" % s.getString) -proc dhas*(q: MinValue, s: MinValue): bool = +proc dhas*(q: MinValue, s: MinValue): bool {.extern:"min_exported_symbol_$1".}= if not q.isDictionary: raiseInvalid("Value is not a dictionary") for v in q.qVal:

@@ -63,7 +63,7 @@ if v.qVal[0].getString == s.getString:

return true return false -proc ddel*(i: In, p: MinValue, s: MinValue): MinValue {.discardable.} = +proc ddel*(i: In, p: MinValue, s: MinValue): MinValue {.discardable, extern:"min_exported_symbol_$1".} = if not p.isDictionary: raiseInvalid("Value is not a dictionary") var q = newVal(p.qVal, i.scope)

@@ -78,7 +78,7 @@ if found:

q.qVal.delete(c) return q -proc dset*(i: In, p: MinValue, s: MinValue, m: MinValue): MinValue {.discardable.}= +proc dset*(i: In, p: MinValue, s: MinValue, m: MinValue): MinValue {.discardable, extern:"min_exported_symbol_$1".}= if not p.isDictionary: raiseInvalid("Value is not a dictionary") var q = newVal(p.qVal, i.scope)

@@ -96,13 +96,13 @@ else:

q.qVal.add(@[s.getString.newVal, m].newVal(i.scope)) return q -proc keys*(i: In, q: MinValue): MinValue = +proc keys*(i: In, q: MinValue): MinValue {.extern:"min_exported_symbol_$1".}= # Assumes q is a dictionary result = newSeq[MinValue](0).newVal(i.scope) for v in q.qVal: result.qVal.add v.qVal[0].getString.newVal -proc values*(i: In, q: MinValue): MinValue = +proc values*(i: In, q: MinValue): MinValue {.extern:"min_exported_symbol_$1".}= # Assumes q is a dictionary result = newSeq[MinValue](0).newVal(i.scope) for v in q.qVal:

@@ -110,7 +110,7 @@ result.qVal.add v.qVal[1]

# JSON interop -proc `%`*(a: MinValue): JsonNode = +proc `%`*(a: MinValue): JsonNode {.extern:"min_exported_symbol_percent".}= case a.kind: of minBool: return %a.boolVal

@@ -132,7 +132,7 @@ result = newJArray()

for i in a.qVal: result.add %i -proc fromJson*(i: In, json: JsonNode): MinValue = +proc fromJson*(i: In, json: JsonNode): MinValue {.extern:"min_exported_symbol_$1".}= case json.kind: of JNull: result = newSeq[MinValue](0).newVal(i.scope)

@@ -161,7 +161,7 @@ return res.newVal(i.scope)

# Validators -proc expect*(i: var MinInterpreter, elements: varargs[string]): seq[MinValue] = +proc expect*(i: var MinInterpreter, elements: varargs[string]): seq[MinValue] {.extern:"min_exported_symbol_$1".}= let stack = elements.reverse.join(" ") let sym = i.currSym.getString var valid = newSeq[string](0)

@@ -210,7 +210,7 @@ else:

raiseInvalid("Invalid type description: " & element) valid.add element -proc reqQuotationOfQuotations*(i: var MinInterpreter, a: var MinValue) = +proc reqQuotationOfQuotations*(i: var MinInterpreter, a: var MinValue) {.extern:"min_exported_symbol_$1".}= a = i.pop if not a.isQuotation: raiseInvalid("A quotation is required on the stack")

@@ -218,7 +218,7 @@ for s in a.qVal:

if not s.isQuotation: raiseInvalid("A quotation of quotations is required on the stack") -proc reqQuotationOfNumbers*(i: var MinInterpreter, a: var MinValue) = +proc reqQuotationOfNumbers*(i: var MinInterpreter, a: var MinValue) {.extern:"min_exported_symbol_$1".}= a = i.pop if not a.isQuotation: raiseInvalid("A quotation is required on the stack")

@@ -226,7 +226,7 @@ for s in a.qVal:

if not s.isNumber: raiseInvalid("A quotation of numbers is required on the stack") -proc reqQuotationOfSymbols*(i: var MinInterpreter, a: var MinValue) = +proc reqQuotationOfSymbols*(i: var MinInterpreter, a: var MinValue) {.extern:"min_exported_symbol_$1".}= a = i.pop if not a.isQuotation: raiseInvalid("A quotation is required on the stack")

@@ -234,24 +234,24 @@ for s in a.qVal:

if not s.isSymbol: raiseInvalid("A quotation of symbols is required on the stack") -proc reqTwoNumbersOrStrings*(i: var MinInterpreter, a, b: var MinValue) = +proc reqTwoNumbersOrStrings*(i: var MinInterpreter, a, b: var MinValue) {.extern:"min_exported_symbol_$1".}= a = i.pop b = i.pop if not (a.isString and b.isString or a.isNumber and b.isNumber): raiseInvalid("Two numbers or two strings are required on the stack") -proc reqStringOrQuotation*(i: var MinInterpreter, a: var MinValue) = +proc reqStringOrQuotation*(i: var MinInterpreter, a: var MinValue) {.extern:"min_exported_symbol_$1".}= a = i.pop if not a.isQuotation and not a.isString: raiseInvalid("A quotation or a string is required on the stack") -proc reqTwoQuotationsOrStrings*(i: var MinInterpreter, a, b: var MinValue) = +proc reqTwoQuotationsOrStrings*(i: var MinInterpreter, a, b: var MinValue) {.extern:"min_exported_symbol_$1".}= a = i.pop b = i.pop if not (a.isQuotation and b.isQuotation or a.isString and b.isString): raiseInvalid("Two quotations or two strings are required on the stack") -proc reqTwoSimilarTypesNonSymbol*(i: var MinInterpreter, a, b: var MinValue) = +proc reqTwoSimilarTypesNonSymbol*(i: var MinInterpreter, a, b: var MinValue) {.extern:"min_exported_symbol_$1".}= a = i.pop b = i.pop if not ((a.kind == b.kind or (a.isNumber and b.isNumber)) and not a.isSymbol):
M core/value.nimcore/value.nim

@@ -4,7 +4,7 @@ import

parser, scope -proc typeName*(v: MinValue): string = +proc typeName*(v: MinValue): string {.extern:"min_exported_symbol_$1".}= case v.kind: of minInt: return "int"

@@ -21,31 +21,31 @@ return "bool"

# Predicates -proc isSymbol*(s: MinValue): bool = +proc isSymbol*(s: MinValue): bool {.extern:"min_exported_symbol_$1".}= return s.kind == minSymbol -proc isQuotation*(s: MinValue): bool = +proc isQuotation*(s: MinValue): bool {.extern:"min_exported_symbol_$1".}= return s.kind == minQuotation -proc isString*(s: MinValue): bool = +proc isString*(s: MinValue): bool {.extern:"min_exported_symbol_$1".}= return s.kind == minString -proc isFloat*(s: MinValue): bool = +proc isFloat*(s: MinValue): bool {.extern:"min_exported_symbol_$1".}= return s.kind == minFloat -proc isInt*(s: MinValue): bool = +proc isInt*(s: MinValue): bool {.extern:"min_exported_symbol_$1".}= return s.kind == minInt -proc isNumber*(s: MinValue): bool = +proc isNumber*(s: MinValue): bool {.extern:"min_exported_symbol_$1".}= return s.kind == minInt or s.kind == minFloat proc isBool*(s: MinValue): bool = return s.kind == minBool -proc isStringLike*(s: MinValue): bool = +proc isStringLike*(s: MinValue): bool {.extern:"min_exported_symbol_$1".}= return s.isSymbol or s.isString or (s.isQuotation and s.qVal.len == 1 and s.qVal[0].isSymbol) -proc isDictionary*(q: MinValue): bool = +proc isDictionary*(q: MinValue): bool {.extern:"min_exported_symbol_$1".}= if not q.isQuotation: return false if q.qVal.len == 0:

@@ -57,30 +57,30 @@ return true

# Constructors -proc newVal*(s: string): MinValue = +proc newVal*(s: string): MinValue {.extern:"min_exported_symbol_$1".}= return MinValue(kind: minString, strVal: s) -proc newVal*(s: cstring): MinValue = +proc newVal*(s: cstring): MinValue {.extern:"min_exported_symbol_$1_2".}= return MinValue(kind: minString, strVal: $s) -proc newVal*(q: seq[MinValue], parentScope: ref MinScope): MinValue = +proc newVal*(q: seq[MinValue], parentScope: ref MinScope): MinValue {.extern:"min_exported_symbol_$1_3".}= return MinValue(kind: minQuotation, qVal: q, scope: newScopeRef(parentScope)) -proc newVal*(s: BiggestInt): MinValue = - return MinValue(kind: minInt, intVal: s) +proc newVal*(i: BiggestInt): MinValue {.extern:"min_exported_symbol_$1_4".}= + return MinValue(kind: minInt, intVal: i) -proc newVal*(s: BiggestFloat): MinValue = - return MinValue(kind: minFloat, floatVal: s) +proc newVal*(f: BiggestFloat): MinValue {.extern:"min_exported_symbol_$1_5".}= + return MinValue(kind: minFloat, floatVal: f) -proc newVal*(s: bool): MinValue = +proc newVal*(s: bool): MinValue {.extern:"min_exported_symbol_$1_6".}= return MinValue(kind: minBool, boolVal: s) -proc newSym*(s: string): MinValue = +proc newSym*(s: string): MinValue {.extern:"min_exported_symbol_$1".}= return MinValue(kind: minSymbol, symVal: s) # Get string value from string or quoted symbol -proc getFloat*(v: MinValue): float = +proc getFloat*(v: MinValue): float {.extern:"min_exported_symbol_$1".}= if v.isInt: return v.intVal.float elif v.isFloat:

@@ -88,7 +88,7 @@ return v.floatVal

else: raiseInvalid("Value is not a number") -proc getString*(v: MinValue): string = +proc getString*(v: MinValue): string {.extern:"min_exported_symbol_$1".}= if v.isSymbol: return v.symVal elif v.isString:
M examples/dyntest.nimexamples/dyntest.nim

@@ -1,11 +1,11 @@

## This is all you need to create a min module in Nim ## Compile with `nim c --app:lib --noMain -d:release -l:"-undefined dynamic_lookup" dyntest.nim` -include ../mindyn +import ../mindyn -proc dyntest*(i: In) {.rtl, dynlib, exportc.} = +proc dyntest*(i: In) {.dynlib, exportc.} = let def = i.define() - def.symbol("myp") do (i: In): + def.symbol("dynplus") do (i: In): let vals = i.expect("num", "num") let a = vals[0] let b = vals[1]
M lib/min_lang.nimlib/min_lang.nim

@@ -190,7 +190,7 @@ if qscope.scope.symbols.hasKey(sym) and qscope.scope.symbols[sym].sealed:

raiseUndefined("Attempting to redefine sealed symbol '$1'" % [sym]) let scope = i.scope info("[publish] Symbol: $2" % [sym]) - let op = proc(i: In) {.gcsafe, closure.} = + let op = proc(i: In) {.closure.} = let origscope = i.scope i.scope = scope i.evaluating = true
M min.nimmin.nim

@@ -1,3 +1,5 @@

+when not defined(windows): + {.passL: "-rdynamic".} import streams, critbits,
M mindyn.nimmindyn.nim

@@ -1,9 +1,4 @@

{.pragma: rtl, exportc, dynlib, cdecl.} -type - DynInfo* = object - moduleName*: string # The name of the symbol to load and run - dynlibVersion*: int # The version of the interface the dynlib is built for. This should increase if the interface changes - # Everything below here is to interface with the main program # Import for the missing types (Look into importing just type definitions) import

@@ -109,108 +104,116 @@ MinUndefinedError* = ref object of ValueError

MinEmptyStackError* = ref object of ValueError MinInvalidError* = ref object of ValueError MinOutOfBoundsError* = ref object of ValueError -proc raiseInvalid(msg: string) {.importc, extern:"raiseInvalid_Emp5jFVyMCrh15i1fpFZiQ".} -proc raiseUndefined(msg: string) {.importc, extern:"raiseUndefined_Emp5jFVyMCrh15i1fpFZiQ_2".} -proc raiseOutOfBounds(msg: string) {.importc, extern:"raiseOutOfBounds_Emp5jFVyMCrh15i1fpFZiQ_3".} -proc raiseEmptyStack() {.importc, extern:"raiseEmptyStack_TxAgT9bR9codeB2uLmVKwt3w".} -proc newScope(parent: ref MinScope): MinScope {.importc, extern:"newScope_rH9cNZXpQjLoAhnola5cX4Q".} -proc newScopeRef(parent: ref MinScope): ref MinScope {.importc, extern:"newScopeRef_s7aB4NQYrY7Hev87iAW4jw".} -proc open(my: var MinParser, input: Stream, filename: string) {.importc, extern:"open_9brvHSJ7qjV9aGAqIpwcMV3A".} -proc close(my: var MinParser) {.importc, extern:"close_vmj9agDNIDvOwQZe8A2kGIAparser".} -proc getInt(my: MinParser): int {.importc, extern:"getInt_bXIqXGzvO9aGBMkrzA6B15gparser".} -proc getFloat(my: MinParser): float {.importc, extern:"getFloat_VXTaXBiGVD6XkIZK3YSq5Aparser".} -proc kind(my: MinParser): MinEventKind {.importc, extern:"kind_tgDyDbkEOSH9aIKWnOecz4Aparser".} -proc getColumn(my: MinParser): int {.importc, extern:"getColumn_bXIqXGzvO9aGBMkrzA6B15g_2parser".} -proc getLine(my: MinParser): int {.importc, extern:"getLine_bXIqXGzvO9aGBMkrzA6B15g_3parser".} -proc getFilename(my: MinParser): string {.importc, extern:"getFilename_s9a5R24VyFqQ3N3m7ZkDqmAparser".} -proc errorMsg(my: MinParser, msg: string): string {.importc, extern:"errorMsg_cVsoiM0SE9cH0KWBNfKqZcA".} -proc errorMsg(my: MinParser): string {.importc, extern:"errorMsg_r87VYrPzvmEsJhjriyvyQw".} -proc errorMsgExpected(my: MinParser, e: string): string {.importc, extern:"errorMsgExpected_Wqyr2ROfsYVJGDFwgiczQw".} -proc raiseParsing(p: MinParser, msg: string) {.importc, extern:"raiseParsing_Tz7DX0jKGOjDMX8SFWqb1A".} -proc raiseUndefined(p:MinParser, msg: string) {.importc, extern:"raiseUndefined_Tz7DX0jKGOjDMX8SFWqb1A_2".} -proc parseNumber(my: var MinParser) {.importc, extern:"parseNumber_q1Bg9ctZWMedsyrbTHRwU9aQ".} -proc handleHexChar(c: char, x: var int): bool {.importc, extern:"handleHexChar_5qj5zQ9aD5ka0UVtIDvSjNg".} -proc parseString(my: var MinParser): MinTokenKind {.importc, extern:"parseString_e3KFIguKCxnkZTqCF3o3jg".} -proc parseSymbol(my: var MinParser): MinTokenKind {.importc, extern:"parseSymbol_4hcHuz8N3YVsotvxzfL3Kw".} -proc skip(my: var MinParser) {.importc, extern:"skip_iFcpIZyA9cJx6updYRSgzjw".} -proc getToken(my: var MinParser): MinTokenKind {.importc, extern:"getToken_e3KFIguKCxnkZTqCF3o3jg_2".} -proc next(my: var MinParser) {.importc, extern:"next_iFcpIZyA9cJx6updYRSgzjw_2".} -proc eat(p: var MinParser, token: MinTokenKind) {.importc, extern:"eat_WE9bi5nLbQn9cAjnzHQ9bV6Kw".} -proc parseMinValue(p: var MinParser, i: In): MinValue {.importc, extern:"parseMinValue_Y6xeteQ253Mvf1JjLWhFig".} -proc `$`(a: MinValue): string {.importc, extern:"dollar__byT09beg0JPSCPWB3NVBb9bQ".} -proc `$$`(a: MinValue): string {.importc, extern:"dollardollar__byT09beg0JPSCPWB3NVBb9bQ_2".} -proc print(a: MinValue) {.importc, extern:"print_az8I9cfVT9b9bR2oSHjBwYE9bQ".} -proc `==`(a: MinValue, b: MinValue): bool {.importc, extern:"eqeq__zMKrLdJOCGuSouwNLkqPvQ".} -proc typeName*(v: MinValue): string {.importc, extern:"typeName_81jMzzfB0Qc0O4DsVU5arg".} -proc isSymbol*(s: MinValue): bool {.importc, extern:"isSymbol_BKcj9aQlJC73fcAZURf0pHw".} -proc isQuotation*(s: MinValue): bool {.importc, extern:"isQuotation_BKcj9aQlJC73fcAZURf0pHw_2".} -proc isString*(s: MinValue): bool {.importc, extern:"isString_BKcj9aQlJC73fcAZURf0pHw_3".} -proc isFloat*(s: MinValue): bool {.importc, extern:"isFloat_BKcj9aQlJC73fcAZURf0pHw_8".} -proc isInt*(s: MinValue): bool {.importc, extern:"isInt_BKcj9aQlJC73fcAZURf0pHw_5".} -proc isNumber*(s: MinValue): bool {.importc, extern:"isNumber_BKcj9aQlJC73fcAZURf0pHw_6".} -proc isBool*(s: MinValue): bool {.importc, extern:"isBool_BKcj9aQlJC73fcAZURf0pHw_7".} -proc isStringLike*(s: MinValue): bool {.importc, extern:"isStringLike_BKcj9aQlJC73fcAZURf0pHw_8".} -proc isDictionary*(q: MinValue): bool {.importc, extern:"isDictionary_7f9afQ8e7zZDtSeY6FzGNrw".} -proc newVal*(s: string): MinValue {.importc, extern:"newVal_JF8l73VBhy9cJEUaMht6wZA".} -proc newVal*(s: cstring): MinValue {.importc, extern:"newVal_MSseSJELDL5qivFR59byJ8Q".} -proc newVal*(q: seq[MinValue], parentScope: ref MinScope): MinValue {.importc, extern:"newVal_1PJ4YdZbCuyyD9bQkH2eu6A".} -proc newVal*(s: BiggestInt): MinValue {.importc, extern:"newVal_xDcIKp9bEb37NZkc9bhRat9cQ".} -proc newVal*(s: BiggestFloat): MinValue {.importc, extern:"newVal_ipbzO9cNeJyt42iGojkGmgg".} -proc newVal*(s: bool): MinValue {.importc, extern:"newVal_3PdI7sQ7HL5wBrAMsSG5sQ".} -proc newSym*(s: string): MinValue {.importc, extern:"newSym_JF8l73VBhy9cJEUaMht6wZA_2".} -proc getString*(v: MinValue): string {.importc, extern:"getString_81jMzzfB0Qc0O4DsVU5arg_2".} -proc define*(i: In): ref MinScope {.importc, extern:"define_HtvBzo0skz2GBYAKuFddKA".} -proc symbol*(scope: ref MinScope, sym: string, p: MinOperatorProc) {.importc, extern:"symbol_D4i19cVxxCgOFsbGlV20kyQ".} -proc symbol*(scope: ref MinScope, sym: string, v: MinValue) {.importc, extern:"symbol_XrX9bLAdrrQ3LgR9a9aYCQDXA".} -proc sigil*(scope: ref MinScope, sym: string, p: MinOperatorProc) {.importc, extern:"sigil_D4i19cVxxCgOFsbGlV20kyQ_2".} -proc sigil*(scope: ref MinScope, sym: string, v: MinValue) {.importc, extern:"sigil_XrX9bLAdrrQ3LgR9a9aYCQDXA_2".} -proc finalize*(scope: ref MinScope, name: string) {.importc, extern:"finalize_Igz9a7Xvo9cCa28si6nE0p5A".} -proc dget*(q: MinValue, s: MinValue): MinValue {.importc, extern:"dget_mfiqh3xcyXvnw9ajEytZuIA".} -proc dhas*(q: MinValue, s: MinValue): bool {.importc, extern:"dhas_MEAApOlp4yH17chuSa0k9bA".} -proc ddel*(i: In, p: MinValue, s: MinValue): MinValue {.importc, extern:"ddel_Riw3bw1BbxVPbq6m4TtOjw".} -proc dset*(i: In, p: MinValue, s: MinValue, m: MinValue): MinValue {.importc, extern:"dset_17HpKix9agOFpoPvvopNcCA".} -proc keys*(i: In, q: MinValue): MinValue {.importc, extern:"keys_oXC9bS9cwNWVkX1wVKP9aFEGA".} -proc values*(i: In, q: MinValue): MinValue {.importc, extern:"values_oXC9bS9cwNWVkX1wVKP9aFEGA_2".} -proc `%`*(a: MinValue): JsonNode {.importc, extern:"percent__QWqVWTWlpTitafp2NrtHgw".} -proc fromJson*(i: In, json: JsonNode): MinValue {.importc, extern:"fromJson_xPRwXdsUk4l7MGnYd2GbVA".} -proc reverse[T](xs: openarray[T]): seq[T] {.importc, extern:"reverse_drwb9cipBBt6vULs9c1MUijg".} -proc expect*(i: var MinInterpreter, elements: varargs[string]): seq[MinValue] {.importc, extern:"expect_EYb0Rd1E6Tl9bqxEJWylifg".} -proc reqQuotationOfQuotations*(i: var MinInterpreter, a: var MinValue) {.importc, extern:"reqQuotationOfQuotations_Xy0o2sh9cpmSUTDb9cbQNwQg".} -proc reqQuotationOfNumbers*(i: var MinInterpreter, a: var MinValue) {.importc, extern:"reqQuotationOfNumbers_Xy0o2sh9cpmSUTDb9cbQNwQg_2".} -proc reqQuotationOfSymbols*(i: var MinInterpreter, a: var MinValue) {.importc, extern:"reqQuotationOfSymbols_Xy0o2sh9cpmSUTDb9cbQNwQg_3".} -proc reqTwoNumbersOrStrings*(i: var MinInterpreter, a, b: var MinValue) {.importc, extern:"reqTwoNumbersOrStrings_iouGpQgslNcuoSL0Wzu7kQ".} -proc reqStringOrQuotation*(i: var MinInterpreter, a: var MinValue) {.importc, extern:"reqStringOrQuotation_Xy0o2sh9cpmSUTDb9cbQNwQg_4".} -proc reqTwoQuotationsOrStrings*(i: var MinInterpreter, a, b: var MinValue) {.importc, extern:"reqTwoQuotationsOrStrings_iouGpQgslNcuoSL0Wzu7kQ_2".} -proc reqTwoSimilarTypesNonSymbol*(i: var MinInterpreter, a, b: var MinValue) {.importc, extern:"reqTwoSimilarTypesNonSymbol_iouGpQgslNcuoSL0Wzu7kQ_3".} -proc copy*(s: ref MinScope): ref MinScope {.importc, extern:"copy_KGlnVwWC9c0GiqXFwLDTiww".} -proc getSymbol*(scope: ref MinScope, key: string): MinOperator {.importc, extern:"getSymbol_fLEzdqSpt81S0Of5t4H9afg".} -proc hasSymbol*(scope: ref MinScope, key: string): bool {.importc, extern:"hasSymbol_58ut1Z9aCNCsBFnk7k9a9cVKA".} -proc delSymbol*(scope: ref MinScope, key: string): bool {.importc, extern:"delSymbol_58ut1Z9aCNCsBFnk7k9a9cVKA_2".} -proc setSymbol*(scope: ref MinScope, key: string, value: MinOperator, override = false): bool {.importc, extern:"setSymbol_i9bO9b9aWD4K9c3RcQs0RqQvPw".} -proc getSigil*(scope: ref MinScope, key: string): MinOperator {.importc, extern:"getSigil_fLEzdqSpt81S0Of5t4H9afg_2".} -proc hasSigil*(scope: ref MinScope, key: string): bool {.importc, extern:"hasSigil_58ut1Z9aCNCsBFnk7k9a9cVKA_3".} -proc previous*(scope: ref MinScope): ref MinScope {.importc, extern:"previous_wp9cZN2pi3N79at4ESdxFNVQ".} -proc raiseRuntime*(msg: string, qVal: var seq[MinValue]) {.importc, extern:"raiseRuntime_t8oUDThVodY80ZU1ov5Z9cQ".} -proc dump*(i: MinInterpreter): string {.importc, extern:"dump_QNAGfSm5dAMbe9cao1yAs9bg".} -proc debug*(i: In, value: MinValue) {.importc, extern:"debug_e4IWAT3CueUziUEgqNhCEA".} -proc debug*(i: In, value: string) {.importc, extern:"debug_lPtsJwNzbYFsAR31JL52GA".} -proc newMinInterpreter*(filename: string): MinInterpreter {.importc, extern:"newMinInterpreter_XvlvXMt0JDVisNg0vLdKLQ".} -proc copy*(i: MinInterpreter, filename: string): MinInterpreter {.importc, extern:"copy_gOoDr5ILrrcZmPeoNmvPmg".} -proc formatError(sym: MinValue, message: string): string {.importc, extern:"formatError_c89a9aMhg9av88jUAkonIhspw".} -proc formatTrace(sym: MinValue): string {.importc, extern:"formatTrace_TfxbUETR0myClep3aQiOxA".} -proc stackTrace(i: In) {.importc, extern:"stackTrace_jfgtXM0Fziq5qAA4WP56DA".} -proc error(i: In, message: string) {.importc, extern:"error_KPzdvl74rfHwj1Zjzl9clSQ".} -proc open*(i: In, stream:Stream, filename: string) {.importc, extern:"open_0S1akx2yO9cGND7o1a5E4Pg".} -proc close*(i: In) {.importc, extern:"close_jfgtXM0Fziq5qAA4WP56DA_2".} -proc apply*(i: In, op: MinOperator) {.importc, extern:"apply_rdLuMUFDgimLSTje2hi9a9cw".} -proc push*(i: In, val: MinValue) {.importc, extern:"push_5Bl42rKgV9afPr4fSWYKCQQ".} -proc dequote*(i: In, q: var MinValue) {.importc, extern:"dequote_iIi9a4U4PSOa3lI3GtpF9a2g".} -proc apply*(i: In, q: var MinValue) {.importc, extern:"apply_iIi9a4U4PSOa3lI3GtpF9a2g_2".} -proc pop*(i: In): MinValue {.importc, extern:"pop_kQ2ndJ8jYAFjieSQojhyOA".} -proc peek*(i: MinInterpreter): MinValue {.importc, extern:"peek_iWvRjZI9bPYXgbwT9bMlY33g".} -proc interpret*(i: In): MinValue {.importc, extern:"interpret_XWC8a7Zv9bICBdwhFZC4oFw".} -proc eval*(i: In, s: string, name: string) {.importc, extern:"eval_IB9cHX0kT7i7VJ1JVxalc0g".} -proc load*(i: In, s: string) {.importc, extern:"load_0LYMivTZTdTPkcMxl9cGHiw".} -proc filetype*(p: PathComponent): string {.importc, extern:"filetype_FZiFjJo8tLR4Z31M0hOccg".} -proc unixPermissions*(s: set[FilePermission]): int {.importc, extern:"unixPermissions_yRhMgkace1wP9a9cKdvJCJhw".} -proc toFilePermissions*(p: BiggestInt): set[FilePermission] {.importc, extern:"toFilePermissions_iFbq0Qn5CDseGqlJex9cAkw".} + +# parser.nim +proc raiseInvalid(msg: string) {.importc, extern:"min_exported_symbol_$1".} +proc raiseUndefined(msg: string) {.importc, extern:"min_exported_symbol_$1".} +proc raiseOutOfBounds(msg: string) {.importc, extern:"min_exported_symbol_$1".} +proc raiseEmptyStack() {.importc, extern:"min_exported_symbol_$1".} +proc newScope(parent: ref MinScope): MinScope {.importc, extern:"min_exported_symbol_$1".} +proc newScopeRef(parent: ref MinScope): ref MinScope {.importc, extern:"min_exported_symbol_$1".} +proc open(my: var MinParser, input: Stream, filename: string) {.importc, extern:"min_exported_symbol_$1".} +proc close(my: var MinParser) {.importc, extern:"min_exported_symbol_$1".} +proc getInt(my: MinParser): int {.importc, extern:"min_exported_symbol_$1".} +proc getFloat(my: MinParser): float {.importc, extern:"min_exported_symbol_$1".} +proc kind(my: MinParser): MinEventKind {.importc, extern:"min_exported_symbol_$1".} +proc getColumn(my: MinParser): int {.importc, extern:"min_exported_symbol_$1".} +proc getLine(my: MinParser): int {.importc, extern:"min_exported_symbol_$1".} +proc getFilename(my: MinParser): string {.importc, extern:"min_exported_symbol_$1".} +proc errorMsg(my: MinParser, msg: string): string {.importc, extern:"min_exported_symbol_$1".} +proc errorMsg(my: MinParser): string {.importc, extern:"min_exported_symbol_$1_2".} +proc errorMsgExpected(my: MinParser, e: string): string {.importc, extern:"min_exported_symbol_$1".} +proc raiseParsing(p: MinParser, msg: string) {.importc, extern:"min_exported_symbol_$1".} +proc raiseUndefined(p:MinParser, msg: string) {.importc, extern:"min_exported_symbol_$1_2".} +proc getToken(my: var MinParser): MinTokenKind {.importc, extern:"min_exported_symbol_$1".} +proc next(my: var MinParser) {.importc, extern:"min_exported_symbol_$1".} +proc eat(p: var MinParser, token: MinTokenKind) {.importc, extern:"min_exported_symbol_$1".} +proc parseMinValue(p: var MinParser, i: In): MinValue {.importc, extern:"min_exported_symbol_$1".} +proc `$`(a: MinValue): string {.importc, extern:"min_exported_symbol_$1".} +proc `$$`(a: MinValue): string {.importc, extern:"min_exported_symbol_$1".} +proc print(a: MinValue) {.importc, extern:"min_exported_symbol_$1".} +proc `==`(a: MinValue, b: MinValue): bool {.importc, extern:"min_exported_symbol_eqeq".} + +# value.nim +proc typeName*(v: MinValue): string {.importc, extern:"min_exported_symbol_$1".} +proc isSymbol*(s: MinValue): bool {.importc, extern:"min_exported_symbol_$1".} +proc isQuotation*(s: MinValue): bool {.importc, extern:"min_exported_symbol_$1".} +proc isString*(s: MinValue): bool {.importc, extern:"min_exported_symbol_$1".} +proc isFloat*(s: MinValue): bool {.importc, extern:"min_exported_symbol_$1".} +proc isInt*(s: MinValue): bool {.importc, extern:"min_exported_symbol_$1".} +proc isNumber*(s: MinValue): bool {.importc, extern:"min_exported_symbol_$1".} +proc isBool*(s: MinValue): bool {.importc, extern:"min_exported_symbol_$1".} +proc isStringLike*(s: MinValue): bool {.importc, extern:"min_exported_symbol_$1".} +proc isDictionary*(q: MinValue): bool {.importc, extern:"min_exported_symbol_$1".} +proc newVal*(s: string): MinValue {.importc, extern:"min_exported_symbol_$1".} +proc newVal*(s: cstring): MinValue {.importc, extern:"min_exported_symbol_$1_2".} +proc newVal*(q: seq[MinValue], parentScope: ref MinScope): MinValue {.importc, extern:"min_exported_symbol_$1_3".} +proc newVal*(s: BiggestInt): MinValue {.importc, extern:"min_exported_symbol_$1_4".} +proc newVal*(s: BiggestFloat): MinValue {.importc, extern:"min_exported_symbol_$1_5".} +proc newVal*(s: bool): MinValue {.importc, extern:"min_exported_symbol_$1_6".} +proc newSym*(s: string): MinValue {.importc, extern:"min_exported_symbol_$1".} +proc getFloat*(v: MinValue): float {.importc, extern:"min_exported_symbol_$1".} +proc getString*(v: MinValue): string {.importc, extern:"min_exported_symbol_$1".} + +# utils.nim +proc define*(i: In): ref MinScope {.importc, extern:"min_exported_symbol_$1".} +proc symbol*(scope: ref MinScope, sym: string, p: MinOperatorProc) {.importc, extern:"min_exported_symbol_$1".} +proc symbol*(scope: ref MinScope, sym: string, v: MinValue) {.importc, extern:"min_exported_symbol_$1_2".} +proc sigil*(scope: ref MinScope, sym: string, p: MinOperatorProc) {.importc, extern:"min_exported_symbol_$1".} +proc sigil*(scope: ref MinScope, sym: string, v: MinValue) {.importc, extern:"min_exported_symbol_$1_2".} +proc finalize*(scope: ref MinScope, name: string) {.importc, extern:"min_exported_symbol_$1".} +proc dget*(q: MinValue, s: MinValue): MinValue {.importc, extern:"min_exported_symbol_$1".} +proc dhas*(q: MinValue, s: MinValue): bool {.importc, extern:"min_exported_symbol_$1".} +proc ddel*(i: In, p: MinValue, s: MinValue): MinValue {.importc, extern:"min_exported_symbol_$1".} +proc dset*(i: In, p: MinValue, s: MinValue, m: MinValue): MinValue {.importc, extern:"min_exported_symbol_$1".} +proc keys*(i: In, q: MinValue): MinValue {.importc, extern:"min_exported_symbol_$1".} +proc values*(i: In, q: MinValue): MinValue {.importc, extern:"min_exported_symbol_$1".} +proc `%`*(a: MinValue): JsonNode {.importc, extern:"min_exported_symbol_percent".} +proc fromJson*(i: In, json: JsonNode): MinValue {.importc, extern:"min_exported_symbol_$1".} +proc reverse[T](xs: openarray[T]): seq[T] {.importc, extern:"min_exported_symbol_$1".} +proc expect*(i: var MinInterpreter, elements: varargs[string]): seq[MinValue] {.importc, extern:"min_exported_symbol_$1".} +proc reqQuotationOfQuotations*(i: var MinInterpreter, a: var MinValue) {.importc, extern:"min_exported_symbol_$1".} +proc reqQuotationOfNumbers*(i: var MinInterpreter, a: var MinValue) {.importc, extern:"min_exported_symbol_$1".} +proc reqQuotationOfSymbols*(i: var MinInterpreter, a: var MinValue) {.importc, extern:"min_exported_symbol_$1".} +proc reqTwoNumbersOrStrings*(i: var MinInterpreter, a, b: var MinValue) {.importc, extern:"min_exported_symbol_$1".} +proc reqStringOrQuotation*(i: var MinInterpreter, a: var MinValue) {.importc, extern:"min_exported_symbol_$1".} +proc reqTwoQuotationsOrStrings*(i: var MinInterpreter, a, b: var MinValue) {.importc, extern:"min_exported_symbol_$1".} +proc reqTwoSimilarTypesNonSymbol*(i: var MinInterpreter, a, b: var MinValue) {.importc, extern:"min_exported_symbol_$1".} + +# scope.nim +proc copy*(s: ref MinScope): ref MinScope {.importc, extern:"min_exported_symbol_$1".} +proc getSymbol*(scope: ref MinScope, key: string): MinOperator {.importc, extern:"min_exported_symbol_$1".} +proc hasSymbol*(scope: ref MinScope, key: string): bool {.importc, extern:"min_exported_symbol_$1".} +proc delSymbol*(scope: ref MinScope, key: string): bool {.importc, extern:"min_exported_symbol_$1".} +proc setSymbol*(scope: ref MinScope, key: string, value: MinOperator, override = false): bool {.importc, extern:"min_exported_symbol_$1".} +proc getSigil*(scope: ref MinScope, key: string): MinOperator {.importc, extern:"min_exported_symbol_$1".} +proc hasSigil*(scope: ref MinScope, key: string): bool {.importc, extern:"min_exported_symbol_$1".} +proc previous*(scope: ref MinScope): ref MinScope {.importc, extern:"min_exported_symbol_$1".} + +# interpreter.nim +proc raiseRuntime*(msg: string, qVal: var seq[MinValue]) {.importc, extern:"min_exported_symbol_$1".} +proc dump*(i: MinInterpreter): string {.importc, extern:"min_exported_symbol_$1".} +proc debug*(i: In, value: MinValue) {.importc, extern:"min_exported_symbol_$1".} +proc debug*(i: In, value: string) {.importc, extern:"min_exported_symbol_$1_2".} +proc newMinInterpreter*(filename: string): MinInterpreter {.importc, extern:"min_exported_symbol_$1".} +proc copy*(i: MinInterpreter, filename: string): MinInterpreter {.importc, extern:"min_exported_symbol_$1_2".} +proc formatError(sym: MinValue, message: string): string {.importc, extern:"min_exported_symbol_$1".} +proc formatTrace(sym: MinValue): string {.importc, extern:"min_exported_symbol_$1".} +proc stackTrace(i: In) {.importc, extern:"min_exported_symbol_$1".} +proc error(i: In, message: string) {.importc, extern:"min_exported_symbol_$1".} +proc open*(i: In, stream:Stream, filename: string) {.importc, extern:"min_exported_symbol_$1_2".} +proc close*(i: In) {.importc, extern:"min_exported_symbol_$1_2".} +proc apply*(i: In, op: MinOperator) {.importc, extern:"min_exported_symbol_$1".} +proc push*(i: In, val: MinValue) {.importc, extern:"min_exported_symbol_$1".} +proc dequote*(i: In, q: var MinValue) {.importc, extern:"min_exported_symbol_$1".} +proc apply*(i: In, q: var MinValue) {.importc, extern:"min_exported_symbol_$1_2".} +proc pop*(i: In): MinValue {.importc, extern:"min_exported_symbol_$1".} +proc peek*(i: MinInterpreter): MinValue {.importc, extern:"min_exported_symbol_$1".} +proc interpret*(i: In): MinValue {.importc, extern:"min_exported_symbol_$1".} +proc eval*(i: In, s: string, name: string) {.importc, extern:"min_exported_symbol_$1".} +proc load*(i: In, s: string) {.importc, extern:"min_exported_symbol_$1".} + +# fileutils.nim +proc filetype*(p: PathComponent): string {.importc, extern:"min_exported_symbol_$1".} +proc unixPermissions*(s: set[FilePermission]): int {.importc, extern:"min_exported_symbol_$1".} +proc toFilePermissions*(p: BiggestInt): set[FilePermission] {.importc, extern:"min_exported_symbol_$1".}