commit 1d17a5014c2bde5c7c11b1d422af3a6de292d0bc
parent b1587c90282e26b8c82986d227987177feeb4c16
Author: Walther Chen <walther.chen@gmail.com>
Date:   Sun,  6 Nov 2022 21:35:07 -0500

add test fixtures mandelbrot and factor

Diffstat:
MREADME.md | 2++
Afixtures/factor.bf | 199+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Afixtures/mandelbrot.bf | 149+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/main.zig | 4+---
4 files changed, 351 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md @@ -3,3 +3,5 @@ bf interpreter. following: https://eli.thegreenplace.net/2017/adventures-in-jit-compilation-part-1-an-interpreter/ using: zig nightly (0.11.0-dev.48+678f3f6e6) + +Note: to run `fixtures/factor.zig`, overflow must be allowed. So -Drelease-fast removes the check. diff --git a/fixtures/factor.bf b/fixtures/factor.bf @@ -0,0 +1,199 @@ +[ + Takes an integer from stdin and emits its factors to stdout + + Factor an arbitrarily large positive integer + + Copyright (C) 1999 by Brian Raiter + under the GNU General Public License +] + +>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>- + +* +* read in the number +* + +<<<<<<<<<+ +[-[>>>>>>>>>>][-]<<<<<<<<<<[[->>>>>>>>>>+<<<<<<<<<<]<<<<<<<<<<] + >>>>>>>>>>,----------] +>>>>>>>>>>[------------------------------------->>>>>>>>>->] +<[+>[>>>>>>>>>+>]<-<<<<<<<<<<]- + +* +* display the number and initialize the loop variable to two +* + +[>++++++++++++++++++++++++++++++++++++++++++++++++. + ------------------------------------------------<<<<<<<<<<<] +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++. +--------------------------.[-] +>>>>>>>>>>>>++<<<<+ + +* +* the main loop +* + +[ [-]>> + + * + * make copies of the number and the loop variable + * + + [>>>>[-]>[-]>[-]>[-] + >[-]>[-] + <<<<<<<[->>>+>+<<<<]>>>>>>>>] + <<<<<<<<<<[>>>>>>[-<<<<+>>>>]<<<<<<<<<<<<<<<<]>>>>>>>>>> + [>[->>>+>>+<<<<<]>>>>>>>>>] + <<<<<<<<<<[>>>>>>[-<<<<<+>>>>>]<<<<<<<<<<<<<<<<]>>>>>>>>>> + + * + * divide the number by the loop variable + * + + [>>>[-]>>>[-]>[-]>>>] initialize + <<<<<<<<<<[<<<<<<<<<<] + >>>>>>>>>[-]>>>>>>>+<<<<<<<<[+]+ + [ ->> double divisor until above dividend + [>>>>>>[->++<]>>>>]<<<<<<<<<< + [>>>>>>>>[-]>[-] + <<<<[->>>++<<<]<<<<<<<<<<<<<<<]>>>>>>>>>> + [>>>>>>>>[->+<[->+<[->+<[->+<[->+<[->+<[->+<[->+<[->+< + [->--------->>>>>>>>>+<<<<<<<<<<[->+<]]]]]]]]]]]>>] + <<<<<<<<<<[>>>>>>>>>[-<+<<<+>>>>]<<<<<<<<<<<<<<<<<<<]>>>>>>>>>> + [>>>>>>>[-<+>[-<+>[-<+>[-<+>[-<+>[-<+>[-<+>[-<+>[-<+> + [-<--------->>>>>>>>>>>+<<<<<<<<<<[-<+>]]]]]]]]]]]>>>] + <<<<<<<<<< + [>>>>[->>>+>>+<<<<<]<<<<<<<<<<<<<<] + >>>>>>>>>>[>>>>>>>[-<<<+>>>]>>>]<<<<<<<<<< + [>>>>>>>>[->-<]> + [<<<<<<<<<[<[-]>>>>>>>>>>[-<<<<<<<<<<+>>>>>>>>>>]<<<<<<<<<<<<<<<<<<<] + >>>>>>>>>>>>>>>>>>>] + <<<<<<<<<<<<<<<<<<<] + >>>>>>>>>[+[+[+[+[+[+[+[+[+[+[[-]<+>]]]]]]]]]]]< + ] + >>>>>>>> + [ subtract divisor from dividend + <<<<<< + [>>>>>>>>[-]>[-]<<<<<[->>>+>+<<<<]>>>>>>]<<<<<<<<<< + [>>>>>>>>[-<<<<+>>>>]<<<[->>>+>+<<<<]<<<<<<<<<<<<<<<]>>>>>>>>>> + [>>>>>>>>>[-<<<<+>>>>]>]<<<<<<<<<< + [>>>>>>>>[-<->]<<<<<<<<<<<<<<<<<<]>>>>>>>>>> + [>>>>>>>[->+<[->+<[->+<[->+<[->+<[->+<[->+<[->+<[->+<[->+< + [++++++++++[+>-<]>>>>>>>>>>-<<<<<<<<<<]]]]]]]]]]]>>>] + >>>>>>>+ + [ if difference is nonnegative then + [-]<<<<<<<<<<<<<<<<< replace dividend and increment quotient + [>>>>[-]>>>>[-<<<<+>>>>]<<[->>+<<]<<<<<<<<<<<<<<<<]>>>>>>>>>> + [>>>>>>>>[->+<<<+>>]>>]<<<<<<<<<< + [>>>[->>>>>>+<<<<<<]<<<<<<<<<<<<<]>>>>>>>>>> + [>>>>>>>>>[-<<<<<<+>>>>>>[-<<<<<<+>>>>>> + [-<<<<<<+>>>>>>[-<<<<<<+>>>>>> + [-<<<<<<+>>>>>>[-<<<<<<+>>>>>> + [-<<<<<<+>>>>>>[-<<<<<<+>>>>>> + [-<<<<<<+>>>>>>[-<<<<<<--------->>>>>>>>>>>>>>>>+<<<<<<<<<< + [-<<<<<<+>>>>>>]]]]]]]]]]]>] + >>>>>>> + ] halve divisor and loop until zero + <<<<<<<<<<<<<<<<<[<<<<<<<<<<]>>>>>>>>>> + [>>>>>>>>[-]<<[->+<]<[->>>+<<<]>>>>>]<<<<<<<<<< + [+>>>>>>>[-<<<<<<<+>>>>>>>[-<<<<<<<->>>>>>+> + [-<<<<<<<+>>>>>>>[-<<<<<<<->>>>>>+> + [-<<<<<<<+>>>>>>>[-<<<<<<<->>>>>>+> + [-<<<<<<<+>>>>>>>[-<<<<<<<->>>>>>+> + [-<<<<<<<+>>>>>>>]]]]]]]]]<<<<<<< + [->>>>>>>+<<<<<<<]-<<<<<<<<<<] + >>>>>>> + [-<<<<<<<<<<<+>>>>>>>>>>>] + >>>[>>>>>>>[-<<<<<<<<<<<+++++>>>>>>>>>>>]>>>]<<<<<<<<<< + [+>>>>>>>>[-<<<<<<<<+>>>>>>>>[-<<<<<<<<->>>>>+>>> + [-<<<<<<<<+>>>>>>>>[-<<<<<<<<->>>>>+>>> + [-<<<<<<<<+>>>>>>>>[-<<<<<<<<->>>>>+>>> + [-<<<<<<<<+>>>>>>>>[-<<<<<<<<->>>>>+>>> + [-<<<<<<<<+>>>>>>>>]]]]]]]]]<<<<<<<< + [->>>>>>>>+<<<<<<<<]-<<<<<<<<<<] + >>>>>>>>[-<<<<<<<<<<<<<+>>>>>>>>>>>>>]>> + [>>>>>>>>[-<<<<<<<<<<<<<+++++>>>>>>>>>>>>>]>>]<<<<<<<<<< + [<<<<<<<<<<]>>>>>>>>>> + >>>>>> + ] + <<<<<< + + * + * make copies of the loop variable and the quotient + * + + [>>>[->>>>+>+<<<<<]>>>>>>>] + <<<<<<<<<< + [>>>>>>>[-<<<<+>>>>]<<<<<[->>>>>+>>+<<<<<<<]<<<<<<<<<<<<] + >>>>>>>>>>[>>>>>>>[-<<<<<+>>>>>]>>>]<<<<<<<<<< + + * + * break out of the loop if the quotient is larger than the loop variable + * + + [>>>>>>>>>[-<->]< + [<<<<<<<< + [<<[-]>>>>>>>>>>[-<<<<<<<<<<+>>>>>>>>>>]<<<<<<<<<<<<<<<<<<] + >>>>>>>>>>>>>>>>>>]<<<<<<<<<<<<<<<<<<] + >>>>>>>>[>-<[+[+[+[+[+[+[+[+[+[[-]>+<]]]]]]]]]]]>+ + + [ [-] + + * + * partially increment the loop variable + * + + <[-]+>>>>+>>>>>>>>[>>>>>>>>>>]<<<<<<<<<< + + * + * examine the remainder for nonzero digits + * + + [<<<<<<[<<<<[<<<<<<<<<<]>>>>+<<<<<<<<<<]<<<<] + >>>>>>>>>>>>>>>>>>>>[>>>>>>>>>>]<<<<<<<<<<[<<<<<<<<<<] + >>>>- + + [ [+] + + * + * decrement the loop variable and replace the number with the quotient + * + + >>>>>>>>-<<[>[-]>>[-<<+>>]>>>>>>>]<<<<<<<<<< + + * + * display the loop variable + * + + [+>>[>>>>>>>>+>>]<<-<<<<<<<<<<]- + [>>++++++++++++++++++++++++++++++++++++++++++++++++. + ------------------------------------------------<<<<<<<<<<<<] + ++++++++++++++++++++++++++++++++.[-]>>>> + + ] + + * + * normalize the loop variable + * + + >>>>>> + [>>[->>>>>+<<<<<[->>>>>+<<<<< + [->>>>>+<<<<<[->>>>>+<<<<< + [->>>>>+<<<<<[->>>>>+<<<<< + [->>>>>+<<<<<[->>>>>+<<<<< + [->>>>>+<<<<<[->>>>>--------->>>>>+<<<<<<<<<< + [->>>>>+<<<<<]]]]]]]]]]]>>>>>>>>] + <<<<<<<<<<[>>>>>>>[-<<<<<+>>>>>]<<<<<<<<<<<<<<<<<] + >>>>>>>>> + + ]< + +]>> + +* +* display the number and end +* + +[>>>>>>>>>>]<<<<<<<<<<[+>[>>>>>>>>>+>]<-<<<<<<<<<<]- +[>++++++++++++++++++++++++++++++++++++++++++++++++.<<<<<<<<<<<] +++++++++++. diff --git a/fixtures/mandelbrot.bf b/fixtures/mandelbrot.bf @@ -0,0 +1,149 @@ +[ + A mandelbrot set fractal viewer in brainf*** written by Erik Bosman + Taken from https://github.com/pablojorge/brainfuck +] + ++++++++++++++[->++>>>+++++>++>+<<<<<<]>>>>>++++++>--->>>>>>>>>>+++++++++++++++[[ +>>>>>>>>>]+[<<<<<<<<<]>>>>>>>>>-]+[>>>>>>>>[-]>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>[-]+ +<<<<<<<+++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>>+>>>>>>>>>>>>>>>>>>>>>>>>>> +>+<<<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[-]+[>>>>>>[>>>>>>>[-]>>]<<<<<<<<<[<<<<<<<<<]>> +>>>>>[-]+<<<<<<++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>+<<<<<<+++++++[-[->>> +>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>+<<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[[-]>>>>>>[>>>>> +>>[-<<<<<<+>>>>>>]<<<<<<[->>>>>>+<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<<<<<<]>>>>>>>>>]>>>>> ++>>>>>>>>>>>>>>>>>>>>>>>>>>>+<<<<<<[<<<<<<<<<]>>>>>>>>>[>>>>>>[-<<<<<<->>>>>>]+< +<<<<<[->>>>>>->>[-<<<<<<<<+>>>>>>>>]<<<<<<<<[->>>>>>>>+<<<<<<<<<<<<<<<<<[<<<<<<< +<<]>>>>[-]+>>>>>[>>>>>>>>>]>+<]]+>>>>>>>>[-<<<<<<<<->>>>>>>>]+<<<<<<<<[->>>>>>>> +-<<[-<<<<<<+>>>>>>]<<<<<<[->>>>>>+<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[-]+>>>>>>[>>>>>> +>>>]>[-]+<]]+>[-<[>>>>>>>>>]<<<<<<<<]>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>[-]<<<++++ ++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>->>>>>>>>>>>>>>>>>>>>>>>>>>>-<<<<<<[<<<< +<<<<<]]>>>] diff --git a/src/main.zig b/src/main.zig @@ -12,12 +12,10 @@ pub fn main() anyerror!void { var args = std.process.args(); _ = args.skip(); const source_path = args.next() orelse return error.MissingSourcePathArg; - std.debug.print("source path: {s}\n", .{source_path}); const f = try std.fs.cwd().openFile(source_path, .{}); defer f.close(); - const src = try f.readToEndAlloc(alloc, 2048); - std.debug.print("{s}", .{src}); + const src = try f.readToEndAlloc(alloc, 1024 * 20); var stdin = std.io.getStdIn(); var stdout = std.io.getStdOut();