Lrlex codegen - #661
Open
ratmice wants to merge 7 commits into
Open
Conversation
ratmice
commented
Aug 19, 2026
| } | ||
| } | ||
|
|
||
| pub(crate) enum LexerBuildEnvError {} |
Collaborator
Author
There was a problem hiding this comment.
I had forgotten to double check this, for some reason I thought a variant had been added to this,
but that was LexerCodegenError.
ratmice
commented
Aug 19, 2026
| ) | ||
| let code_gen = build_env | ||
| .code_generator(self.rule_ids_map, env!("VERGEN_BUILD_TIMESTAMP")) | ||
| .map_err(|e| match e {})?; |
Collaborator
Author
There was a problem hiding this comment.
This wacky map_err/match was necessary at the time because ? couldn't convert the error.
I figured by the time I was done we'd have a variant added. Although I must admit I'm a bit uncertain what the type returned is, I assume it's inferring ! or some such.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is an attempt at lrlex codegen, in the style of the recently added lrpar codegen module.
One thing this doesn't do is change the
CTTokenMapBuilder.This tries to sequence the move over a couple of commits, with the first commit just generating module and ownership structure. With each subsequent commit moving one aspect of code generation, until it's all in the codegen module.
One slightly suprising thing was the placement of lexerdef within the
LexerBuildEnv, because we need it to generate therule_ids_map, with that we can wait to generate theLexerCodegenutil therule_ids_mapis built, and pass it in to thecode_generatorfunction, this is a slight departure from thelrparapi, which merely took atimestamp.Edit: One thing that the additional
rule_ids_mapparameter I immediately notice is that unlikeBuildEnvArgsand other builder patterns, it's hard for us to add add an additional parameter should we need one. I wonder if we should considerLexerCodegenArgs?