[antlr-interest] ANTLR problem

Zulfiqar Malik zulfiqar.malik at gmail.com
Sun Jul 30 10:36:07 PDT 2006


Ok, i finally found out the problem and this will probably serve as a
warning to all those starting out with VS8.0 project.
I was getting all sort of weird errors, CRT exceptions and the likes
and the scenarios were not consistent. You know the sort of errors you
get when you try to compile different projects with different
C-runtime. Obviously i was compiling with /MD compiler option for all
dependent projects. It turns out that the antlr support library (for
which i created the dll project using VS8.0) had the following option
turned on (which was not in the application using this dll)

Project Properties:
->C/C++
->->Language (Treat wchar_t as built-in type)

was set to Yes. This was turned off in the application and hence the
weird errors. Once i turned it off all the errors got fixed, and
turning it off reduced my dll size from 560KB to 180KB!!! Anyways,
thanks for help.

On a side note, is there any online book or tutorial series for ANTLR,
you know something that can serve as a quick reference because i find
the documentation (although clear) not so well organized so it does
not serve as a good quick lookup reference.

On 7/30/06, Scott Amort <jsamort at gmail.com> wrote:
> 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
>


-- 
Regards,
Zulfiqar Inayat Malik.


More information about the antlr-interest mailing list