-
Notifications
You must be signed in to change notification settings - Fork 28
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
add source to diagnostics #204
Conversation
✅ Deploy Preview for dada-lang ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
@vemoo -- I'm not sure how this helps, can you explain a bit more? (Also, it needs a rebase, if nothing else, sorry about that...) |
To verify the tree-sitter grammar I added this: https://github.com/vemoo/dada/blob/af9cdc0c61cb6de421c733fd73fa167ed6ac716b/components/dada-lang/src/test_harness.rs#L179-L199 But I don't think the grammar should catch validation errors, so we need to know which ones are from lexing or parsing. I see that brson here: https://github.com/brson/dada/blob/e2861cc6b0c00af2a4e52aa7d6ad93813ad58818/components/dada-lang/src/test_harness.rs#L519-L549 is comparing against the expected diagnostics. So maybe another option is to juste add something like |
12effb4
to
aba8ec9
Compare
Ah, I see. So the idea is that we (internally) track the phase of the compiler the error comes from, for the purpose of our testing harness? In particular, we want to know whether it got a parse error, so that we can compare that against the reference grammar? |
What if instead we just distinguish parse error vs other error, and we make a separate macro |
Maybe instead of |
to be able to know which diagnostics should also be emitted by the reference grammar
aba8ec9
to
b068441
Compare
With this changes maybe it doesn't make sense to merge it as a separate PR and it should be part of the reference grammar PR? |
@vemoo I was just thinking -- another option is, rather than modifying the The code for getting diagnostics today is: dada/components/dada-db/src/lib.rs Lines 55 to 60 in 0199d1b
but we could add another method: /// Checks `input_file` for parsing errors and returns relevant diagnostics.
pub fn grammar_diagnostics(&self, input_file: InputFile) -> Vec<Diagnostic> {
dada_parse::file_parser::parse_file::<dada_ir::diagnostic::Diagnostics>(
self, input_file,
)
} and it would just the diagnostics emitted by the parser. Maybe that'd be easier still? |
Yeah, I like that. It ended up being a little more complicated: https://github.com/vemoo/dada/blob/29b3718387fe2ae3d4e5498455165d24ac1087b2/components/dada-parse/src/lib.rs#L26-L50 because I'm going to close this PR because this change will make more sense in the context of adding a reference grammar. |
This will help with #17, by making it easier to know for which files the reference parser should emit an error.
We could also complete the expected diagnostics in tests to include the source, but I'm not sure if that is worth it. At the moment we only distinguish between runtime and compile-time diagnostics.