use of de.prob.prolog.term.CompoundPrologTerm in project probparsers by bendisposto.
the class PrologGeneratorTest method testCurrent1.
@Test
public void testCurrent1() throws Exception {
final PrologTerm root = new CompoundPrologTerm("root");
final PrologTerm stateid = new CompoundPrologTerm("stateid", root);
final PrologTerm ap = new CompoundPrologTerm("ap", stateid);
final PrologTerm implies = new CompoundPrologTerm("implies", ap, TERM_TRUE);
final PrologTerm expected = new CompoundPrologTerm("globally", implies);
check("G (current => true)", expected);
}
use of de.prob.prolog.term.CompoundPrologTerm in project probparsers by bendisposto.
the class PrologGeneratorTest method testAction.
@Test
public void testAction() throws Exception {
final PrologTerm transPred = new CompoundPrologTerm("bla");
final PrologTerm wrapped = new CompoundPrologTerm("dtrans", transPred);
final PrologTerm expected = new CompoundPrologTerm("action", wrapped);
check("[bla]", expected);
}
use of de.prob.prolog.term.CompoundPrologTerm in project probparsers by bendisposto.
the class Parserlib17Test method testParserlib17.
@Test
@Ignore
public void testParserlib17() throws Exception {
// has to be ignored because the dummyparser can not parse the ap
// might check for the syntax error exception instead?
final PrologTerm none = new CompoundPrologTerm("none");
final PrologTerm stringl = new CompoundPrologTerm("string", none, new CompoundPrologTerm("{"));
final PrologTerm stringr = new CompoundPrologTerm("string", none, new CompoundPrologTerm("1"));
final PrologTerm eq = new CompoundPrologTerm("equal", none, stringl, stringr);
final PrologTerm bpred = new CompoundPrologTerm("bpred", eq);
final PrologTerm ap = new CompoundPrologTerm("ap", bpred);
final PrologTerm expected = new CompoundPrologTerm("globally", ap);
check("G {\"{\"=\"1\"}", expected);
}
use of de.prob.prolog.term.CompoundPrologTerm in project probparsers by bendisposto.
the class BindingGenerator method createBinding.
private static Map<String, PrologTerm> createBinding(final ListPrologTerm list) {
Map<String, PrologTerm> result;
result = new HashMap<String, PrologTerm>();
for (int i = 0; i < list.size(); i++) {
PrologTerm element = list.get(i);
if (element.isTerm()) {
CompoundPrologTerm binding = (CompoundPrologTerm) element;
if (binding.getArity() == 2 && "=".equals(binding.getFunctor())) {
extractBinding(result, binding);
} else
throw new IllegalArgumentException("Expected binding (=/2), but was " + binding.getFunctor() + "/" + String.valueOf(binding.getArity()));
} else
throw new IllegalArgumentException("Expected binding but was not a term");
}
return Collections.unmodifiableMap(result);
}
use of de.prob.prolog.term.CompoundPrologTerm in project probparsers by bendisposto.
the class BindingGenerator method extractBinding.
private static void extractBinding(final Map<String, PrologTerm> result, final CompoundPrologTerm binding) {
PrologTerm varterm = binding.getArgument(1);
if (varterm.isAtom()) {
String name = ((CompoundPrologTerm) varterm).getFunctor();
PrologTerm value = binding.getArgument(2);
result.put(name, value);
} else
throw new IllegalArgumentException("Expected atomic variable name, but found " + varterm.toString());
}
Aggregations