I'm making an application to make writing (PEG) parsers more approachable and user friendly for people without experience. Yes it has been done before but it's a good learning experience for me regarding GUIs.
Part of what makes it approachable would be that the user doesn't need to worry about their grammar having to match the whole text, they should be able to extract meaningful data without all that "boilerplate".
How would one do this? Please see my answer below. Or provide your own.
This stumped me for most of an evening and couldn't find it answered already online so figured I'd share.
MRE of what I have using the parsimonious library. It works because match will match any top level user defined expressions, and there is a fall back that matches anything else, sadly only one character at a time.
And the print out is correct.
I don't find it very elegant to be honest, especially how individual characters are matched for "any" and "root" (I'd much prefer if they were together or omitted completely), but it's the best I could do, if it's of use to anyone that's all that matters!
From the Parsimonious readme there are examples like this.
Which to me suggests there's a way to use this on a larger body of text (that contains text that's neither bold nor italic throughout) that I'm not aware of. Other than using the optional "pos" (position) parameter for parse/match on every position of a document, which also isn't elegant.
I don't see how from the readme, if anyone knows the "proper" way, please share.