-
Notifications
You must be signed in to change notification settings - Fork 21
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
The ++
pattern is too greedy?
#89
Comments
So I would write that as
The current implementation does not backtrack the | or ++ matching based on the continuation. For some of the optimisations I applied, I actually carry the continuation around, so that could be possible to do. There is another similar case:
This matches XYZ or XZ. But
only matches XZ. |
Are these optimisations of the Trieste code, or optimisations written in the client code? |
Trieste code optimisations. Before a pattern like
would result in for dynamic dispatch calls before it tries to see if there is a T(A). By CPS converting the pattern it becomes one, and the continuation is a dynamic dispatch as well. E.g. here we Trieste/include/trieste/rewrite.h Line 957 in 0b2ec3c
This could form the basis for the better backtracking, but would need care given the other optimisations. |
I was expecting the pattern
Any++ * T(Bar)
to match the sequenceFoo Foo Foo Bar
, just as the regular expression.*b
matchesaaab
, but it seems like theAny++
matches all ofFoo Foo Foo Bar
, meaning the whole pattern fails to match (since there is noBar
after that sequence). I don't know if this is by design, nor what the consequences would be of making it more like the kleene star, but I thought I would bring it up for discussion.My use case was for matching a
Y
inside anX
, where the last child ofY
is aZ
(for reasonable values ofX
,Y
, andZ
):If I didn't care about both the
X
and theY
I could just haveT(Z) * End
, but I now it's important that theY
is in anX
and has the children specified. In this particular case I can do(!T(Z))++ * T(Z)
, but in general this might not be satisfactory.The text was updated successfully, but these errors were encountered: