src/verilogPreproc/verilogPreproc.cpp
/*
 * Remove unwanted comment in text macro.
 * Line escape and Line comment have to be removed
 */
Remove unwanted comment in text macro.
Line escape and Line comment have to be removed
Remove unwanted comment in text macro . Line escape and Line comment have to be removed
void VerilogPreproc::remove_comment(Token *start, Token *end, string *str) {
	vector<Token*> cmtChannel;
	cmtChannel = _tokens.getTokens(start->getTokenIndex(),
			end->getTokenIndex());
	for (auto cmt : cmtChannel) {
		if (cmt->getChannel() == verilogPreprocLexer::CH_LINE_ESCAPE) {
			string comment_txt = cmt->getText();
			replaceStringInPlace(*str, comment_txt, "\n");
		} else if (cmt->getChannel() == verilogPreprocLexer::CH_LINE_COMMENT) {
			string comment_txt = cmt->getText();
			replaceStringInPlace(*str, comment_txt, "");
		}
	}
}
void VerilogPreproc :: remove_comment ( Token * start , Token * end , string * str ) { vector < Token * > cmtChannel ; cmtChannel = _tokens . getTokens ( start -> getTokenIndex ( ) , end -> getTokenIndex ( ) ) ; for ( auto cmt : cmtChannel ) { if ( cmt -> getChannel ( ) == verilogPreprocLexer :: CH_LINE_ESCAPE ) { string comment_txt = cmt -> getText ( ) ; replaceStringInPlace ( * str , comment_txt , " \n " ) ; } else if ( cmt -> getChannel ( ) == verilogPreprocLexer :: CH_LINE_COMMENT ) { string comment_txt = cmt -> getText ( ) ; replaceStringInPlace ( * str , comment_txt , " " ) ; } } }
Remove unwanted comment in text macro.
Remove unwanted comment in text macro .
//Get the list of token between the start and the end of replacement rule. //For all those token we are going to their channel. //If the channel is of the kind we search then we search and removed it from the string. //TODO : replace by " " to preserve character position of the original source code