GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
Essentially this optimization will allow for "early exits" in FirstOf rules.
Consider this example
Sequence(A(), B(), C()),
Currently parboiled will try the second alternative in all cases where the first alternative failed.
However, if the first alternative already matched A and B and only failed at C the second alternative would not actually need to be tried since the already matched A B is not a prefix of the second alternative.
This analysis can be done statically after rule tree generation and so called "cut markers" can be introduced at all points, where FirstOf alternatives have matched far enough to become "non-prefixes" of all following alternatives.