is the right one (for the if/then/else problem) - but effectively I realized that the hidden problem on my side was (is) my limited knowledge and experience on recursion (which is the true explanation for the hack I was thinking about).
So I need a deep dive there (did the first one already today).
The approach I am taking now is the following (exemplary for a simplified markup language):
* sections indicated by "="s at the front and the end
* templates indicated by double curly braces "{{" "}}"
* some other grammar classes indicated by ... to dig out content
class Template(Grammar):
grammar = ("{{", REF(Template_Recursion), "}}")
class Template_Recursion(Grammar):
grammar = ( ... | ... | Templates)
class Section(Grammar):
grammar = ( "=", REF(Section_Recursion), "=")
class Section_Recursion(Grammar):
grammar = ( ... | ... | Section)
class ML(Grammar):
grammar = (Template_Recursion | Section_Recursion)
;) Sounds like a plan - to me this looks kind of beautiful.
This solves the "local" problem in my view. The "global" problem (ML will stop after one iteration) I haven't decided yet. A simple REPEAT(ML) grammar could solve it - however with a quite large markup language definition I fear a bit the devil in the detail (e.g. infinite loops due to small language errors in the content of the wiki or small errors in my grammar definitions).
;) I might come back with questions on ParseError
Any comments welcome - but I think I am back on the right track. In case of interest I can share my experience (might take a bit).
Thanks for modgrammar! It is a great tool. It simply "feels" right.
Best Regards
Kai