-
Notifications
You must be signed in to change notification settings - Fork 3
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
A std::io::Read
-based parser. Also, ran cargo format
.
#3
Conversation
This change is straightforward because the DIMACS format is ASCII-only.
Panics on IO errors Why? Because the alternatives are: * `collect` the first IO error -- requiring us to pull the whole string into memory * catch those IO errors deep in the lexer, and bubble them up as a special kind of `ParseError`. Since we'll generally be reading form files, read errors won't typically happen, so I figure its better to just panic, since a use wouldn't want to recover any ways.
1 similar comment
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.
LGTM
Didn't know that the |
I'm not using it yet, but I plan to write a set of teaching SAT solvers on top of it. |
Good to know then we might want to improve it and also provide a streaming interface for clauses using the https://crates.io/crates/ipasir crate. |
Thanks for the PR. I merge this now. |
The reason for this is that it allows parsing to begin without reading the whole file into memory.
At some point it might be nice to add a "clause stream" output as well---then you could incrementally read clauses and assimilate them directly into the SAT solver data structures.
I chose to panic on IO error during the read, because I don't think that users would want to catch them, and panicking is much simpler.
Also, I ran cargo format. Sorry about the large diff, but my editor handles tabs poorly.