Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/org/sosy_lab/java_smt/api/FormulaManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ default BooleanFormula makeDistinct(Formula... pArgs) {
default BooleanFormula parse(String s) throws IllegalArgumentException {
List<BooleanFormula> formulas = parseAll(s);
checkArgument(!formulas.isEmpty(), "No assertion found in the SMTLIB string.");
checkArgument(
formulas.size() == 1,
"More than one assertion found in the SMT-LIB string, " + "please use parseAll(String).");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

String concatenation not required. Remove the PLUS.

return Objects.requireNonNull(Iterables.getOnlyElement(formulas));
}

Expand Down
14 changes: 11 additions & 3 deletions src/org/sosy_lab/java_smt/basicimpl/AbstractFormulaManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,17 @@ private String sanitize(String formulaStr) {
int pos = 0; // index of the current token

for (String token : tokens) {
if (Tokenizer.isSetLogicToken(token)) {
// Skip the (set-logic ...) command at the beginning of the input
Preconditions.checkArgument(pos == 0);
if (pos == 0 && Tokenizer.isSetInfoToken(token)) {
// set-info call is allowed to be the very first command in the benchmark, but can also
// appear repeatedly throughout a SMT2 program
// Technically it is even required to be the very first command, and it must set the
// :smt-lib-version attribute. See SMT-LIB 2.7 §3.11.3
// TODO: check that version >= 2?
Preconditions.checkArgument(token.contains(":smt-lib-version"));
Comment thread
daniel-raffler marked this conversation as resolved.
Outdated

} else if (Tokenizer.isSetLogicToken(token)) {
// Skip (set-logic ...) commands for now. They may appear throughout an SMT-LIB2 program
// to set the 'current logic' to a new logic. Default (no command needed): ALL.
Comment thread
daniel-raffler marked this conversation as resolved.
Outdated

} else if (Tokenizer.isExitToken(token)) {
// Skip the (exit) command at the end of the input
Expand Down
4 changes: 4 additions & 0 deletions src/org/sosy_lab/java_smt/basicimpl/Tokenizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ public static boolean isSetLogicToken(String token) {
return matchesOneOf(token, "set-logic");
}

public static boolean isSetInfoToken(String token) {
return matchesOneOf(token, "set-info");
}

/**
* Check if the token is a function or variable declaration.
*
Expand Down
Loading