From 4863af23b5280354293524191cba82f09403b741 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Fri, 8 Oct 2021 23:11:06 +0200 Subject: Fixed failing mycology tests --- README.md | 2 +- src/defaultIO.nim | 5 ++++- src/pointer.nim | 9 ++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f0c07e4..7918f60 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # NimFunge98 : a Funge-98 interpreter written in nim -This repository contains code for a nim program that can interpret a valid [Funge-98](https://github.com/catseye/Funge-98/blob/master/doc/funge98.markdown) program. It will soon pass the [mycology test suite](https://github.com/Deewiant/Mycology). +This repository contains code for a nim program that can interpret a valid [Funge-98](https://github.com/catseye/Funge-98/blob/master/doc/funge98.markdown) program. It passes the [mycology test suite](https://github.com/Deewiant/Mycology). Current limitations are : - currently does not implement any fingerprints diff --git a/src/defaultIO.nim b/src/defaultIO.nim index ccf4476..1c3e2ca 100644 --- a/src/defaultIO.nim +++ b/src/defaultIO.nim @@ -34,7 +34,10 @@ proc defaultDecimalInput*(): int = return result proc defaultCharacterOutput*(v: int) = - discard stdout.writeChars(@[v.char()], 0, 1) + try: + discard stdout.writeChars(@[v.char()], 0, 1) + except RangeDefect: + discard stdout.writeBuffer(unsafeAddr v, 4) proc defaultDecimalOutput*(v: int) = stdout.write(&"{v} ") diff --git a/src/pointer.nim b/src/pointer.nim index 91fb8be..219fa12 100644 --- a/src/pointer.nim +++ b/src/pointer.nim @@ -217,13 +217,16 @@ proc Eval(p: var Pointer, f: var Field, c: int): (bool, ref int) = of "SHELL": discard else: continue p.ss[].Push(0) - for i in value.len-1..0: + for i in countdown(value.len-1, 0): p.ss[].Push(int(value[i])) + p.ss[].Push(int('=')) + for i in countdown(key.len-1, 0): + p.ss[].Push(int(key[i])) # 19 p.ss[].PushVector((0, 0)) for i in 0..