use of de.be4.ltl.core.ctlparser.parser.ParserException in project probparsers by bendisposto.
the class EventBParser method createEventBParseException.
private EventBParseException createEventBParseException(final ParserException e) {
final Token token = e.getToken();
String message = e.getMessage();
final boolean expectingFound = message.indexOf("expecting") >= 0;
/*
* Special error message for misplaced comments.
*/
if (expectingFound && token instanceof TComment) {
message = MSG_COMMENT_PLACEMENT;
}
/*
* Replace some token names...
*/
message = message.replaceFirst(" at", " @");
return new EventBParseException(token, message);
}
use of de.be4.ltl.core.ctlparser.parser.ParserException in project probparsers by bendisposto.
the class EventBParser method createEventBParseException.
private EventBParseException createEventBParseException(final ParserException e) {
final Token token = e.getToken();
String message = e.getMessage();
final boolean expectingFound = message.indexOf("expecting") >= 0;
/*
* Special error message for misplaced comments.
*/
if (expectingFound && token instanceof TComment) {
message = MSG_COMMENT_PLACEMENT;
}
/*
* Replace some token names...
*/
message = message.replaceFirst(" at", " @");
return new EventBParseException(token, message);
}
use of de.be4.ltl.core.ctlparser.parser.ParserException 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.ctlparser.parser.ParserException 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.ctlparser.parser.ParserException in project probparsers by bendisposto.
the class BParser method eparse.
public Start eparse(String input, IDefinitions context) throws BCompoundException, LexerException, IOException {
final Reader reader = new StringReader(input);
Start ast = null;
List<String> ids = new ArrayList<>();
final DefinitionTypes defTypes = new DefinitionTypes();
defTypes.addAll(context.getTypes());
BLexer bLexer = new BLexer(new PushbackReader(reader, BLexer.PUSHBACK_BUFFER_SIZE), defTypes);
bLexer.setParseOptions(parseOptions);
Token t;
do {
t = bLexer.next();
if (t instanceof TIdentifierLiteral) {
if (!ids.contains(t.getText())) {
ids.add(t.getText());
}
}
} while (!(t instanceof EOF));
Parser p = new Parser(new EBLexer(input, BigInteger.ZERO, ids, defTypes));
boolean ok;
try {
ast = p.parse();
ok = true;
} catch (Exception e) {
handleException(e);
ok = false;
}
BigInteger b = new BigInteger("2");
b = b.pow(ids.size());
b = b.subtract(BigInteger.ONE);
while (!ok && b.compareTo(BigInteger.ZERO) > 0) {
p = new Parser(new EBLexer(input, b, ids, defTypes));
try {
ast = p.parse();
ok = true;
} catch (ParserException e) {
b = b.subtract(BigInteger.ONE);
handleException(e);
}
}
return ast;
}
Aggregations