[antlr-interest] CPP COMMENTS
Henry Butowsky
henryb at ntlworld.com
Wed Nov 9 07:44:28 PST 2005
Hi Guys,
Please help. I am at my wits end.
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
Please help
Many thx Henry
void CalcLexer::mCPP_COMMENT(bool _createToken) {
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token;
ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = CPP_COMMENT;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
match("//");
{ // ( ... )*
for (;;) {
if ((_tokenSet_0.member(LA(1)))) {
matchNot('\n' /* charlit */ );
}
else {
goto _loop36;
}
}
_loop36:;
} // ( ... )*
match('\n' /* charlit */ ); //CRASHING OUT HERE
#line 139 "calc.g"
_ttype = antlr::Token::SKIP; newline();
#line 590 "CalcLexer.cpp"
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;
_saveIndex=0;
}
More information about the antlr-interest
mailing list