all repos — min @ b154ead9ac4d63e4a3e954c85016154e1066294b

A small but practical concatenative programming language.

fix(counquote) Fixed coroutine support & updated tests.
h3rald h3rald@h3rald.com
Fri, 10 Jun 2016 20:39:36 +0200
commit

b154ead9ac4d63e4a3e954c85016154e1066294b

parent

0013968299e2faf94008545a70e53b1faa680dd0

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

jump to
M lib/lang.nimlib/lang.nim

@@ -219,15 +219,16 @@ .symbol("counquote") do (i: In):

var q: MinValue i.reqQuotation q let stack = i.copystack - proc coroutine(i: MinInterpreter, val: MinValue, results: ptr MinStack) {.routine.} = - i.unquote("<counquote>", val) - results[].add i.stack - var results = newSeq[MinValue](0) - for r in q.qVal: - # TODO raise error if r is not a quotation + proc coroutine(i: MinInterpreter, c: int, results: ptr MinStack) {.routine.} = + i.unquote("<counquote>", q.qVal[c]) + results[][c] = i.stack[0] + var results = newSeq[MinValue](q.qVal.len) + for c in 0..q.qVal.high: + if not q.qVal[c].isQuotation: + raise MinInvalidError(msg: "Item #$1 is not a quotation" % [$(c+1)]) var i2 = i.copy(i.filename) var res: MinStack = newSeq[MinValue](0) - pRun coroutine, (i2, r, results.addr) + pRun coroutine, (i2, c, results.addr) waitAllRoutine() i.push results.newVal
M tests/lang.mintests/lang.min

@@ -101,11 +101,12 @@ (1 at)

) try "Test Message" ==) assert ( + ((dup 0 ==) (1 +) (dup 1 -) ( * ) linrec) :factorial ( - ((1 2 3) (dup *) map) - ((4 5 6) (dup *) map) - ((7 8 9) (dup *) map) - ) counquote ((1 4 9) (16 25 36) (49 64 81)) ==) assert + (8 factorial) + (12 factorial) + (9 factorial) + ) counquote (40320 479001600 362880) ==) assert report ; Tidy up