-
Notifications
You must be signed in to change notification settings - Fork 106
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
Support binding token literals in rules #322
Labels
Comments
Another option is to use rule arguments: rule tok(expected_kind: TokenKind) -> Token<'input>
= token:[Token{ kind, .. } if kind == expected_kind] { token }
rule foo() -> u32
= t:tok(TokenKind::Blah) { t.line } But sure, I think it would make sense to add an associated type to the |
kevinmehall
added
feature
Something not supported that perhaps should be
requires-breaking-change
labels
Oct 11, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
The tokens I'm using in my grammar include info like text range, line, column, etc. It would be nice if I could match some of these tokens via the literal syntax and bind the resulting token to a variable for use within the rule's action expression.
Something like:
but when I try something like the above I get "cannot find value `t` in this scope".
I can work around this in a couple ways right now:
(the above is what I'm using for now)
or
The text was updated successfully, but these errors were encountered: