A Working Mathematician’s Guide to Parsing
jeremykun.com
jeremykun.com
Unless our hero mathematician is writing, like, several blog posts a day, using tools like parser generators and writing your grammar in BNF and the like is WAY overkill. Just use search/replace and manually fix it up. Or, like, maybe some kind of editor macro/multiple cursor nonsense in your fully-featured text editor. If she really wants to go nuts, she should write a four-line python script to do the search/replace a tiny bit smarter. Fixing it up with some manual oversight takes like three minutes per blog post at most, it's not worth trying to automate fully.
This is one of them "killing an ant with a nuclear bomb" situations.
> because the parser generator knows about all patterns you want to match in advance, it will match longer terminals before shorter—more ambiguous—terminals
If you don't mind manually ordering your choices in your alt operators, then PEG and parser combinators are OK.
Oh, and you often need to restructure your grammar to avoid left recursion.