Search in sources :

Example 1 with BMoThParser

use of de.bmoth.antlr.BMoThParser 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)

Example 2 with BMoThParser

use of de.bmoth.antlr.BMoThParser in project bmoth by hhu-stups.

the class Parser method getParser.

private BMoThParser getParser(String inputString) {
    CodePointCharStream fromString = CharStreams.fromString(inputString);
    final BMoThLexer lexer = new BMoThLexer(fromString);
    // create a buffer of tokens pulled from the lexer
    CommonTokenStream tokens = new CommonTokenStream(lexer);
    BMoThParser bMoThParser = new BMoThParser(tokens);
    bMoThParser.removeErrorListeners();
    ErrorListener errorListener = new ErrorListener();
    bMoThParser.addErrorListener(errorListener);
    return bMoThParser;
}
Also used : CommonTokenStream(org.antlr.v4.runtime.CommonTokenStream) BMoThParser(de.bmoth.antlr.BMoThParser) BMoThLexer(de.bmoth.antlr.BMoThLexer) CodePointCharStream(org.antlr.v4.runtime.CodePointCharStream)

Aggregations

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