[antlr-interest] ANTLR problem
Scott Amort
jsamort at gmail.com
Sun Jul 30 08:07:31 PDT 2006
Hi,
Zulfiqar Malik wrote:
> i encounter an exception at the following line of code (for any
> token, in this particular case mNEWLINE in the lexer):
>
> if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken &&
> _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
> _token = makeToken(_ttype);
> _token->setText(text.substr(_begin, text.length()-_begin));
> }
> _returnToken = _token; // <--- CRASH ON THIS LINE
>
> and it should crash since _returnToken is not initialized and points
> to an invalid memory address.
No, this is not the case. _returnToken is a protected member of
CharScanner (of which your lexer L is a derived class). Otherwise you
would have gotten a compiler error, because not only was _returnToken
not initialised in your snippet, it wasn't even declared!
What is the exception you are receiving? Make sure you put your test
code in a try..catch block and see what information the exception is
providing.
Best,
Scott
More information about the antlr-interest
mailing list