Search in sources :

Example 6 with LtlParseException

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

the class LTLFormulaVisitor method parseDefinition.

public void parseDefinition(AExpressionDefinitionDefinition def) {
    if (!(def.getRhs() instanceof AStringExpression)) {
        throw new LTLParseException("Error: LTL formula is not in a string representation.");
    }
    AStringExpression stringNode = (AStringExpression) def.getRhs();
    this.ltlFormula = stringNode.getContent().getText();
    try {
        this.ltlFormulaStart = parseLTLFormula(ltlFormula);
    } catch (Exception e) {
        String message = "Parsing definition " + name + " (line " + def.getStartPos().getLine() + "):\n";
        throw new LTLParseException(message + e.getMessage());
    }
}
Also used : LTLParseException(de.prob.typechecker.exceptions.LTLParseException) AStringExpression(de.be4.classicalb.core.parser.node.AStringExpression) LexerException(de.be4.ltl.core.parser.lexer.LexerException) ParserException(de.be4.ltl.core.parser.parser.ParserException) ScopeException(de.prob.typechecker.exceptions.ScopeException) LTLParseException(de.prob.typechecker.exceptions.LTLParseException) IOException(java.io.IOException) BCompoundException(de.be4.classicalb.core.parser.exceptions.BCompoundException)

Example 7 with LtlParseException

use of de.be4.ltl.core.parser.LtlParseException 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

IOException (java.io.IOException)3 BCompoundException (de.be4.classicalb.core.parser.exceptions.BCompoundException)2 LtlParseException (de.be4.ltl.core.parser.LtlParseException)2 UniversalToken (de.be4.ltl.core.parser.internal.UniversalToken)2 LexerException (de.be4.ltl.core.parser.lexer.LexerException)2 ParserException (de.be4.ltl.core.parser.parser.ParserException)2 PrologTerm (de.prob.prolog.term.PrologTerm)2 LTLParseException (de.prob.typechecker.exceptions.LTLParseException)2 PushbackReader (java.io.PushbackReader)2 StringReader (java.io.StringReader)2 BParser (de.be4.classicalb.core.parser.BParser)1 AStringExpression (de.be4.classicalb.core.parser.node.AStringExpression)1 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 LtlAdapterException (de.be4.ltl.core.parser.internal.LtlAdapterException)1 LtlLexer (de.be4.ltl.core.parser.internal.LtlLexer)1