-
Notifications
You must be signed in to change notification settings - Fork 200
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 for an array of token types in longer_alt
property
#1602
Comments
Hello @msujew
Yes, it seems like a good upgrade. Note the lexer runtime code is super optimized for performance (and thus "ugly"). But I think the performance implications of this feature would not be severe as Comparing dev vs latest release performance can be done using this benchmark: The array of token types capability should also be mentioned in these docs |
Yeah, I already looked into what needs to be changed previously. I'm used to writing ugly code though ;) Thanks for setting me up with the required processes (especially the performance benchmark). Expect a PR from me within the next days. |
Thanks @msujew I will review it sometime this week. |
release in 9.1.0 |
Currently,
longer_alt
on token types only accepts a single other token type. However, let's say we have a division token like/
in our grammar and single tokens for multiline and singleline comments, starting with/*
and//
respectively. This is common for every language that derives its syntax from C. Usinglonger_alt
in the/
token type currently allows us to select only one of the comment token types.Of course, we could try to merge their definitions, thereby losing some important information. For example, in Langium, we plan to implement the LSP hover API by looking at the last multiline comment that directly precedes the AST element in question. Doing this generically requires us to rely on the token type name. However, this behavior breaks as soon as we have to merge the token type definitions. That outlines my use case for an array of token types in the
longer_alt
property.This improvement should be non-breaking, as the API only has to be extended to look like
longer_alt: TokenType | TokenType[]
. Are you interested in seeing this change? I would gladly contribute a PR.The text was updated successfully, but these errors were encountered: