all repos — min @ 4fd384f43567d7f952e21d9d061eedc411681708

A small but practical concatenative programming language.

Now using simple counter for compiled variables.
h3rald h3rald@h3rald.com
Wed, 16 Dec 2020 03:39:43 +0100
commit

4fd384f43567d7f952e21d9d061eedc411681708

parent

0daa8ff769fd1e273bb0c3ee1e3d16156f98934f

1 files changed, 8 insertions(+), 4 deletions(-)

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

@@ -3,7 +3,6 @@ import

lexbase, strutils, sequtils, - oids, streams, critbits, baseutils

@@ -119,6 +118,8 @@ MinUndefinedError* = ref object of ValueError

MinEmptyStackError* = ref object of ValueError MinInvalidError* = ref object of ValueError MinOutOfBoundsError* = ref object of ValueError + +var CVARCOUNT = 0 # Helpers

@@ -695,7 +696,8 @@ of tkFloat:

result = @[op&"MinValue(kind: minFloat, floatVal: "&p.a&")"] discard getToken(p) of tkBracketLe: - var qvar = "q" & $genOid() + CVARCOUNT.inc + var qvar = "q" & $CVARCOUNT result.add indent&"var "&qvar&" = newSeq[MinValue](0)" discard getToken(p) while p.token != tkBracketRi:

@@ -711,8 +713,10 @@ var val: MinValue

discard getToken(p) var c = 0 var valInitialized = false - var scopevar = "scope" & $genOid() - var valvar = "val" & $genOid() + CVARCOUNT.inc + var scopevar = "scope" & $CVARCOUNT + CVARCOUNT.inc + var valvar = "val" & $CVARCOUNT while p.token != tkBraceRi: c = c+1 var instructions = p.compileMinValue(i, false, indent)