as I know, “push” and “pop” are assembler-commands.
To solve this problem I recommend recursion.
I don’t know if you know what this is, so I’ll explain it shortly:
Recursion is when a function calls itself. So for each call in a call the local variables of the function are pushed on the stack. When the function ends, the variables are removed from the stack.
So you could write a function which is called when the beginning-tag starts. And for each further beginning-tag it calls itself.
In c you will need the string-functions in