[antlr-interest] Query: customizing error messages

Loring Craymer lgcraymer at yahoo.com
Wed Mar 26 23:02:42 PDT 2008


Override getTokenErrorDisplay(Token t)  (see BaseRecognizer) to index into an array of strings (or template names, if you are interested in localization); in this case, array[ID] would be the string "an identifier".

BTW, Ter--BaseRecognizer.getErrorMessage() should use templates instead of only generating English language messages ...

--Loring


----- Original Message ----
From: "nilesh.kapile at tcs.com" <nilesh.kapile at tcs.com>
To: antlr-interest at antlr.org
Sent: Wednesday, March 26, 2008 10:14:57 PM
Subject: [antlr-interest] Query: customizing error messages


Hello,

We are developing a translator for Business-aware
language.

My query is related to Paraphrase
for customizing error messages.

We can use  paraphrases in Rules
to make error messages user-friendly, however, I could not  find a
way to replace token names with user-friendly names.
e.g.:
 mismatchedinput ';' expecting ID. In this message, I want to replace ID with "an
identifier".

ID :('a'..'z'|'A'..'Z'|'_')+('0'..'9')*
;

( options{ paraphrases = "an identifier"; } does not work. )

Any help will be highly appreciated.
Thanks.

Regards,
Nilesh Sudhakar Kapile
Tata Consultancy Services
Mailto: nilesh.kapile at tcs.com
Website: http://www.tcs.com
____________________________________________
Experience certainty.        IT Services
                       Business Solutions
                       Outsourcing
____________________________________________
ForwardSourceID:NT0000EFAE
   
ForwardSourceID:NT0000F00E
   =====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain 
confidential or privileged information. If you are 
not the intended recipient, any dissemination, use, 
review, distribution, printing or copying of the 
information contained in this e-mail message 
and/or attachments to it are strictly prohibited. If 
you have received this communication in error, 
please notify us by reply e-mail or telephone and 
immediately and permanently delete the message 
and any attachments. Thank you








      ____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080326/1ef0bf41/attachment.html 


More information about the antlr-interest mailing list