[antlr-interest] TR : Question (or bug alert) : what's the character to append to the end of a string stream ?
Anthony Brenelière
abreneliere at telys.com
Sun Feb 2 15:33:24 PST 2003
I have the following main function i my program :
CMainApp::CMainApp(char * szCmdLine)
{
strstream clinebuf;
clinebuf << szCmdLine << "\377" << ends;
/*
i also tried:
clinebuf << szCmdLine << "\377";
or
clinebuf << szCmdLine << "\377\0";
*/
cmdLineLexer lexer(clinebuf); // <- i insert a string stream as
parameter for the lexer
// TokenBuffer buffer(lexer);
cmdLineParser parser(lexer);
parser.parameter_list();
cin.get();
}
But the lexer throws an an exception because there is no EOF character
at the end of the stream.
When i append an EOF character at the end of the string (lie the
exemple) stream then it does not even work.
My question is: is there something else i should append to my stream to
make my lexer working ?
If, in the grammar-generated function cmdLineLexer::nextToken(), i
manually replace..
if (LA(1)==EOF_CHAR)
{
uponEOF();
_returnToken =
makeToken(ANTLR_USE_NAMESPACE(antlr)Token::EOF_TYPE);
}
..by..
char _c_ = LA(1);
if (_c_==EOF_CHAR)
{
uponEOF();
_returnToken =
makeToken(ANTLR_USE_NAMESPACE(antlr)Token::EOF_TYPE);
}
..then it works !!
So is that could be a bug ?
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list