Creating a Brainfuck parser, whats the best method of parsing loop operators?
I'm creating a Brainfuck parser (in a BASIC dialect) ultimately to create an interpreter but i've realise it's not as straight forward as i first thought. My problem is that i need a way to accurately parse the matching loop operators within a Brainfuck program. This is an example program: ,>,>++++++++[<------<------>>-] <<[>[>+>+<<-]>>[<<+>>-]<<<-] >>>++++++[<++++++++>-],<.>. '[' = start of loop ']' = end of loop I need to record the start and end point of each matching loop operator so i can jump around the source as needed. Some loops are alone, some are nested. What would be the best way