I made a typo, *Line Number" is supposed to read "Line offset"
On Wed, Jan 28, 2009 at 12:21 AM, Bot Tiger <[email protected]> wrote: > Hello ANTLR community, > > I have been testing out the error reporting capabilities of the C runtime > and have run into some difficulties trying to get a Line Number. > > > Using the calculator example from the 5 minute intro to ANTLR, I have tried > to use the default error handler. > However, upon trying to detect an EOF token, it segfaults, so I have > attempted to override the default error handlers at > > pParser->rec->reportError > pParser->rec->recover > > pLexer->rec->reportError > pLexer->rec->recover > > > Entering an incomplete expression such as "1+2+" results in an error of > ANTLR3_EARLY_EXIT_EXCEPTION. > > Unfortunately, in antlr3baserecognizer.c, all it does is: > ANTLR3_FPRINTF(stderr, " : missing elements...\n"); > > All my attempts to get a string offset from anywhere have failed. > > Here are a list of my attempts and why it fails. > > ======================================== > recognizer->state->exception->charPositionInLine > --- returns -1 > > theToken = (pANTLR3_COMMON_TOKEN)(recognizer->state->exception->token); > ttext = theToken->toString(theToken); > --- returns a gibberish string > > theToken->getCharPositionInLine(theToken); > --- also returns -1 > > recognizer->state->tokenNames[exception->expecting] > --- exception->expecting is always 0, and the string returned is always > "<invalid>" > > > recognizer->state->tokenStartLine > --- always returns 0 > > recognizer->state->tokenStartCharPositionInLine > --- always returns 0 > > recognizer->state->tokenStartCharIndex > --- always returns 0 > > > (pANTLR3_COMMON_TOKEN)exception->token->.... > --- same problems as tokens above > > recognizer->state->token->.... > --- same problem as tokens above > > (pANTLR3_COMMON_TOKEN)recognizer->getCurrentInputSymbol(recognizer, > parser->tstream->istream) > --- same problems as the tokens above > > > > As you can see I've exhausted almost every combination I can think of, and > I am just wondering if none of the offset indexes are implemented. > > Please send any information on how to get a string offset for either an > expected token location or the last scanned token. > > Thank you. > --~--~---------~--~----~------------~-------~--~----~ 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
