[antlr-interest] Proper error handling in a C target parser

Heiko Folkerts Heiko.Folkerts at david-bs.de
Sun Aug 23 23:54:54 PDT 2009


Hi all,
I have an Parser creating an AST which uses the C target. After correct statements are parsed well I want to implement the error handling to provide meaningful error messages to the users.

I've read the coresponding sections of the antlr reference and I think that I need something like @rulecatch but I am a bit confused by the example in java and how to translate it to C correctly - do I have to catch the exceptions like normal C++ exceptions?

What I want to do ist to fill my own structures with the error information instead of displaying a text message. The reason is that the error message will be displayed by a separate component of the software. So I want to catch the errors and fill my own data structures. What is the right way to do that?

I should mention that I use wsyntactic predicates with backtracking in my parser. So a failed predicate doesn't mean that there is something wrong in all circumstances because there are more possible alternatives.

Thanks in advance
Heiko


Mit freundlichem Gruß
Heiko Folkerts
Systementwicklung und -design
--
______________________________________________
DAVID GmbH · Wendenring 1 · 38114 Braunschweig
Tel.: +49 531 24379-14
Fax.: +49 531 24379-79
E-Mail: mailto:Heiko.Folkerts at david-bs.de
WWW:   http://www.david-bs.de 
Eintragung: Amtsgericht Braunschweig, HRB 3167
Geschäftsführer: Frank Ptok
______________________________________________

 


More information about the antlr-interest mailing list