From 1461e19c06a75660cbd2e8891713a3f7879fdfd6 Mon Sep 17 00:00:00 2001 From: Pavel Kirilin <win10@list.ru> Date: Sun, 14 Jun 2020 23:30:17 +0400 Subject: [PATCH] Fixed Loop logic, added examples. Signed-off-by: Pavel Kirilin <win10@list.ru> --- examples/99bottles.bf | 21 ++++++ examples/mandelbrot.b | 145 ++++++++++++++++++++++++++++++++++++++++++ examples/quine.bf | 43 +++++++++++++ src/REPL.hs | 5 +- test.bf | 7 -- 5 files changed, 213 insertions(+), 8 deletions(-) create mode 100644 examples/99bottles.bf create mode 100644 examples/mandelbrot.b create mode 100644 examples/quine.bf delete mode 100644 test.bf diff --git a/examples/99bottles.bf b/examples/99bottles.bf new file mode 100644 index 0000000..93cff7b --- /dev/null +++ b/examples/99bottles.bf @@ -0,0 +1,21 @@ +.++>+>++>>+>>>++++++++++[->+>+>++++++++++<<<]>>>>++++++++++[->+++++>++++++++++>+ +++++++++++>++++++++>++++++++>+++>++++>+<<<<<<<<]+>->+++>++++++>->+++++>+++>+++++ +>+>+>+>+>++>+>+>++[-<]<<<<<<<[->>[>>>>>>>>[<<<<<<<[->[-]>>>>>>>>>>>.<----.>>>.<< +<--.++.+++.+<-.+<<+<<<<<<<<]+>[-<[-]>>>>>[>>>+<<<<+<+<+>>>-]<<<[->>>+<<<]>[>>>>> +>+<<<<<<-]>>>>>[[-]>.<]<<<<[>>>>>-<<<<<-]>>[<<+<+<+>>>>-]<<<<[->>>>+<<<<]>[>>>>> +>+<<<<<<-]>>>>>>.<<<<<[>>>>>-<<<<<-]>>>[-<<<+<+>>>>]<<<<[->>>>+<<<<]>-[[-]>>>>+< +<<<]<<<]+>>>>>>>>>>>>>.<<<<----.>----.+++++..-<++++++++++.-------.<<[[-]>>>.<<<] +>>>>>>.<<<----.<+.>>>>.<<<<----.+++..+>+++.+[>]+>+>[->+<<-<-<<<.<<<----.-.>>>.<< +<++++++.<++.---.>>>>.<<<+++.<----.+++++++++++..------>---->--------------------- +----------->>>++.-->..>>>]>>>[->[-]<<<<<<<[<]<[-]>>[>]>>>>>]+>[-<[-]<<<<[->>[->+ +<<<<-<<<.<<<----.-.>>>.<<<++++++.<++.---.>>>>.<<<+++.<----.+++++++++++..------>- +--->++++++++++++++++++++++++++++++++>>>.<.>>>>>>]<<]<[->>>>[-<<+<<<<++.-->.[<]<< +<<<<<<[->[-]<]+>[-<[-]>>>>>>>>>>>>>.<<<-----.++++++++++.------.>>>>.<<<----.-.<. +>>>>.<<<<-.>+.++++++++.---------.>>>.<<<<---.>.<+++.>>>>.<<<++.<---.>+++..>>>.<< +<<++++++++.>+.>>>.<<<<--------.>--.---.++++++.-------.<+++.++>+++++>>>>.<.[<]<<< +<<<<]+>>>>>>-<<<+>>[<<[-]<+<+>>>>-]<<<<[>-<[-]]>[->>>+<<<]>[->->+++++++++<<]>>>> +>[>]>>>>]<<<<]>>>>>>]+<<<<<<<[<]<]+<+<<<<<<+<-]>>>>>>>>>>[>]>>>>>[->[-]<]+>[-<[- +]<<<<<<<<<-------------.<<----.>>>.<<<+++++.-----.>>>.<<<+++++.<++.---.>>>>.<<<- +.+.-----.+++.<.>>>>.<<<<----.>----.<+++.>>>>.<<<<--.>+++++++.++++.>>>.<<<------. +----.--.<+++.>>>>.<<<.++.+++.+<.+>>>>>.<.>>>>>>>>>]+<[-]+<[-]<[-]<[-]+<<<[<]<[-] +<[-]<[-]<[-]++++++++++[->+>+>++++++++++<<<]>->->-<<<<<<[-]+<[-]<+<<] \ No newline at end of file diff --git a/examples/mandelbrot.b b/examples/mandelbrot.b new file mode 100644 index 0000000..5e253e1 --- /dev/null +++ b/examples/mandelbrot.b @@ -0,0 +1,145 @@ + A mandelbrot set fractal viewer in brainf*** written by Erik Bosman ++++++++++++++[->++>>>+++++>++>+<<<<<<]>>>>>++++++>--->>>>>>>>>>+++++++++++++++[[ +>>>>>>>>>]+[<<<<<<<<<]>>>>>>>>>-]+[>>>>>>>>[-]>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>[-]+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>>[->>+<<]<<<<<<<<<<<<<<<]>>>>>>>>>[>>>>>>>>>]<<<<<<<<<[>[-]<- +>>>>>>>>[-<<<<<<<<+>[<->-<<+>>]<[->+<]>>>>>>>>]<<<<<<<[->>>>>>>+<<<<<<<]<+<<<<<< +<<<]>>>>>>>>-<<<<<[-]+<<<]+>>>>>>>>[-<<<<<<<<->>>>>>>>]+<<<<<<<<[->>>>>>>>->[>>> +>>>[->>+<<]>>>]<<<<<<<<<[>[-]<->>>>>>>>[-<<<<<<<<+>[<->-<<+>>]<[->+<]>>>>>>>>]<< +<<<<<[->>>>>>>+<<<<<<<]<+<<<<<<<<<]>+++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>> ++>>>>>>>>>>>>>>>>>>>>>>>>>>>+<<<<<<[<<<<<<<<<]>>>>>>>>>[>>>>>>[-<<<<<<->>>>>>]+< +<<<<<[->>>>>>->>[-<<<<<<<<+>>>>>>>>]<<<<<<<<[->>>>>>>>+<<<<<<<<<<<<<<<<<[<<<<<<< +<<]>>>>[-]+>>>>>[>>>>>>>>>]>+<]]+>>>>>>>>[-<<<<<<<<->>>>>>>>]+<<<<<<<<[->>>>>>>> +-<<[-<<<<<<+>>>>>>]<<<<<<[->>>>>>+<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[-]+>>>>>>[>>>>>> +>>>]>[-]+<]]+>[-<[>>>>>>>>>]<<<<<<<<]>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>[-]<<<++++ ++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>->>>>>>>>>>>>>>>>>>>>>>>>>>>-<<<<<<[<<<< +<<<<<]]>>>] diff --git a/examples/quine.bf b/examples/quine.bf new file mode 100644 index 0000000..2cb3f4c --- /dev/null +++ b/examples/quine.bf @@ -0,0 +1,43 @@ +>>>>>+++++>+++++>+++++>+++++>+++++>>++++++>++++>+++++++>++++>++++++>++++> ++++++++>++++>++++++>++++>+++++++>+++++>++++++>++++>++++++>++>+++++++>+>+>+>+>+> ++>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+ +>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+++++>++++++>++++>++>++>++>++>++>++>++>++>++>++> +++>++>++>++>++>++>++>+++++>++++>++++>+>+++++>+++++>++>++++++>++++>+>+>+++++>+++ ++>++++>+>+++++>+++++>++>++++++>++++>+>+++++>++++>++++>+>+++++>+++++>++>++++++>+ ++++>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+++++>++++>++++>+>+++++>+++++>++>++++++>++++>+> ++>+++++>++++>++++>+>+++++>+++++>++>++++++>++++>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+> ++>+>+>+>+>+>+>+>+>+>+>+>+>+++++>++++>++++>+>+++++>+++++>++>++++++>++++>+>+>++++ ++>++++>++++>+>+++++>+++++>++>++++++>++>+++++++>+++++++>+++++++>+++++++>+++++++> ++++++++>+++++++>+++++++>++++>+++>++++++>++>+++++++>+++++>+++++>+++++++>++++>+++ ++>++++>++++++>++++>+++++++>+++++>++++++>++++++>++++>++++>+>+++++>+++++>++++>+++ ++++>++>+++++++>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+> ++>+>+>+>+>+>+>+>+>+>+>+++>++++++>++>+++++++>+++++>++>+++++++>++++++>++>+++++++> ++>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+ +>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+++>++++++>++>+++++++>+++++>++++++ ++>++++++>++>+++++++>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+ +>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+++>++++++>++> ++++++++>+++++>+++++>+++++>++++++>++++++>++++>++++>+>+++++>+++++>++++>++++++>++> ++++++++>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+ +>+>+>+>+>+>+>+>+++>++++++>++>+++++++>+++++>++>+++++++>++++++>++>+++++++>+>+>+>+ +>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+> ++>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+++>++++++>++>+++++++>+++++>+++++++>++++> +++++>++++>++++++>++++>+++++++>+++++>++++++>++++>++++++>++>+++++++>+>+>+>+>+>+>+ +>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+> ++>+>+>+>+>+>+>+>+>+>+>+>+>+>+++++>++++++>++++>++>++>++>++>++>++>++>++>++>++>++> +++>++>++>++>++>++>+++++>++++>++++>+>+++++>+++++>++>++++++>++++>+>+>+++++>++++>+ ++++>+>+++++>+++++>++>++++++>++++>+>+++++>++++>++++>+>+++++>+++++>++>++++++>++++ +>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+++++>++++>++++>+>+++++>+++++>++>++++++>++++>+>+>+ +++++>++++>++++>+>+++++>+++++>++>++++++>++++>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+ +>+>+>+>+>+>+>+>+>+>+>+>+++++>++++>++++>+>+++++>+++++>++>++++++>++++>+>+>+++++>+ ++++>++++>+>+++++>+++++>++>++++++>++>+++++++>+++++++>+++++++>+++++++>+++++++>+++ +++++>+++++++>+++++++>++++>+++>++++++>++>+++++++>+++++>+++++>+++++++>[<]<[<]<[<]>[< +[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[<-----------------><<+> +>-[<++><<+>>-[<+><<+>>-[<++++++++++++++><<+>>-[<++><<+>>-[<++++++++++++++++++++++++ ++++++><<+>>-[<++><<+>>-[-]]]]]]]]<.[-]>>]<<<[<]>[[<<+>><[-]+++++++++++++++++++++++++++++++ +++++++++++++.[-]>-][-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++.[-]>][-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]>>>[[<<+> +><[-]+++++++++++++++++++++++++++++++++++++++++++.[-]>-][-]++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++.[-]>]<<<[<]>[<[-]++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++>[<-----------------><<+>>-[<++><<+>>-[<+><<+>>-[<++++++++++ +++++><<+>>-[<++><<+>>-[<++++++++++++++++++ ++++++++++++><<+>>-[<++><<+>>-[-]]]]]]]]<.[-]>>] \ No newline at end of file diff --git a/src/REPL.hs b/src/REPL.hs index d863730..bc9a3a2 100644 --- a/src/REPL.hs +++ b/src/REPL.hs @@ -147,7 +147,10 @@ readCell = do runBrainCodeLoop :: BrainBreakBlock -> StateT REPLState IO () runBrainCodeLoop code = do - runBrainBreakCode code + cell <- getCell + case cell of + 0 -> return () + val -> runBrainBreakCode code cell <- getCell case cell of 0 -> return () diff --git a/test.bf b/test.bf deleted file mode 100644 index 7c7ddff..0000000 --- a/test.bf +++ /dev/null @@ -1,7 +0,0 @@ -++++++++++[ - >+++++++>++++++++++>+++>+<<<<- - ] - >++.>+.+++++++.. - +++.>++.<<+++++++++++++++. - >.+++ -.------.--------.>+.>. \ No newline at end of file -- GitLab