I add another small detail that seems to me more of a bug than a feature: The reportError function in antlr3lexer.c does not increment the state->errorCount attribute of the recognizer and this is why lxr->pLexer->rec->getNumberOfSyntaxErrors(lxr->pLexer->rec) always returns 0;
Luca On Tue, Apr 7, 2009 at 10:20 AM, register reg.ini <[email protected]>wrote: > I have done a little more research and found that the lexer main loop is > found in the nextTokenStr function. > This function handles lexer exceptions and tries to recover from them. This > means that after a successful recovery the > > lexer->rec->state->error and lexer->rec->state->failed attributes are set > to FALSE and that the final state of the lexer does not necessarily contain > information about previous occurred errors. It seems to me that I have to > overload lexer's reportError or displayRecognitionError functions in a way > suitable for my needs. Does the C runtime provide a facility to embed this > overload directly in the grammar (like java's @member or *catch* sections > ) or should I add the overload in the generated code? > > Thanks, > > Luca > > > P.S: Tim, sorry for posting my previous mail only to you and not on the > mailing list. I didn't mean to be rude: I just hit the wrong button. > > > On Mon, Apr 6, 2009 at 5:37 PM, register reg.ini > <[email protected]>wrote: > >> Sorry to ask more questions but I am hitting a stumbling block. >> >> I tryed the following since it is the only thing that makes sense to me >> after reading the source code: >> >> >> tstream->tstream->_LT(tstream->tstream, 1); >> >> pANTLR3_LEXER lexer; >> >> lexer = (pANTLR3_LEXER)(tstream->tstream->tokenSource->super); >> >> size_t nerr=lexer->rec->getNumberOfSyntaxErrors(lexer->rec); >> >> if(nerr!=0) >> >> printf( >> "Syntax errors \n"); >> >> >> >> but this does not work. I really don't understand the relation between the >> recognizers, lexers and parsers.... >> >> Also I really don't understand why one should use a catch all lexer rule >> like ANY: how could I then detect the offending lexer rule? I don't see any >> example of this pattern anywhere ( I own Terence's book) maybe a few >> examples could help in clarifying matters. >> >> Thanks for your help, I really appreciate it very much. >> >> Regards, >> >> Luca >> >> >> > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~----------~----~----~----~------~----~------~--~---
List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
