Repository navigation
Conversation
|
Besides a more exhaustive check of the errors, this probably also needs a read through the rustdoc output. At a first glance, a lot of the codegen docs are in fact missing. |
|
So I think that is a initial pass over everything, I'll probably leave it draft for a day or two and mull over whether or not I might have forgotten anything and if nothing comes up mark it ready for review. |
|
One thing I haven't fully thought through: because this exposes a lot of previously-internal APIs, I wonder if we might want to document this API as being partly unstable? Some parts seem rock solid to me, and others I haven't really thought about if I'm honest! It might be that the whole kaboodle is good as-is: I'm happy to hear your thoughts! |
|
I don't really have a problem doing that, I recall we actually have features for that. It would mean that nimbleparse has to enable that feature, which seems fine (since it is a binary). My feeling would be that it would be good to make a stabilization issue, and put it in a comment, I think the place i'm least happy with the API is around the error handling, |
|
I think it might require some acrobatics to continue using the API from lrpar/lrlex without enabling the Is that the kind of thing you were thinking about, or something more informal? |
I haven't thought it through very carefully! FWIW I don't have a problem with the grmtools crates using an unstable API between themselves while we wait to see how it goes. If you think that might be a good compromise, it would work for me, but you're deeper into the details here than I am! |
|
I'll do some playing around with using the |
|
Thanks! |
|
I think this one is squashable and mergeable? |
| /// This value should only be used within grmtools. | ||
| /// External users should *always* use the `unstable_api::UnstableApi` value. | ||
| #[doc(hidden)] | ||
| pub const HIDDEN_UNSTABLE_API: crate::unstable::UnstableApi = crate::unstable::UnstableApi; |
There was a problem hiding this comment.
This const value, and type alias should be removed to keep it in line with the unstable module of other crates. This was kind of an experiment that didn't work out, but didn't get removed from lrlex.
This marks `Value`, `HeaderError`, and `HeaderErrorKind` in the header module as unstable API.
|
Besides that one little bit of accidental code that needed to be removed, I had to With that I squashed it down into a few sensible commits, and marked it ready for review. |
|
I guess, I did want to ask, let me just quote your previous message
I'm curious which parts you've thought less about vs the parts you thought seemed rock solid. I guess my list of things that give me some hesitation with this api is mostly just the error types.
The second is that the error cannot be checked until you've produced the AST, but by that point you can waltz off with the AST into the sunset. I'm not super worried about this second, as this probably is never going to be a commonly used end-user API. So it seems like enough to know you should call |
I guess the only way to solve this would be to rethink the API a bit. IIRC the problem in a sense is that |
Yep, exactly like what I think one way we might approach fixing it is that we remove the ability to get an So that might ensure that these errors are checked before people can run off with the ast. |
|
I played around with the above, and did get it working, besides moving the |
Previously you could get an `ASTWithValidityInfo` before calling `ParserBuildEnv::code_generator` where errors in the `ast.grmtools_section` were checked. This patch delays the ability to obtain an `ASTWithValidityInfo` until later. Add a `warnings()` method to `ParserBuildEnv` that returns the ast's warnings, so that you can still handle warnings alongside errors.
|
I went ahead and pushed that as 0fea24b so you could take a look. |
| let mut unrecognized_keys = Vec::new(); | ||
| unrecognized_keys.extend( | ||
| self.ast_with_validity_info() | ||
| self.ast_with_validity_info |
There was a problem hiding this comment.
An alternate (perhaps better) fix might be to move this check so it happens earlier.
It looks like the place to do that would be in ParserSrcEnv::build_env().
Then we could leave ParserBuildEnv::ast_with_validity_info() as it was.
There was a problem hiding this comment.
In d5d4b6f I went ahead and moved this error check so it happens earlier and reverted some of the patch that moved the AST getter to happen late.
In doing so I noticed one spot we were printing errors without spans, so I added that case to the match.
| } | ||
| Box::<dyn Error>::from(ErrorString(out)) | ||
| } | ||
| ref e @ ParserSrcEnvError::GrmtoolsSectionUnusedKeys(ref errs) => { |
There was a problem hiding this comment.
It would be nice if we could collapse these 3 match case branches for error printing down to two cases, one for spanned errors, and one for non-spanned errors.
- This error doesn't currently implement the
Spannedtrait - We'd need
ParserSrcEnvErrorto have something that returnssomething like animpl Into<Option<dyn Spanned>> for ParserSrcEnvErrorimpl Iterator<Item=dyn Spanned + Error>
That might be best left for a future cleanup?
There was a problem hiding this comment.
Agreed that sounds like a good cleanup, and we can do it in a followup.
This is a first attempt at my remaining todo list.
It tries to make codegen pub, and remove the usage of hidden API in nimbleparse.
It does so by usage of the codegen process and selectively unhiding some API we've worked towards making nicer over this development cycle (the
header::Valuestructure and header errors).The actual errors that are going to be emitted here will very likely need some work,
But I did do a basic smoke test run of nimbleparse with some erroneous input.
The usage of codegen might seem weird, nimbleparse doesn't actually generating any code...
We kind of use it as a "PreBuilder" for RTParserBuilder which does a couple of things
%grmtools{yacckind: ...}by parsing the%grmtoolssection.As an example of step 3, we can add an invalid key to one of the examples
$ cargo run --bin nimbleparse -- ./lrpar/examples/calc_parsetree/src/calc.{l,y}I had hoped to before making this stuff
pub, get a version of nimbleparse_lsp ready to test with.But that was before I had noticed the hidden API usage in nimbleparse. In this regard, there isn't
much that could go wrong in nimbleparse_lsp that wouldn't also run afoul of nimbleparse itself.
I would say that the
codegenerror handling is not totally pretty here.I should probably go through
CTParserBuilderand double check it's error handling,to see if I missed any nicer mechanisms. Despite that, it does seem to come out as a net negative lines of code (prior to adding documentation) 👏