[antlr-interest] Token Names
Adam Connelly
adam.rpconnelly at googlemail.com
Tue Jan 8 07:41:38 PST 2008
Hi,
When antlr's doing error reporting it uses the tokenNames array to get the
name of tokens that it couldn't parse (from what I can see). If I want to
change what's displayed in the error message I can easily alter the values
in this array to do so, but is there a way to do this in the grammar?
Here's an example:
rule: expression ';' ;
could give a tokenNames array something like this:
public static final String[] tokenNames = new String[] {
"<invalid>", "<EOR>", "<DOWN>", "<UP>", "';'"
};
whereas
rule: expression SEMI ;
SEMI: ';' ;
could give something like this:
public static final String[] tokenNames = new String[] {
"<invalid>", "<EOR>", "<DOWN>", "<UP>", "SEMI"
};
Is there a way in the grammar to tell antlr to put the actual ';' in the
tokenNames array rather than the name "SEMI" (which apart from the innuendo
might not be amazingly useful to users :))?
Cheers,
Adam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080108/2edf2a70/attachment.html
More information about the antlr-interest
mailing list