[antlr-interest] CPP COMMENTS

Ric Klaren ric.klaren at gmail.com
Wed Nov 9 07:41:36 PST 2005


Henry Butowsky wrote:
> Im still trying to get C++ style comments working. I have the rule.
> 
> CPP_COMMENT: ("//" (~'\n')* '\n')
>     { newline(); $setType(antlr::Token::SKIP); };
> 
> It seems to be crashing out in the lexer in CalcLexer::mCPP_COMMENT().
> More specifically -- whats happening is that it is crashing out on the
> line -- match('\n'). I've investigated with the debugger and whats
> happening is that it is matching everything from the comment start till
> the end of the file (ignoring any \n). Thus returning a -1 (which is EOF)
> 
> Setting codeGenBitsetTestThreshold to 999 ?
> Setting k to 3,4,5 ?
> Rebuilding antlr from scratch rather than using rpm distribution

Basically the rule and the generated code look ok.

When you rebuild antlr did you make sure to clean out any old object
files? Also make sure to use the same compiler for both the library and
the project. (make sure it does not pick up a stale libantlr.a from
somewhere else on the system)

What antlr version is this?
What compiler are you using?
On what platform?

It would also be interesting to know why the matchNot is not behaving..
Could you post the _tokenSet_0 contents? (preferably including the
comment with the contents the bitset in front of it)

Does it crash on the call of match or does it crash inside match?

Cheers,

Ric


More information about the antlr-interest mailing list