The impending libregex will implement GNU extensions to bring BREs and
EREs closer together. Prepare for this and reduce the diff of libregex changes by
refactoring and combining the top-level parsers for EREs/BREs ahead of time.
Branching functionality has been split out to make it easier to follow the combined
version of the top-level parser. It may also be enabled in the parsing context to make
it easier when libregex enables branching for BREs.
A branching context was also added for the various branching functions and so that
BREs, for instance, can determine if they're the first expression in a chain of expressions
within the current branch and treat '*' as ordinary if so.
This should have no functional impact and negligible performance impact.
As an aside, I'm not against moving the pre- and post- parse logic in the top-level
parser (if (p->bre && EAT('^')) { ... } and if (p->bre && wasdollar) { ... }
out into their own functions, setting them as function pointers of the struct parse
in the caller of the top-level parser if (p->bre), and then just calling them
in the appropriate places if they're set. I just did not do this here because it
seemed like perhaps a step too far.