-
-
Notifications
You must be signed in to change notification settings - Fork 191
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
Add function to compute lookahead #107
Comments
Are you talking about "positive lookahead" ? Because I was about to file an issue about that, as I'm unsure there is something like that. It would be particularly useful along with "!" (which is starting to actually work with any kind of pattern) type MyTest struct {
SomeCoolRule *SubRule `=!('.' String) @@`
} This would match SubRule but ONLY if SubRule doesn't start with |
This was solely about automatically determining what the required lookahead value for a particular grammar is. What's the use case for this? Participle already performs lookahead automatically, so normally given multiple cases in a disjunction this kind of behaviour will occur automatically. ie. you'd typically have type MyTest struct {
A *string `"." @String`
B *SubRule `| @@`
} |
I can't really think of anything other than readability right now. I'm not even sure I have ever used a look ahead in any of the grammars I've written. |
Am I right, that look ahead value is computed automatically now ? If so, why this disjunction example fails ? input: "one two"
|
It is not computed automatically, this ticket is still open. |
Ok, got it. |
Lookahead only comes into play if a branch fails to match. In your case it
successfully matches the first branch and so accepts it. You'll need to
reorder your branches.
…On Tue, Oct 13, 2020 at 8:28 PM mechaneg ***@***.***> wrote:
Ok, got it.
Anyway, I tried to increase look ahead value during parser initialization
and my previous example still fails.
What's wrong with it?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#107 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAKGJZ3BIYI2YIDBZKKO23SKQMU7ANCNFSM4Q3SBYIQ>
.
|
The addition of |
Repetitions will be unbounded. Everything else should be computable.
The text was updated successfully, but these errors were encountered: