Search in sources :

Example 1 with UniversalToken

use of de.be4.ltl.core.parser.internal.UniversalToken in project probparsers by bendisposto.

the class CtlParser method parseFormula.

protected Start parseFormula(final String formula) throws LtlParseException, IOException {
    StringReader reader = new StringReader(formula);
    PushbackReader r = new PushbackReader(reader);
    Lexer l = new CtlLexer(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;
}
Also used : ParserException(de.be4.ltl.core.ctlparser.parser.ParserException) CtlLexer(de.be4.ltl.core.parser.internal.CtlLexer) Lexer(de.be4.ltl.core.ctlparser.lexer.Lexer) UniversalToken(de.be4.ltl.core.parser.internal.UniversalToken) Start(de.be4.ltl.core.ctlparser.node.Start) StringReader(java.io.StringReader) CtlLexer(de.be4.ltl.core.parser.internal.CtlLexer) LexerException(de.be4.ltl.core.ctlparser.lexer.LexerException) PushbackReader(java.io.PushbackReader) Parser(de.be4.ltl.core.ctlparser.parser.Parser)

Example 2 with UniversalToken

use of de.be4.ltl.core.parser.internal.UniversalToken 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;
}
Also used : ParserException(de.be4.ltl.core.parser.parser.ParserException) LtlLexer(de.be4.ltl.core.parser.internal.LtlLexer) Lexer(de.be4.ltl.core.parser.lexer.Lexer) UniversalToken(de.be4.ltl.core.parser.internal.UniversalToken) Start(de.be4.ltl.core.parser.node.Start) StringReader(java.io.StringReader) LexerException(de.be4.ltl.core.parser.lexer.LexerException) LtlLexer(de.be4.ltl.core.parser.internal.LtlLexer) PushbackReader(java.io.PushbackReader) Parser(de.be4.ltl.core.parser.parser.Parser)

Aggregations

UniversalToken (de.be4.ltl.core.parser.internal.UniversalToken)2 PushbackReader (java.io.PushbackReader)2 StringReader (java.io.StringReader)2 Lexer (de.be4.ltl.core.ctlparser.lexer.Lexer)1 LexerException (de.be4.ltl.core.ctlparser.lexer.LexerException)1 Start (de.be4.ltl.core.ctlparser.node.Start)1 Parser (de.be4.ltl.core.ctlparser.parser.Parser)1 ParserException (de.be4.ltl.core.ctlparser.parser.ParserException)1 CtlLexer (de.be4.ltl.core.parser.internal.CtlLexer)1 LtlLexer (de.be4.ltl.core.parser.internal.LtlLexer)1 Lexer (de.be4.ltl.core.parser.lexer.Lexer)1 LexerException (de.be4.ltl.core.parser.lexer.LexerException)1 Start (de.be4.ltl.core.parser.node.Start)1 Parser (de.be4.ltl.core.parser.parser.Parser)1 ParserException (de.be4.ltl.core.parser.parser.ParserException)1