From aa049227c17f15ad22092f1fcab4410bbf3521ba Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sat, 26 Aug 2017 23:16:00 +0200 Subject: Cleanup and features debugger, bitwise ops, bounds checking, hex literals, better typing of some optimisations, makefile fix, exit function. --- bf.lang | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'bf.lang') diff --git a/bf.lang b/bf.lang index e2f6788..6f7426b 100644 --- a/bf.lang +++ b/bf.lang @@ -22,7 +22,7 @@ func int[] makejumpmap(char[] src, int srclen) { int stkp := 0; int i := 0; while (i < srclen) { - putint(i); putc(' '); putint(stkp); putc(' '); putc(src[i]); putc('\n'); + // putint(i); putc(' '); putint(stkp); putc(' '); putc(src[i]); putc('\n'); if (src[i] == '[') { stack[stkp] = i; stkp = stkp + 1; @@ -35,6 +35,9 @@ func int[] makejumpmap(char[] src, int srclen) { } i = i + 1; } + if (stkp != 0) { + exit(1); + } /*i = 0; while (i < srclen) { putint(jm[i]); @@ -72,17 +75,20 @@ func interpret(char[] src, int srclen) { ip = ip + 1; } + // debugger; + + putc('\n'); memp = 0; while (memp < 10) { - putint(int(mem[memp])); putc(' '); + putint(int(mem[memp]) & 0xff); putc(' '); memp = memp + 1; } putc('\n'); } func int main() { - int bufsize := 4088; - char[] source := new char[4088]; + int bufsize := 12280; + char[] source := new char[12280]; int sourcelen := 0; while (1) { -- cgit v1.2.3-70-g09d2