Is there any way I can execute a block of code in a loop, like so:
[ some code goes here ]
Where the delimiters are "[" and "]", and also allowing for nested blocks, i.e.:
[the user can create another loop]
I am creating a parser for a language that implements such semantics, and it reads the code one byte/character at a time since the commands are all single characters and because the syntax is supposed to be very minimal (which is fairly important), and I am currently stuck in this loop thing.
I have tried matching the byte (since I am only reading 1 character at a time) with a "[" character and then setting a global variable across the instance, but this seems to break when the statements are nested, and doesn't seem to work.
Any help (in Python, possibly) is appreciated!
EDIT: Conforming to what @mattnz commented, the question & post has been further clarified.