Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

You can still do something like this manually with very little work. Described in the reference book Chapter 10, "Error Reporting and Recovery" : "Altering Recognizer Error Messages".  The new v3 mechanism lends itself to a more flexible "top down" paraphrase mechanism.  Rules as well as tokens may be paraphrased.  As a simple start the paraphrase option may be replaced trivially...

Code Block

LPAREN options { paraphrase = "("; } : '(';

...by...

Code Block

...
@members {
...
Stack<String> paraphrase = new Stack<String>();
...
}
...
LPAREN
@init { paraphrase.push("("); }
@after { paraphrase.pop(); }
: '(';

Per-Token AST Type Specs

ANTLR 2 allowed the grammar to specify an AST implementation class per token type.

...