all repos — min @ 7c14158611ecb9d23761bc5195b33f528760b72a

A small but practical concatenative programming language.

Fixed Nim 2.0 compilation errors.
h3rald h3rald@h3rald.com
Wed, 02 Aug 2023 15:24:11 +0000
commit

7c14158611ecb9d23761bc5195b33f528760b72a

parent

afa50cc6d41383a966ef75ba8993b384b588690f

M min.nimsmin.nims

@@ -9,6 +9,8 @@ switch("amd64.linux.gcc.exe", "x86_64-linux-musl-gcc")

switch("amd64.linux.gcc.linkerexe", "x86_64-linux-musl-gcc") switch("opt", "size") +switch("deepcopy", "on") +switch("threadAnalysis", "off") when not defined(dev): switch("define", "release")

@@ -23,7 +25,6 @@ else:

switch("dynlibOverride", "pcre") when defined(ssl): - switch("threads", "on") when defined(windows): # TODO", change once issue nim#15220 is resolved switch("define", "noOpenSSLHacks")
M minpkg/core/interpreter.nimminpkg/core/interpreter.nim

@@ -147,9 +147,9 @@

proc close*(i: In) = i.parser.close(); -proc push*(i: In, val: MinValue) {.gcsafe.} +proc push*(i: In, val: MinValue) -proc call*(i: In, q: var MinValue): MinValue {.gcsafe.}= +proc call*(i: In, q: var MinValue): MinValue = var i2 = newMinInterpreter("<call>") i2.trace = i.trace i2.scope = i.scope

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

raise return i2.stack.newVal -proc callValue*(i: In, v: var MinValue): MinValue {.gcsafe.}= +proc callValue*(i: In, v: var MinValue): MinValue = var i2 = newMinInterpreter("<call-value>") i2.trace = i.trace i2.scope = i.scope

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

raise return i2.stack[0] -proc copyDict*(i: In, val: MinValue): MinValue {.gcsafe.}= +proc copyDict*(i: In, val: MinValue): MinValue = # Assuming val is a dictionary var v = newDict(i.scope) v.scope.symbols = val.scope.symbols

@@ -187,7 +187,7 @@ if not val.obj.isNil:

v.obj = val.obj return v -proc apply*(i: In, op: MinOperator, sym = "") {.gcsafe.}= +proc apply*(i: In, op: MinOperator, sym = "") {.effectsOf: op.} = if op.kind == minProcOp: op.prc(i) else:

@@ -211,7 +211,7 @@ q.qVal = qqval

else: i.push(q) -proc apply*(i: In, q: var MinValue) {.gcsafe.}= +proc apply*(i: In, q: var MinValue) = var i2 = newMinInterpreter("<apply>") i2.trace = i.trace i2.scope = i.scope

@@ -246,7 +246,7 @@ column: i.currSym.column,

outerSym: i.currSym.symVal, docComment: i.currSym.docComment) -proc push*(i: In, val: MinValue) {.gcsafe.}= +proc push*(i: In, val: MinValue) = if val.kind == minSymbol: i.debug(val) if not i.evaluating:

@@ -349,7 +349,7 @@

proc compileFile*(i: In, main: bool): seq[string] {.discardable.} = result = newSeq[string](0) if not main: - result.add "COMPILEDMINFILES[\"$#\"] = proc(i: In) {.gcsafe.}=" % i.filename + result.add "COMPILEDMINFILES[\"$#\"] = proc(i: In) =" % i.filename result = result.concat(i.rawCompile(" ")) else: result = i.rawCompile("")
M minpkg/core/parser.nimminpkg/core/parser.nim

@@ -103,7 +103,7 @@ parent*: ref MinScope

symbols*: CritBitTree[MinOperator] sigils*: CritBitTree[MinOperator] kind*: MinScopeKind - MinOperatorProc* = proc (i: In) {.closure, gcsafe.} + MinOperatorProc* = proc (i: In) {.closure.} MinOperatorKind* = enum minProcOp minValOp
M minpkg/core/utils.nimminpkg/core/utils.nim

@@ -17,13 +17,13 @@ var scope = newScopeRef(i.scope, minNativeScope)

scope.parent = i.scope return scope -proc symbol*(scope: ref MinScope, sym: string, p: MinOperatorProc) = +proc symbol*(scope: ref MinScope, sym: string, p: MinOperatorProc) {.effectsOf: p.} = scope.symbols[sym] = MinOperator(prc: p, kind: minProcOp, sealed: true) proc symbol*(scope: ref MinScope, sym: string, v: MinValue) = 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) {.effectsOf: p.} = scope.sigils[sym] = MinOperator(prc: p, kind: minProcOp, sealed: true) proc sigil*(scope: ref MinScope, sym: string, v: MinValue) =

@@ -176,9 +176,9 @@ return res.newVal

# Validators -proc validate*(i: In, value: MinValue, t: string, generics: var CritBitTree[string]): bool {.gcsafe.} +proc validate*(i: In, value: MinValue, t: string, generics: var CritBitTree[string]): bool -proc validateValueType*(i: var MinInterpreter, element: string, value: MinValue, generics: var CritBitTree[string], vTypes: var seq[string], c: int): bool {.gcsafe.} = +proc validateValueType*(i: var MinInterpreter, element: string, value: MinValue, generics: var CritBitTree[string], vTypes: var seq[string], c: int): bool = vTypes.add value.typeName let ors = element.split("|") for to in ors:

@@ -203,7 +203,7 @@ if andr:

result = true break -proc validateValueType*(i: var MinInterpreter, element: string, value: MinValue): bool {.gcsafe.} = +proc validateValueType*(i: var MinInterpreter, element: string, value: MinValue): bool = var g: CritBitTree[string] var s = newSeq[string](0) var c = 0

@@ -297,7 +297,7 @@ return true

# The following is used in operator signatures -proc expect*(i: var MinInterpreter, elements: varargs[string], generics: var CritBitTree[string]): seq[MinValue] {.gcsafe.}= +proc expect*(i: var MinInterpreter, elements: varargs[string], generics: var CritBitTree[string]): seq[MinValue] = if not DEV: # Ignore validation, just return elements result = newSeq[MinValue](0)
M minpkg/lib/min_http.nimminpkg/lib/min_http.nim

@@ -37,7 +37,7 @@

proc http_module*(i: In)= let def = i.define() - def.symbol("request") do (i: In) {.gcsafe.}: + def.symbol("request") do (i: In) : let vals = i.expect "dict" let req = vals[0] let cli = newCli()

@@ -83,7 +83,7 @@ let url = vals[1]

let cli = newCli() cli.downloadFile(url.getString, file.getString) - def.symbol("start-server") do (ii: In) {.gcsafe.}: + def.symbol("start-server") do (ii: In) : let vals = ii.expect "dict" let cfg = vals[0] if not cfg.dhas("port"):
M minpkg/lib/min_io.nimminpkg/lib/min_io.nim

@@ -41,8 +41,9 @@ var q = vals[1]

if not KEYNAMES.contains(key) and not KEYSEQS.contains(key): raiseInvalid("Unrecognized key: " & key) var ic = i.copy(i.filename) - KEYMAP[key] = proc (ed: var LineEditor) {.gcsafe.} = + let action = proc (ed: var LineEditor) {.closure.} = ic.apply(q) + KEYMAP[key] = action def.symbol("newline") do (i: In): echo ""

@@ -93,17 +94,17 @@ if ch[0].getString.len != 1:

raiseInvalid("Symbol putch requires a string containing a single character.") putchr(ch[0].getString[0].cint) - def.symbol("password") do (i: In) {.gcsafe.}: + def.symbol("password") do (i: In) : var ed = initEditor() i.push ed.password("Enter Password: ").newVal - def.symbol("ask") do (i: In) {.gcsafe.}: + def.symbol("ask") do (i: In) : var ed = initEditor() let vals = i.expect("str") let s = vals[0] i.push ed.readLine(s.getString & ": ").newVal - def.symbol("confirm") do (i: In) {.gcsafe.}: + def.symbol("confirm") do (i: In) : var ed = initEditor() let vals = i.expect("str") let s = vals[0]

@@ -119,7 +120,7 @@ stdout.flushFile()

return confirm() i.push confirm().newVal - def.symbol("choose") do (i: In) {.gcsafe.}: + def.symbol("choose") do (i: In) : var ed = initEditor() let vals = i.expect("'sym", "quot") let s = vals[0]
M minpkg/lib/min_lang.nimminpkg/lib/min_lang.nim

@@ -26,7 +26,7 @@

const HELPFILE = "../../help.json".slurp let HELP = HELPFILE.parseJson - def.symbol("from-json") do (i: In) {.gcsafe.}: + def.symbol("from-json") do (i: In) : let vals = i.expect("str") let s = vals[0] i.push i.fromJson(s.getString.parseJson)

@@ -38,7 +38,7 @@ i.push(($((i%q).pretty)).newVal)

# Save/load symbols - def.symbol("save-symbol") do (i: In) {.gcsafe.}: + def.symbol("save-symbol") do (i: In) : let vals = i.expect("'sym") let s = vals[0] let sym = s.getString

@@ -339,7 +339,7 @@ def.symbol("puts") do (i: In):

let a = i.peek echo $$a - def.symbol("gets") do (i: In) {.gcsafe.}: + def.symbol("gets") do (i: In) : var ed = initEditor() i.push ed.readLine().newVal
M minpkg/lib/min_str.nimminpkg/lib/min_str.nim

@@ -66,7 +66,7 @@ let q = vals[0]

let reg = re(vals[1].strVal) let s_find = vals[2].strVal var i2 = i.copy(i.filename) - let repFn = proc(match: RegexMatch): string = + let repFn = proc(match: RegexMatch): string {.closure.} = var ss = newSeq[MinValue](0) ss.add match.match.newVal for s in match.captures: