[antlr-interest] Handling Lexer, Parser, Tree walker error messages.

Marc-André Laverdière ma_laver at ciise.concordia.ca
Tue May 22 13:32:47 PDT 2007


You can override the reportError() method. You can then redirect the 
parsing exception to wherever you need it for handling.

I personally did it for a parser, and I'm sure that the lexer would work 
too, since they both extend BaseRecognizer.

CARLOS MELGAREJO wrote:
> 
>      I'm trying to develop a web application that allow the user to 
> enter a free form text. The application should be able to
> do lexical, sintatic and semantic interpretation of the text entered by 
> the user, and then finally do an evaluation. I'm using
> ANTLR and for now I just working with very simple grammar, but will grow 
> in the near future. I really like this tool by the way,
> do a lot of stuff for me and the error message is kinda cool.
> 
>      The dilema that I'm facing is that my web application should spit 
> out friendly error messages to the final users. In order
> to do that, I will need a sort of ErrorManager that collect all errors 
> from Lexer, Parser and TreeWalker, I should be able
> to add more errors as well. Then finally display all errors to the user. 
> In that case I can even put some logic anywhere
> when some error occurs stops building the AST tree.
> 
>      I'm aware that there is already some plugins for Eclipse, but I'm 
> using Netbeans. I donwloaded the source code of ANTLR, in
> the mean time I'll be looking on that to see what I can do.
> 
>     Any suggestion to solve my problem or a better approach?.
> 
>    Thanks.

-- 
Marc-André LAVERDIÈRE, B. Eng., M. A. Sc. (in progress)
Computer Security Laboratory - Laboratoire de sécurité informatique
CIISE, Université Concordia University, Montréal, Québec, Canada
www.ciise.concordia.ca

/"\
\ /    ASCII Ribbon Campaign
  X      against HTML e-mail
/ \

"Perseverance must finish its work so that you may be mature and 
complete, not lacking anything." -James 1:4



More information about the antlr-interest mailing list