APaGeD automatically generates error messages of the form
filename(line number): found A, expected B, C or D
If you want to specify your own error messages, you can add a special operator in your rules. It is similar to PROLOG's cut operator (if you happen to know it):
Program()
{
"begin" !("Statement expected after begin in line %d")
Statement "end"
{}
}
The effect of this operator is that if a Program symbol is being parsed and the "begin" terminal has been matched successfully, but the Statement non-terminal fails, parsing is aborted and a ParserException with the given error message is thrown.
The !("...") operator therefore cuts off the search tree at it's position. If the parser is in a non-deterministic state, that is, there might be different ways to parse the input, it will not backtrack to try the other paths. If no explicit error message is given, it will backtrack.