use of de.be4.ltl.core.ctlparser.parser.Parser in project probparsers by bendisposto.
the class DefinitionsErrorsTest method getTreeAsString.
private String getTreeAsString(final String testMachine) throws BCompoundException {
// System.out.println("Parsing: \"" + testMachine + "\":");
final BParser parser = new BParser("testcase");
final Start startNode = parser.parse(testMachine, false);
// startNode.apply(new ASTPrinter());
final Ast2String ast2String = new Ast2String();
startNode.apply(ast2String);
final String string = ast2String.toString();
// System.out.println();
return string;
}
use of de.be4.ltl.core.ctlparser.parser.Parser in project probparsers by bendisposto.
the class PushbackBufferOverflows method withoutPredVars.
@Test
public void withoutPredVars() throws Exception {
String source = "#PREDICATE procs : STRING +-> {\"waiting\",\"ready\"} & current : STRING & idle : {TRUE,FALSE} & idle = FALSE & procs /= { } & { \"waiting\" } /= { } & { \"waiting\" } /\\ ran(procs) = { } & { \"ready\" } = ran(procs)";
BParser parser = new BParser();
Start result = parser.parse(source, false);
assertNotNull(result);
}
use of de.be4.ltl.core.ctlparser.parser.Parser in project probparsers by bendisposto.
the class PushbackBufferOverflows method withPredVars.
@Test
public void withPredVars() throws Exception {
String source = "#PREDICATE procs : STRING +-> {\"waiting\",\"ready\"} & current : STRING & idle : {TRUE,FALSE} & idle = FALSE & procs /= { } & { \"waiting\" } /= { } & { \"waiting\" } /\\ ran(procs) = { } & { \"ready\" } = ran(procs)";
BParser parser = new BParser();
Start result = parser.eparse(source, new MockedDefinitions());
assertNotNull(result);
}
use of de.be4.ltl.core.ctlparser.parser.Parser in project probparsers by bendisposto.
the class Helpers method parseFile2.
public static String parseFile2(String filename) throws IOException {
final File machineFile = new File(filename);
final BParser parser = new BParser(machineFile.getAbsolutePath());
Start tree;
OutputStream output = new OutputStream() {
private StringBuilder string = new StringBuilder();
@Override
public void write(int b) throws IOException {
this.string.append((char) b);
}
public String toString() {
return this.string.toString();
}
};
try {
tree = parser.parseFile(machineFile, false);
PrintStream printStream = new PrintStream(output);
BParser.printASTasProlog(printStream, parser, machineFile, tree, new ParsingBehaviour(), parser.getContentProvider());
output.close();
return output.toString();
} catch (BCompoundException e) {
e.printStackTrace();
PrologExceptionPrinter.printException(output, e);
return output.toString();
}
}
use of de.be4.ltl.core.ctlparser.parser.Parser in project probparsers by bendisposto.
the class Helpers method getMachineAsPrologTerm.
public static String getMachineAsPrologTerm(String input) {
final BParser parser = new BParser("Test");
Start start;
try {
start = parser.parse(input, true);
} catch (BCompoundException e) {
throw new RuntimeException(e);
}
OutputStream output = new OutputStream() {
private StringBuilder string = new StringBuilder();
@Override
public void write(int b) throws IOException {
this.string.append((char) b);
}
public String toString() {
return this.string.toString();
}
};
final IPrologTermOutput pout = new PrologTermOutput(output, false);
printAsProlog(start, pout);
return output.toString();
}
Aggregations