Skip to content
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

Set option support #608

Merged
merged 19 commits into from
Jun 2, 2023
Merged

Set option support #608

merged 19 commits into from
Jun 2, 2023

Conversation

Halbaroth
Copy link
Collaborator

@Halbaroth Halbaroth commented May 26, 2023

This PR aims to make AE fit better the SMT-LIB standards by adding the support for set-option.

  • support :regular-output-channel and :diagnostic-output-channel
  • support :produce-models
  • partial support :verbosity
  • partial support :reproducible-resource-limit
  • support :produce-unsat-cores

I don't plan to support other standard options in this PR. Maybe we could add print-success later.

I had to refactor the way AE manages its output channels in order to be able to change the channel during the execution of smt2 scripts.

@Halbaroth Halbaroth added this to the 2.5.0 milestone May 26, 2023
@Halbaroth Halbaroth force-pushed the set-option-support branch 2 times, most recently from b97b16d to 5ca3313 Compare May 26, 2023 15:57
@Halbaroth Halbaroth marked this pull request as ready for review May 30, 2023 13:09
@Halbaroth
Copy link
Collaborator Author

It is ready :)

Copy link
Collaborator

@bclement-ocp bclement-ocp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a couple minor naming concerns.

src/bin/common/parse_command.ml Show resolved Hide resolved
src/bin/common/parse_command.ml Outdated Show resolved Hide resolved
src/bin/common/parse_command.ml Outdated Show resolved Hide resolved
let usc_output = ref Stdout

let contents = function
| Stdout | Stderr | Channel _ | Invalid -> ""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a very good idea and can only cause confusion if that function ever ends up called on a non-buffer output. At the very least this should raise an exception, but a better API design would be:

  • Replace Buffer of Buffer.t * Format.formatter with Formatter of Format.formatter
  • Remove create_buffer and replace it with let of_formatter fmt = Formatter fmt
  • Remove contents entirely
  • Users of create_buffer (i.e. the js_worker) are responsible for calling formatter_of_buffer and Buffer.contents directly (and maybe there should be a pp_print_flush somewhere?)

Copy link
Collaborator Author

@Halbaroth Halbaroth May 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only flush the formatter. According to the documentation:

formatter_of_buffer b returns a new formatter writing to buffer b. At the end of pretty-printing, the formatter must be flushed using Format.pp_print_flush or Format.pp_print_newline, to print all the pending material into the buffer.

it should be fine :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation you quoted states that the formatter must be flushed but I didn't see where this actually happens in the code?

Copy link
Collaborator Author

@Halbaroth Halbaroth May 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should happen in the finalizer close_all but I forgot to add it in the js_worker. I will do it right now. Using set-option calls systematically the function Output.close on the old output channel.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it ok?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling close_all on at_exit in the JS worker is good, but not sufficient to ensure we get the proper content of the buffer. The corresponding formatter must be flushed with pp_print_flush before calling Buffer.contents.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooh I thought Buffer.contents calls the flush procedure!

src/lib/util/options.mli Outdated Show resolved Hide resolved
src/lib/util/options.mli Show resolved Hide resolved
src/lib/util/options.mli Outdated Show resolved Hide resolved
src/bin/common/parse_command.ml Show resolved Hide resolved
src/bin/common/parse_command.ml Outdated Show resolved Hide resolved
src/bin/common/parse_command.ml Outdated Show resolved Hide resolved
Copy link
Collaborator

@bclement-ocp bclement-ocp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could have simply propagated the formatter from create_buffer but it looks good to me now, let's merge this :)

@Halbaroth Halbaroth merged commit 35cf1c3 into OCamlPro:next Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants