Proposal: Support Custom Token Kinds in lexer_builder!
Problem:
Currently, when defining language-specific constructs like @extern or #include, the resulting tokens are split into multiple TokenKinds such as [At, Keyword("extern")]. However, some users may prefer a single, unique TokenKind for such constructs that isn't treated as an identifier or keyword.
Proposed Solution:
Introduce a way to define custom token kinds directly in the lexer_builder! macro. For example:
lexer_builder!(
/*
Rest of the lexer definition...
*/
Custom {
Extern,
Include
}
)
With this feature, users could define custom TokenKinds like Extern or Include and create their own systems for processing these tokens.
Example:
A user could implement a function that outputs these custom tokens. For instance:
fn macro_start(state: LexerState) -> Option<TokenKind> {
// Logic to recognize and return a custom token
}
This approach would give developers more flexibility in building lexers tailored to their language's unique requirements
Proposal: Support Custom Token Kinds in lexer_builder!
Problem:
Currently, when defining language-specific constructs like
@externor#include, the resulting tokens are split into multiple TokenKinds such as[At, Keyword("extern")]. However, some users may prefer a single, unique TokenKind for such constructs that isn't treated as an identifier or keyword.Proposed Solution:
Introduce a way to define custom token kinds directly in the
lexer_builder!macro. For example:With this feature, users could define custom TokenKinds like Extern or Include and create their own systems for processing these tokens.
Example:
A user could implement a function that outputs these custom tokens. For instance:
This approach would give developers more flexibility in building lexers tailored to their language's unique requirements