bf_debug_0.2 looping error
Status: Alpha
Brought to you by:
teancum
Say I have a program such as
",1[2[->+>+<<]>>3[-<<+>>]<<4].>."
Note that there are more than one set of loop brackets
inside the main set. When I execute the program (in
debug mode, to do tracing), it enters the main loop ,
goes through both internal loops fine. But when it
reaches the end bracket (#4) it goes back to #3,
probably because it was the last '[' bracker.
Logged In: NO
The loop code is symmetrical, and from the looks of it, it
will produce the same error either direction. One simple
test program would be:
[ [ ] +++++++++++++++++++++++++++++++++++.....[-]]
which should skip from the first bracket straight to the
last and terminate without doing anything, but instead (I
think--I don't have a Windows machine to test it on) will
jump to the inner ] and print five #s.
Another thing: matching loops at runtime is a giant time
hog. They should be matched at the start, and unmatched [ or
] should be reported as a syntax error.
(As best I can tell, this loop code also jumps TO the
matching bracket, not to the instruction after the matching
bracket--but that's not a giant time hog, just a little time
hog. Easily fixed, anyway.)
Again, I suggest that all brainfuck implementors read my
compilation of issues to watch out for, available along with
other brainfuck stuff at
http://www.hevanet.com/cristofd/brainfuck/
Several of them appear to be relevant to this project.
-Daniel Cristofani.
cristofd@hevanet.com
(One more related question. Why do AdvanceInstructionPointer
and ReverseInstructionPointer wrap around? And they have
slightly different ranges; Advance should use >= and not >
if the two procedures are to be inverses of each other.)