Recursion tends to be a much easier approach to parsing than iteration. An informal pseudo-code grammar might be:
word character: any character matching /[A-Za-z]/ sequence: starts with '\', then one or more word characters section: one or more sequences, or something that starts with '{', then a section, then '}'
Note the "then a section" part of 'section' is recursive. This allows sections to be embedded inside other sections. The above is quite a bit wordier than a formal grammar defintion would be (as pseduo-code often is), but should be more understandable if you haven't played with context-free grammars before.
"There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.
In reply to Re: Basics of parsing (using RTF as a testbed)
by hardburn
in thread Basics of parsing (using RTF as a testbed)
by Mugatu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |