-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: lookahead (?=) (?!) #11
Comments
I'm going to build this. I hadn't looked at the code in long enough that I forgot how some of it works. I took it as an opportunity to improve the docs a bit as I rediscovered where I put the important logic. I'm confident once again that I know how to do what this issue describes, and I'll do it just as soon as the macrome generated artifacts are stable again (shifted from timestamps to hashes) |
This will be significantly simpler once #35 lands I think. |
I'm ready to implement this, and I'm less likely to mess it up since I just spent so much time rewriting and debugging the engine. |
The architectural question is how to look at expressions when succeeding or failing. Currently success and failure are the responsibility of sequences, and expressions are assumed to be safe to prune when they no longer are needed to hold a list. Currently there are two places in the code that are relevant. Line 122 in 58a456b
A succeeding sequence is promoted, which may allow it to eliminate expressions: Lines 273 to 287 in 58a456b
|
The question will be, do I want a recursive solution, which would allow me to program the behavior as a a method overload, or should I try to avoid recursion, as I am unsure how deep the state tree may be? A middle ground may be for a lookahead to be a subclass of match, say |
If I do use a |
I've been assuming I need engine-level support for this, but is that really true? It's not too hard to create an |
if I make implement a |
I'll have a |
A failure of the |
I think I want a |
It's time! I need this feature myself, and am building it. |
Current problem: captures. First, I don't really remember entirely how what I built works, and I'm not 100% sure it's right. Second: lookahead has some really weird cases. Evaluating something like |
For an execution like |
I think I've duplicated part of the engine's data structure in the stack-of-lists data structure I use for captures. |
OK, that's fixed. Captures themselves no longer contain |
Support lookahead assertions. Given a
lookahead
expression and acontingent
sequence, here's what has to happen:Make a lookahead state at the engine level. It will essentially be a normal expression state of
[lookahead, contingent]
with a bit of special sauce in handling success and failure.lookahead
succeeds it must fail thelookahead
expression, causingcontingent
to become the best alternativelookahead
fails the entire lookahead state must fail.The text was updated successfully, but these errors were encountered: