Search in sources :

Example 1 with VisitorException

use of de.bmoth.parser.ErrorListener.VisitorException in project bmoth by hhu-stups.

the class Parser method parseLTLFormula.

private LtlStartContext parseLTLFormula(String inputString) throws ParseErrorException {
    CodePointCharStream fromString = CharStreams.fromString(inputString);
    final BMoThLexer lexer = new BMoThLexer(fromString);
    lexer.pushMode(BMoThLexer.LTL_MODE);
    // create a buffer of tokens pulled from the lexer
    CommonTokenStream tokens = new CommonTokenStream(lexer);
    BMoThParser parser = new BMoThParser(tokens);
    parser.removeErrorListeners();
    ErrorListener errorListener = new ErrorListener();
    parser.addErrorListener(errorListener);
    try {
        return parser.ltlStart();
    } catch (VisitorException e) {
        final Logger logger = Logger.getLogger(getClass().getName());
        logger.log(Level.SEVERE, PARSE_ERROR, e);
        throw e.getParseErrorException();
    }
}
Also used : CommonTokenStream(org.antlr.v4.runtime.CommonTokenStream) BMoThParser(de.bmoth.antlr.BMoThParser) VisitorException(de.bmoth.parser.ErrorListener.VisitorException) Logger(java.util.logging.Logger) BMoThLexer(de.bmoth.antlr.BMoThLexer) CodePointCharStream(org.antlr.v4.runtime.CodePointCharStream)

Aggregations

BMoThLexer (de.bmoth.antlr.BMoThLexer)1 BMoThParser (de.bmoth.antlr.BMoThParser)1 VisitorException (de.bmoth.parser.ErrorListener.VisitorException)1 Logger (java.util.logging.Logger)1 CodePointCharStream (org.antlr.v4.runtime.CodePointCharStream)1 CommonTokenStream (org.antlr.v4.runtime.CommonTokenStream)1