Lrpar codegen - #657
Conversation
|
My attempt to avoid conflicts didn't work (We modified lines that are removed too!), But this does run though |
| match syn::parse_str::<proc_macro2::Ident>(mod_name) { | ||
| Ok(s) => s, | ||
| Err(e) => return Err(format!( | ||
| "CTParserBuilder::mod_name(\"{}\") is not a valid rust identifier due to '{}'", |
There was a problem hiding this comment.
So I think ideally we'd be able to retain some mention of CTParserBuilder in this error text, which
in my patch series we've lost, to me it indicates that mod_name might want to be routed through Header, so it can pick up a location of CTParserBuilder or so.
There seem like a number of places in this patch where the origin of some error condition might be improved, but I'm hesitant to try and do too much/everything in this specific series.
There was a problem hiding this comment.
I agree: we don't have to do everything in one go.
|
I suspect it's worth merging |
|
I'm actually not really worried about the rebase, since all the conflicts should be of the form I believe that 5143009 should bring it in line with the current master branch |
|
I think we're probably ready to squash? |
|
I think so, but I wanted to think given all the simplifications we've done, whether we can move back to the more simpler model like we started with with I think it might be feasible now to have the two-phase thing, but I kind of like the I'd like to mull that over a bit, hear what you think first. |
|
Taking a step back is always a good idea if it might help us reach a better decision. I'm a little bit unsure about the best way ahead, as I admit I've slightly muddled myself in the detail. |
|
I think if it's going to work, basically we'd be combining the So, But I think it might allow us to squash those two types together. I believe the main reason I had to separate them is we needed to borrow That said, I do kind of like how this current patch is structured in the sense that building a src env, and a build env, etc seems like a logical sequence. Edit: There is probably a simple way we can test this by making a constructor on |
|
So, I did end up quickly testing that out, and it does work but it didn't really spark joy, mostly because I had forgotten about the It is perhaps one less type we have to make public, but the construction progression doesn't seem to feel nearly as nice. |
|
I tend to agree. |
|
Working on squashing, but it might take me a bit before I can get the history into nice shape. Because in the back and forth some code got moved around that we can clean up... |
7c31849 to
1c50cbf
Compare
|
@ltratt I squashed and moved some commits around to hopefully make it somewhat reasonable. Does that seem okay to you, or keep working on it? |
|
Perfection is for the next life: if we're confident that this moves us in the right direction overall, I'm fine with it! So, ready to merge I think? |
|
I think so, it feels like a step in the right direction and isn't committing us to any API surface yet. |
|
Agreed! |
|
Thanks, I'll start working on a version of the lrlex patches using the same overall structure. |
I think this is probably as reviewable as I'm going to manage to make this large of a patch.
The basic idea behind this patch is to have a kind of "functional pipeline", for doing code generation,
(SrcEnv?, BuildEnvArgs) -> BuildEnv? -> Codegen(SrcEnv, BuildEnv) -> rust_code?A bit of an oversimplification, as there are some other minor details...
BuildEnvArgsis kind of a minimalist equivalent of the current builder, it's just full ofOptionvalues.BuildEnvis full ofderivedvalues, it mostly strips off theOption, but it also contains values likeASTWithValidityInfothat are derived from all the other args.Codegenthen owns theYaccGrammar,StateTableandStateGraphs, which you can take ownership of after generating code.This may not be totally perfect basis for traits and external usage, for example it currently returns
Box<dyn Error>instead of typed errors. But it should be a pretty faithful conversion of the existing process, into a more targeted/self contained module.