use of de.be4.ltl.core.parser.parser.Parser in project probparsers by bendisposto.
the class LTLFormulaVisitor method parseLTLFormula.
public static Start parseLTLFormula(String ltlFormula) throws ParserException, LexerException, IOException {
StringReader reader = new StringReader(ltlFormula);
PushbackReader r = new PushbackReader(reader);
Lexer l = new LtlLexer(r);
Parser p = new Parser(l);
Start ast = null;
ast = p.parse();
return ast;
}
use of de.be4.ltl.core.parser.parser.Parser in project probparsers by bendisposto.
the class BatchParser method parseFile.
private static void parseFile(final String filename) throws IOException, BCompoundException {
final int dot = filename.lastIndexOf('.');
if (dot >= 0) {
final File machineFile = new File(filename);
final String probfilename = filename.substring(0, dot) + ".prob";
BParser parser = new BParser(filename);
Start tree = parser.parseFile(machineFile, false);
PrintStream output = new PrintStream(probfilename);
BParser.printASTasProlog(output, parser, machineFile, tree, new ParsingBehaviour(), parser.getContentProvider());
output.close();
} else
throw new IllegalArgumentException("Filename '" + filename + "' has no extension");
}
use of de.be4.ltl.core.parser.parser.Parser in project probparsers by bendisposto.
the class LtlParser method parseFormula.
protected Start parseFormula(final String formula) throws LtlParseException, IOException {
StringReader reader = new StringReader(formula);
PushbackReader r = new PushbackReader(reader);
Lexer l = new LtlLexer(r);
Parser p = new Parser(l);
Start ast = null;
try {
ast = p.parse();
} catch (ParserException e) {
final UniversalToken token = UniversalToken.createToken(e.getToken());
throw new LtlParseException(token, e.getLocalizedMessage());
} catch (LexerException e) {
throw new LtlParseException(null, e.getLocalizedMessage());
}
return ast;
}
use of de.be4.ltl.core.parser.parser.Parser in project probparsers by bendisposto.
the class BParser method printASTasProlog.
public static void printASTasProlog(final PrintStream out, final BParser parser, final File bfile, final Start tree, final ParsingBehaviour parsingBehaviour, IDefinitionFileProvider contentProvider) throws BCompoundException {
final RecursiveMachineLoader rml = new RecursiveMachineLoader(bfile.getParent(), contentProvider, parsingBehaviour);
rml.loadAllMachines(bfile, tree, parser.getDefinitions());
rml.printAsProlog(new PrintWriter(out));
}
use of de.be4.ltl.core.parser.parser.Parser in project probparsers by bendisposto.
the class BParser method getASTasFastProlog.
private static String getASTasFastProlog(final BParser parser, final File bfile, final Start tree, final ParsingBehaviour parsingBehaviour, IDefinitionFileProvider contentProvider) throws BCompoundException {
final RecursiveMachineLoader rml = new RecursiveMachineLoader(bfile.getParent(), contentProvider, parsingBehaviour);
rml.loadAllMachines(bfile, tree, parser.getDefinitions());
StructuredPrologOutput structuredPrologOutput = new StructuredPrologOutput();
rml.printAsProlog(structuredPrologOutput);
Collection<PrologTerm> sentences = structuredPrologOutput.getSentences();
StructuredPrologOutput output = new StructuredPrologOutput();
output.openList();
for (PrologTerm term : sentences) {
output.printTerm(term);
}
output.closeList();
output.fullstop();
FastReadTransformer transformer = new FastReadTransformer(output);
return transformer.write();
}
Aggregations