Skip to content

Commit 76df5f0

Browse files
Fix parsing for Princess and make sure that an IllegalArgumentException is thrown if an invalid symbol name is used in the input script
1 parent edf75a2 commit 76df5f0

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/org/sosy_lab/java_smt/solvers/princess/PrincessEnvironment.java

+13
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
package org.sosy_lab.java_smt.solvers.princess;
1010

11+
import static com.google.common.base.Preconditions.checkArgument;
1112
import static scala.collection.JavaConverters.asJava;
1213
import static scala.collection.JavaConverters.collectionAsScalaIterableConverter;
1314

@@ -82,6 +83,7 @@
8283
import org.sosy_lab.common.io.PathCounterTemplate;
8384
import org.sosy_lab.java_smt.api.FormulaType;
8485
import org.sosy_lab.java_smt.api.SolverContext.ProverOptions;
86+
import org.sosy_lab.java_smt.basicimpl.FormulaCreator;
8587
import ostrich.OFlags;
8688
import ostrich.OstrichStringTheory;
8789
import scala.Tuple2;
@@ -323,6 +325,17 @@ public List<? extends IExpression> parseStringToTerms(String s, PrincessFormulaC
323325

324326
final List<IFormula> formulas = asJava(parserResult._1());
325327

328+
// Check that all user defined function, constant and predicate symbols have valid names
329+
for (IFunction f : asJava(parserResult._2().keys())) {
330+
checkArgument(FormulaCreator.isValidName(FormulaCreator.dequote(f.name())));
331+
}
332+
for (ConstantTerm c : asJava(parserResult._3().keys())) {
333+
checkArgument(FormulaCreator.isValidName(FormulaCreator.dequote(c.name())));
334+
}
335+
for (Predicate p : asJava(parserResult._4().keys())) {
336+
checkArgument(FormulaCreator.isValidName(FormulaCreator.dequote(p.name())));
337+
}
338+
326339
ImmutableSet.Builder<IExpression> declaredFunctions = ImmutableSet.builder();
327340
for (IExpression f : formulas) {
328341
declaredFunctions.addAll(creator.extractVariablesAndUFs(f, true).values());

0 commit comments

Comments
 (0)