-
Notifications
You must be signed in to change notification settings - Fork 1
Insert raw definition into .smt2 file with #![raw_definie()] attribute #21
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
base: main
Are you sure you want to change the base?
Conversation
|
Probably I have to add some more tests and documentation comments. |
| @@ -0,0 +1,20 @@ | |||
| //@error-in-other-file: UnexpectedToken | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can I test that the Thrust panics with a specific error message? I tried using //@error-in-other-file, but I might be misunderstanding its purpose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think testing panic messages is not possible with the current testing framework (ui_test https://docs.rs/ui_test/). However, I don't think we want tests for panicking cases anyway; it would be beneficial if we supported reporting rustc diagnostics for parse errors, but it's out of scope for now.
| let ts = analyze::annot::extract_annot_tokens(attrs.clone()); | ||
| let parser = annot::AnnotParser::new( | ||
| // TODO: this resolver is not actually used. | ||
| analyze::annot::ParamResolver::default() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parseg_raw_definition() is implemented on annot::AnnotParser and it's new() requires any Resolver instance, which isn't actually used in parsing of raw definitions.
I might have to fix so that no Resolver is required for this analysis.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it needs to be implemented in AnnotParser. How about extracting the string from the annotation in a method within crate_::Analyzer?
| writeln!(f, "(set-logic HORN)\n")?; | ||
|
|
||
| // insert definition from #![thrust::define_chc()] here | ||
| for raw_def in self.ctx.raw_definitions() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about just using self.inner.raw_definitions here instead of copying raw_definitions to FormatContext?
| } | ||
|
|
||
| pub fn raw_define_path() -> [Symbol; 2] { | ||
| [Symbol::intern("thrust"), Symbol::intern("raw_define")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this feature could also be used to insert non-definitions into the resulting SMT-LIB2, such as set-option or set-info, so how about naming it something like thrust::raw_command or just thrust::raw? The same applies to RawDefinition and related data structures/functions.
| let ts = analyze::annot::extract_annot_tokens(attrs.clone()); | ||
| let parser = annot::AnnotParser::new( | ||
| // TODO: this resolver is not actually used. | ||
| analyze::annot::ParamResolver::default() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it needs to be implemented in AnnotParser. How about extracting the string from the annotation in a method within crate_::Analyzer?
| @@ -0,0 +1,20 @@ | |||
| //@error-in-other-file: UnexpectedToken | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think testing panic messages is not possible with the current testing framework (ui_test https://docs.rs/ui_test/). However, I don't think we want tests for panicking cases anyway; it would be beneficial if we supported reporting rustc diagnostics for parse errors, but it's out of scope for now.
| //@check-pass | ||
| //@compile-flags: -Adead_code -C debug-assertions=off | ||
|
|
||
| // Insert definitions written in SMT-LIB2 format into .smt file directly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit
| // Insert definitions written in SMT-LIB2 format into .smt file directly. | |
| // Insert definitions written in SMT-LIB2 format into .smt2 file directly. |
|
|
||
| #[thrust::requires(true)] | ||
| #[thrust::ensures(result == 2 * x)] | ||
| // #[thrust::ensures(is_double(x, result))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you plan to uncomment this in a future PR, please add a note about it in the comments.
This attribute allows users to inject arbitrary string literals directly into the generated .smt2 files using crate-level inner attributes.
By adding an inner attribute to the crate root, such as:
The attached string literal will be inserted into the head of the generated SMT-LIB2 file:
This feature is intended for debugging and testing. It enables the manual injection of SMT-LIB logic, serving as a workaround until a dedicated parser is implemented.