use of de.be4.classicalb.core.parser.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.classicalb.core.parser.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.classicalb.core.parser.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.classicalb.core.parser.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();
}
use of de.be4.classicalb.core.parser.parser.Parser in project probparsers by bendisposto.
the class CliBParser method parseTemporalFormula.
private static void parseTemporalFormula(BufferedReader in, final TemporalLogicParser<?> parser) throws IOException {
String theFormula;
PrologTermStringOutput strOutput = new PrologTermStringOutput();
theFormula = in.readLine();
try {
final PrologTerm term = parser.generatePrologTerm(theFormula, null);
strOutput.openTerm("ltl").printTerm(term).closeTerm();
} catch (LtlParseException e) {
strOutput.openTerm("syntax_error").printAtom(e.getLocalizedMessage()).closeTerm();
}
strOutput.fullstop();
// A Friendly Reminder: strOutput includes a newline!
print(strOutput.toString());
}
Aggregations