[antlr-interest] Proper errorhandling in grammars for the C target

Heiko Folkerts Heiko.Folkerts at david-bs.de
Wed Aug 26 02:38:14 PDT 2009


Hi all,
I haven't found any example using the C target that uses things like rulecatch etc. for errorhandling. The chapter in the book uses java and exceptions but I don't know how to translate it to C correctly.

So far I have a parser creating an AST and hooked up a displayRecognitionError function which exists in another CPP file. I had to separate it, because declaring the function in the @members section didn't declare the function in the header file. 

The displayErrorMessage function works correct and I get the errors from failed expressions, but I need more specific error handling. E.g. I use syntactic predicates to check for keywords. At the moment I get the error when the parser finds out, that the whole expression fails but I need to check for special conditions and raise an error.

So is there an example showing such features? 

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