instaparse

If you're not trampolining your parser, why bother getting up in the morning?
matan 2017-07-05T09:44:25.080389Z

With instaparse, how do you elegantly match any sequence of characters up until a specific sequence of characters?

matan 2017-07-05T09:54:34.292535Z

Currently I do that in a cumbersome way, given the impedence mismatch between grammars and regular expressions:

WrappedLabel = UnderscorePair Word UnderscorePair
UnderscorePair = "__"
Word = #".+(?=__)" (* a valid word is hereby contrained to anything that does not include an UnderScorePair *)

matan 2017-07-05T09:55:08.304396Z

__ appears both as a grammar definition (`UnderscorePair`) as well as serving as a stop expression in the regex

matan 2017-07-05T09:56:02.323420Z

:thinking_face: I am curious in case there's a solution I've not thought of

matan 2017-07-05T09:57:06.345877Z

The above is supposed to catch and parse anything of the form __foo__, so that foo can be extracted (as part of a larger parse the details of which are quite plain and uninteresting)

aengelberg 2017-07-05T16:13:31.388843Z

@matan that's how I would do it. I'm not aware of a more elegant or efficient solution, besides making the underscore pairs part of the regex.