[antlr-interest] Code generation error?

jm_newton jm_newton at yahoo.co.uk
Tue Jul 27 05:56:40 PDT 2004


Hi,
I'm new to ANTLR (downloaded 2.7.4 a couple of days ago) and have
started trying to specify a grammer. One of my lexer rules is currently:

STRING : !QUOTE ('a'..'z')* !QUOTE 
       ;

which results in the following generated c++ code. Unfourtunately in
the middle of that lot is the statement text.setLength(). setLength()
is not a valid member function of std::basic_string so compilation
fails...

I'm not sure if I'm trying to do the impossible with my parser or
found a real problem here. Environment:
cantlr -> 2.7.4 from WWW site
antlr-2.7.4

John-Mark

void StorageLexer::mSTRING(bool _createToken) {
	int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; int
_begin=text.length();
	_ttype = STRING;
	int _saveIndex;
	
	_saveIndex = text.length();
	mQUOTE(false);
	text.erase(_saveIndex);
	{ // ( ... )*
	for (;;) {
		if (((LA(1) >= 0x61 /* 'a' */  && LA(1) <= 0x7a /* 'z' */ ))) {
			_saveIndex=text.length();
			matchRange('a','z');
			text.setLength(_saveIndex);
		}
		else {
			goto _loop46;
		}
		
	}
	_loop46:;
	} // ( ... )*
	_saveIndex = text.length();
	mQUOTE(false);
	text.erase(_saveIndex);
	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;
}




 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



More information about the antlr-interest mailing list