<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>ANTLR Support Libraries 2.7.1+: antlr/TokenStreamRewriteEngine.hpp Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="search/search.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="search/search.js"></script> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body onload='searchBox.OnSelectItem(0);'> <!-- Generated by Doxygen 1.7.3 --> <script type="text/javascript"><!-- var searchBox = new SearchBox("searchBox", "search",false,'Search'); --></script> <div id="top"> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">ANTLR Support Libraries 2.7.1+</div> </td> </tr> </tbody> </table> </div> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li id="searchli"> <div id="MSearchBox" class="MSearchBoxInactive"> <span class="left"> <img id="MSearchSelect" src="search/mag_sel.png" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" alt=""/> <input type="text" id="MSearchField" value="Search" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)" onblur="searchBox.OnSearchFieldFocus(false)" onkeyup="searchBox.OnSearchFieldChange(event)"/> </span><span class="right"> <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a> </span> </div> </li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <div class="header"> <div class="headertitle"> <h1>antlr/TokenStreamRewriteEngine.hpp</h1> </div> </div> <div class="contents"> <a href="TokenStreamRewriteEngine_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef INC_TokenStreamRewriteEngine_hpp__</span> <a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor">#define INC_TokenStreamRewriteEngine_hpp__</span> <a name="l00003"></a>00003 <span class="preprocessor"></span> <a name="l00004"></a>00004 <span class="comment">/* ANTLR Translator Generator</span> <a name="l00005"></a>00005 <span class="comment"> * Project led by Terence Parr at http://www.jGuru.com</span> <a name="l00006"></a>00006 <span class="comment"> * Software rights: http://www.antlr.org/license.html</span> <a name="l00007"></a>00007 <span class="comment"> */</span> <a name="l00008"></a>00008 <a name="l00009"></a>00009 <span class="preprocessor">#include <string></span> <a name="l00010"></a>00010 <span class="preprocessor">#include <list></span> <a name="l00011"></a>00011 <span class="preprocessor">#include <vector></span> <a name="l00012"></a>00012 <span class="preprocessor">#include <map></span> <a name="l00013"></a>00013 <span class="preprocessor">#include <utility></span> <a name="l00014"></a>00014 <span class="preprocessor">#include <iostream></span> <a name="l00015"></a>00015 <span class="preprocessor">#include <iterator></span> <a name="l00016"></a>00016 <span class="preprocessor">#include <cassert></span> <a name="l00017"></a>00017 <span class="preprocessor">#include <algorithm></span> <a name="l00018"></a>00018 <a name="l00019"></a>00019 <span class="preprocessor">#include <antlr/config.hpp></span> <a name="l00020"></a>00020 <a name="l00021"></a>00021 <span class="preprocessor">#include <antlr/TokenStream.hpp></span> <a name="l00022"></a>00022 <span class="preprocessor">#include <antlr/TokenWithIndex.hpp></span> <a name="l00023"></a>00023 <span class="preprocessor">#include <antlr/BitSet.hpp></span> <a name="l00024"></a>00024 <a name="l00025"></a>00025 <span class="preprocessor">#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE</span> <a name="l00026"></a>00026 <span class="preprocessor"></span><span class="keyword">namespace </span>antlr { <a name="l00027"></a>00027 <span class="preprocessor">#endif</span> <a name="l00028"></a>00028 <span class="preprocessor"></span> <a name="l00077"></a><a class="code" href="classTokenStreamRewriteEngine.html">00077</a> <span class="keyword">class </span><a class="code" href="classTokenStreamRewriteEngine.html">TokenStreamRewriteEngine</a> : <span class="keyword">public</span> <a class="code" href="classTokenStream.html">TokenStream</a> <a name="l00078"></a>00078 { <a name="l00079"></a>00079 <span class="keyword">public</span>: <a name="l00080"></a>00080 <span class="keyword">typedef</span> <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)vector<antlr::RefTokenWithIndex> <a class="code" href="classTokenStreamRewriteEngine.html#a2be10b6477784e9cb704a66d9d6273e2">token_list</a>; <a name="l00081"></a><a class="code" href="classTokenStreamRewriteEngine.html#a2be10b6477784e9cb704a66d9d6273e2">00081</a> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* DEFAULT_PROGRAM_NAME; <a name="l00082"></a><a class="code" href="classTokenStreamRewriteEngine.html#a2a0a8089b1e2f73bad643ccd928ccbbe">00082</a> <span class="preprocessor">#ifndef NO_STATIC_CONSTS</span> <a name="l00083"></a>00083 <span class="preprocessor"></span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">size_t</span> MIN_TOKEN_INDEX; <a name="l00084"></a><a class="code" href="classTokenStreamRewriteEngine.html#a481fd309b9c39105572768f84337601e">00084</a> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> PROGRAM_INIT_SIZE; <a name="l00085"></a><a class="code" href="classTokenStreamRewriteEngine.html#a73069518168545dcd5fe1b8aa701e82f">00085</a> <span class="preprocessor">#else</span> <a name="l00086"></a>00086 <span class="preprocessor"></span> <span class="keyword">enum</span> { <a name="l00087"></a>00087 MIN_TOKEN_INDEX = 0, <a name="l00088"></a>00088 PROGRAM_INIT_SIZE = 100 <a name="l00089"></a>00089 }; <a name="l00090"></a>00090 <span class="preprocessor">#endif</span> <a name="l00091"></a>00091 <span class="preprocessor"></span> <a name="l00092"></a>00092 <span class="keyword">struct </span>tokenToStream { <a name="l00093"></a><a class="code" href="structTokenStreamRewriteEngine_1_1tokenToStream.html">00093</a> <a class="code" href="structTokenStreamRewriteEngine_1_1tokenToStream.html">tokenToStream</a>( <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)ostream& o ) : out(o) {} <a name="l00094"></a><a class="code" href="structTokenStreamRewriteEngine_1_1tokenToStream.html#a74f548e6afffee0cb79110b7bd2d5a7c">00094</a> <span class="keyword">template</span> <<span class="keyword">typename</span> T> <span class="keywordtype">void</span> operator() ( <span class="keyword">const</span> T& t ) { <a name="l00095"></a><a class="code" href="structTokenStreamRewriteEngine_1_1tokenToStream.html#a27a1e4f4cfa03e73c3f3043f371a15b9">00095</a> out << t->getText(); <a name="l00096"></a>00096 } <a name="l00097"></a>00097 <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)ostream& out; <a name="l00098"></a><a class="code" href="structTokenStreamRewriteEngine_1_1tokenToStream.html#ae79ccdc9b151eb68b74193fee3d60644">00098</a> }; <a name="l00099"></a>00099 <a name="l00100"></a>00100 class <a class="code" href="classTokenStreamRewriteEngine_1_1RewriteOperation.html">RewriteOperation</a> { <a name="l00101"></a><a class="code" href="classTokenStreamRewriteEngine_1_1RewriteOperation.html">00101</a> <span class="keyword">protected</span>: <a name="l00102"></a>00102 RewriteOperation( <span class="keywordtype">size_t</span> idx, <span class="keyword">const</span> <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)<span class="keywordtype">string</span>& txt ) <a name="l00103"></a><a class="code" href="classTokenStreamRewriteEngine_1_1RewriteOperation.html#a5ff3c23799a28fd83a6a9f5911705c29">00103</a> : index(idx), text(txt) <a name="l00104"></a>00104 { <a name="l00105"></a>00105 } <a name="l00106"></a>00106 <span class="keyword">public</span>: <a name="l00107"></a>00107 <span class="keyword">virtual</span> ~RewriteOperation() <a name="l00108"></a><a class="code" href="classTokenStreamRewriteEngine_1_1RewriteOperation.html#a6b1f951221ce2039526a0f11bf0893cb">00108</a> { <a name="l00109"></a>00109 } <a name="l00113"></a>00113 <span class="keyword">virtual</span> <span class="keywordtype">size_t</span> execute( <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)ostream& <span class="comment">/* out */</span> ) { <a name="l00114"></a><a class="code" href="classTokenStreamRewriteEngine_1_1RewriteOperation.html#aee3239663513dd77cdd450980faa6c90">00114</a> <span class="keywordflow">return</span> index; <a name="l00115"></a>00115 } <a name="l00116"></a>00116 <span class="keyword">virtual</span> <span class="keywordtype">size_t</span> getIndex()<span class="keyword"> const </span>{ <a name="l00117"></a><a class="code" href="classTokenStreamRewriteEngine_1_1RewriteOperation.html#a176951d75ef39d88ba89dbd6c51d1de5">00117</a> <span class="keywordflow">return</span> index; <a name="l00118"></a>00118 } <a name="l00119"></a>00119 <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* type()<span class="keyword"> const </span>{ <a name="l00120"></a><a class="code" href="classTokenStreamRewriteEngine_1_1RewriteOperation.html#afddc0c8dc679eb5bc7390a5a27a5a603">00120</a> <span class="keywordflow">return</span> <span class="stringliteral">"RewriteOperation"</span>; <a name="l00121"></a>00121 } <a name="l00122"></a>00122 <span class="keyword">protected</span>: <a name="l00123"></a>00123 <span class="keywordtype">size_t</span> index; <a name="l00124"></a><a class="code" href="classTokenStreamRewriteEngine_1_1RewriteOperation.html#ad260f22b94777f69bd8b0e8d5f05e294">00124</a> <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)string text; <a name="l00125"></a><a class="code" href="classTokenStreamRewriteEngine_1_1RewriteOperation.html#ad589204a972ff5fa42bb40f47757a9db">00125</a> }; <a name="l00126"></a>00126 <a name="l00127"></a>00127 struct <a class="code" href="structTokenStreamRewriteEngine_1_1executeOperation.html">executeOperation</a> { <a name="l00128"></a><a class="code" href="structTokenStreamRewriteEngine_1_1executeOperation.html">00128</a> <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)ostream& out; <a name="l00129"></a><a class="code" href="structTokenStreamRewriteEngine_1_1executeOperation.html#a7467d9f000eed4732043653be719b099">00129</a> executeOperation( <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)ostream& s ) : out(s) {} <a name="l00130"></a><a class="code" href="structTokenStreamRewriteEngine_1_1executeOperation.html#abb50ed0d334c923a962ebef55dfede06">00130</a> <span class="keywordtype">void</span> operator () ( RewriteOperation* t ) { <a name="l00131"></a><a class="code" href="structTokenStreamRewriteEngine_1_1executeOperation.html#aef266bb4905af32cf5a5df4d48247271">00131</a> t-><a class="code" href="classTokenStreamRewriteEngine_1_1RewriteOperation.html#aee3239663513dd77cdd450980faa6c90">execute</a>(out); <a name="l00132"></a>00132 } <a name="l00133"></a>00133 }; <a name="l00134"></a>00134 <a name="l00136"></a>00136 <span class="keyword">typedef</span> <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)list<RewriteOperation*> operation_list; <a name="l00138"></a>00138 typedef <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)map<<a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)<span class="keywordtype">string</span>,operation_list> program_map; <a name="l00139"></a><a class="code" href="classTokenStreamRewriteEngine.html#a6ace1ccee2524d37862c1d68a5a923c4">00139</a> <a name="l00140"></a>00140 class <a class="code" href="classTokenStreamRewriteEngine_1_1InsertBeforeOp.html">InsertBeforeOp</a> : public RewriteOperation <a name="l00141"></a><a class="code" href="classTokenStreamRewriteEngine_1_1InsertBeforeOp.html">00141</a> { <a name="l00142"></a>00142 <span class="keyword">public</span>: <a name="l00143"></a>00143 <a class="code" href="classTokenStreamRewriteEngine_1_1InsertBeforeOp.html">InsertBeforeOp</a>( <span class="keywordtype">size_t</span> index, <span class="keyword">const</span> <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)<span class="keywordtype">string</span>& text ) <a name="l00144"></a><a class="code" href="classTokenStreamRewriteEngine_1_1InsertBeforeOp.html#a2a5fbaa28cc2ae52fc0cc343b93ac91a">00144</a> : RewriteOperation(index, text) <a name="l00145"></a>00145 { <a name="l00146"></a>00146 } <a name="l00147"></a>00147 <span class="keyword">virtual</span> ~<a class="code" href="classTokenStreamRewriteEngine_1_1InsertBeforeOp.html">InsertBeforeOp</a>() {} <a name="l00148"></a><a class="code" href="classTokenStreamRewriteEngine_1_1InsertBeforeOp.html#a77e95aed9bd33d998609a7e955d4e7ea">00148</a> <span class="keyword">virtual</span> <span class="keywordtype">size_t</span> execute( <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)ostream& out ) <a name="l00149"></a><a class="code" href="classTokenStreamRewriteEngine_1_1InsertBeforeOp.html#a8eb70be0ec324e87f18b586a4bd763b2">00149</a> { <a name="l00150"></a>00150 out << text; <a name="l00151"></a>00151 <span class="keywordflow">return</span> index; <a name="l00152"></a>00152 } <a name="l00153"></a>00153 <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* type()<span class="keyword"> const </span>{ <a name="l00154"></a><a class="code" href="classTokenStreamRewriteEngine_1_1InsertBeforeOp.html#a18517591759afc2a66ce8f464e211813">00154</a> <span class="keywordflow">return</span> <span class="stringliteral">"InsertBeforeOp"</span>; <a name="l00155"></a>00155 } <a name="l00156"></a>00156 }; <a name="l00157"></a>00157 <a name="l00158"></a>00158 <span class="keyword">class </span>ReplaceOp : <span class="keyword">public</span> RewriteOperation <a name="l00159"></a><a class="code" href="classTokenStreamRewriteEngine_1_1ReplaceOp.html">00159</a> { <a name="l00160"></a>00160 <span class="keyword">public</span>: <a name="l00161"></a>00161 <a class="code" href="classTokenStreamRewriteEngine_1_1ReplaceOp.html">ReplaceOp</a>(<span class="keywordtype">size_t</span> from, <span class="keywordtype">size_t</span> to, <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)<span class="keywordtype">string</span> text) <a name="l00162"></a><a class="code" href="classTokenStreamRewriteEngine_1_1ReplaceOp.html#a59f8be887674b3cbe8f643d7f559fdde">00162</a> : RewriteOperation(from,text) <a name="l00163"></a>00163 , lastIndex(to) <a name="l00164"></a>00164 { <a name="l00165"></a>00165 } <a name="l00166"></a>00166 <span class="keyword">virtual</span> ~<a class="code" href="classTokenStreamRewriteEngine_1_1ReplaceOp.html">ReplaceOp</a>() {} <a name="l00167"></a><a class="code" href="classTokenStreamRewriteEngine_1_1ReplaceOp.html#a082e2a0415369fd083d19525da2f6e80">00167</a> <span class="keyword">virtual</span> <span class="keywordtype">size_t</span> execute( <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)ostream& out ) { <a name="l00168"></a><a class="code" href="classTokenStreamRewriteEngine_1_1ReplaceOp.html#a604256b5d1531b5b982e2b507fb4a4a7">00168</a> out << text; <a name="l00169"></a>00169 <span class="keywordflow">return</span> lastIndex+1; <a name="l00170"></a>00170 } <a name="l00171"></a>00171 <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* type()<span class="keyword"> const </span>{ <a name="l00172"></a><a class="code" href="classTokenStreamRewriteEngine_1_1ReplaceOp.html#a8e866be59ceffaf1bc77f99b0b9d67f1">00172</a> <span class="keywordflow">return</span> <span class="stringliteral">"ReplaceOp"</span>; <a name="l00173"></a>00173 } <a name="l00174"></a>00174 <span class="keyword">protected</span>: <a name="l00175"></a>00175 <span class="keywordtype">size_t</span> lastIndex; <a name="l00176"></a><a class="code" href="classTokenStreamRewriteEngine_1_1ReplaceOp.html#ad460ff5b2252123f9a9820bd6f332f13">00176</a> }; <a name="l00177"></a>00177 <a name="l00178"></a>00178 <span class="keyword">class </span><a class="code" href="classTokenStreamRewriteEngine_1_1DeleteOp.html">DeleteOp</a> : <span class="keyword">public</span> <a class="code" href="classTokenStreamRewriteEngine_1_1ReplaceOp.html">ReplaceOp</a> { <a name="l00179"></a><a class="code" href="classTokenStreamRewriteEngine_1_1DeleteOp.html">00179</a> <span class="keyword">public</span>: <a name="l00180"></a>00180 <a class="code" href="classTokenStreamRewriteEngine_1_1DeleteOp.html">DeleteOp</a>(<span class="keywordtype">size_t</span> from, <span class="keywordtype">size_t</span> to) <a name="l00181"></a><a class="code" href="classTokenStreamRewriteEngine_1_1DeleteOp.html#a1856f3aba6afa530cfb0bf12515d5f31">00181</a> : <a class="code" href="classTokenStreamRewriteEngine_1_1ReplaceOp.html">ReplaceOp</a>(from,to,<span class="stringliteral">""</span>) <a name="l00182"></a>00182 { <a name="l00183"></a>00183 } <a name="l00184"></a>00184 <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keywordtype">char</span>* type()<span class="keyword"> const </span>{ <a name="l00185"></a><a class="code" href="classTokenStreamRewriteEngine_1_1DeleteOp.html#a1f53abd41bb741b3df82de48dc0a272b">00185</a> <span class="keywordflow">return</span> <span class="stringliteral">"DeleteOp"</span>; <a name="l00186"></a>00186 } <a name="l00187"></a>00187 }; <a name="l00188"></a>00188 <a name="l00189"></a>00189 <a class="code" href="classTokenStreamRewriteEngine.html">TokenStreamRewriteEngine</a>(<a class="code" href="classTokenStream.html">TokenStream</a>& upstream); <a name="l00190"></a>00190 <a name="l00191"></a>00191 <a class="code" href="classTokenStreamRewriteEngine.html">TokenStreamRewriteEngine</a>(<a class="code" href="classTokenStream.html">TokenStream</a>& upstream, <span class="keywordtype">size_t</span> initialSize); <a name="l00192"></a>00192 <a name="l00193"></a>00193 <a class="code" href="classTokenRefCount.html">RefToken</a> nextToken( <span class="keywordtype">void</span> ); <a name="l00194"></a>00194 <a name="l00195"></a>00195 <span class="keywordtype">void</span> rollback(<span class="keywordtype">size_t</span> instructionIndex) { <a name="l00196"></a><a class="code" href="classTokenStreamRewriteEngine.html#a73185dea4e41801999787a5df6ca8168">00196</a> <a class="code" href="classTokenStreamRewriteEngine.html#a73185dea4e41801999787a5df6ca8168">rollback</a>(DEFAULT_PROGRAM_NAME, instructionIndex); <a name="l00197"></a>00197 } <a name="l00198"></a>00198 <a name="l00203"></a>00203 <span class="keywordtype">void</span> rollback(<span class="keyword">const</span> <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)<span class="keywordtype">string</span>& programName, <a name="l00204"></a>00204 <span class="keywordtype">size_t</span> instructionIndex ); <a name="l00205"></a>00205 <a name="l00206"></a>00206 <span class="keywordtype">void</span> deleteProgram() { <a name="l00207"></a><a class="code" href="classTokenStreamRewriteEngine.html#aa13fca3fd25773504c10ccd422604c00">00207</a> <a class="code" href="classTokenStreamRewriteEngine.html#aa13fca3fd25773504c10ccd422604c00">deleteProgram</a>(DEFAULT_PROGRAM_NAME); <a name="l00208"></a>00208 } <a name="l00209"></a>00209 <a name="l00211"></a>00211 <span class="keywordtype">void</span> deleteProgram(<span class="keyword">const</span> <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)<span class="keywordtype">string</span>& programName) { <a name="l00212"></a><a class="code" href="classTokenStreamRewriteEngine.html#a77828c12aa05fcb4bdda51b6445659ef">00212</a> rollback(programName, MIN_TOKEN_INDEX); <a name="l00213"></a>00213 } <a name="l00214"></a>00214 <a name="l00215"></a>00215 <span class="keywordtype">void</span> insertAfter( <a class="code" href="classTokenRefCount.html">RefTokenWithIndex</a> t, <a name="l00216"></a><a class="code" href="classTokenStreamRewriteEngine.html#a8f299252ffc85c3baf5b13893001760e">00216</a> <span class="keyword">const</span> <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)<span class="keywordtype">string</span>& text ) <a name="l00217"></a>00217 { <a name="l00218"></a>00218 <a class="code" href="classTokenStreamRewriteEngine.html#a8f299252ffc85c3baf5b13893001760e">insertAfter</a>(DEFAULT_PROGRAM_NAME, t, text); <a name="l00219"></a>00219 } <a name="l00220"></a>00220 <a name="l00221"></a>00221 <span class="keywordtype">void</span> insertAfter(<span class="keywordtype">size_t</span> index, <span class="keyword">const</span> <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)<span class="keywordtype">string</span>& text) { <a name="l00222"></a><a class="code" href="classTokenStreamRewriteEngine.html#a4ce8ce21451f201feb2cac291f21d242">00222</a> <a class="code" href="classTokenStreamRewriteEngine.html#a4ce8ce21451f201feb2cac291f21d242">insertAfter</a>(DEFAULT_PROGRAM_NAME, index, text); <a name="l00223"></a>00223 } <a name="l00224"></a>00224 <a name="l00225"></a>00225 <span class="keywordtype">void</span> insertAfter( <span class="keyword">const</span> <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)<span class="keywordtype">string</span>& programName, <a name="l00226"></a><a class="code" href="classTokenStreamRewriteEngine.html#ad13bdfee996e28e6901b15b5fa76623f">00226</a> <a class="code" href="classTokenRefCount.html">RefTokenWithIndex</a> t, <a name="l00227"></a>00227 <span class="keyword">const</span> <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)<span class="keywordtype">string</span>& text ) <a name="l00228"></a>00228 { <a name="l00229"></a>00229 <a class="code" href="classTokenStreamRewriteEngine.html#ad13bdfee996e28e6901b15b5fa76623f">insertAfter</a>(programName, t->getIndex(), text); <a name="l00230"></a>00230 } <a name="l00231"></a>00231 <a name="l00232"></a>00232 <span class="keywordtype">void</span> insertAfter( <span class="keyword">const</span> <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)<span class="keywordtype">string</span>& programName, <a name="l00233"></a><a class="code" href="classTokenStreamRewriteEngine.html#ac5992ec4a7efa1ee2a108a7e8ef31ebe">00233</a> <span class="keywordtype">size_t</span> index, <a name="l00234"></a>00234 <span class="keyword">const</span> <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)<span class="keywordtype">string</span>& text ) <a name="l00235"></a>00235 { <a name="l00236"></a>00236 <span class="comment">// to insert after, just insert before next index (even if past end)</span> <a name="l00237"></a>00237 insertBefore(programName,index+1, text); <a name="l00238"></a>00238 } <a name="l00239"></a>00239 <a name="l00240"></a>00240 <span class="keywordtype">void</span> insertBefore( <a class="code" href="classTokenRefCount.html">RefTokenWithIndex</a> t, <a name="l00241"></a><a class="code" href="classTokenStreamRewriteEngine.html#a292a230fbd1c2cb741c56d6f5d877fb9">00241</a> <span class="keyword">const</span> <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)<span class="keywordtype">string</span>& text ) <a name="l00242"></a>00242 { <a name="l00243"></a>00243 <span class="comment">// std::cout << "insertBefore index " << t->getIndex() << " " << text << std::endl;</span> <a name="l00244"></a>00244 insertBefore(DEFAULT_PROGRAM_NAME, t, text); <a name="l00245"></a>00245 } <a name="l00246"></a>00246 <a name="l00247"></a>00247 <span class="keywordtype">void</span> insertBefore(<span class="keywordtype">size_t</span> index, <span class="keyword">const</span> <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)<span class="keywordtype">string</span>& text) { <a name="l00248"></a><a class="code" href="classTokenStreamRewriteEngine.html#a93758b1f2f150d139957093510b830ef">00248</a> <a class="code" href="classTokenStreamRewriteEngine.html#a93758b1f2f150d139957093510b830ef">insertBefore</a>(DEFAULT_PROGRAM_NAME, index, text); <a name="l00249"></a>00249 } <a name="l00250"></a>00250 <a name="l00251"></a>00251 <span class="keywordtype">void</span> insertBefore( <span class="keyword">const</span> <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)<span class="keywordtype">string</span>& programName, <a name="l00252"></a><a class="code" href="classTokenStreamRewriteEngine.html#a18f81404434c15194aef08dc4dcc6444">00252</a> <a class="code" href="classTokenRefCount.html">RefTokenWithIndex</a> t, <a name="l00253"></a>00253 <span class="keyword">const</span> <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)<span class="keywordtype">string</span>& text ) <a name="l00254"></a>00254 { <a name="l00255"></a>00255 <a class="code" href="classTokenStreamRewriteEngine.html#a18f81404434c15194aef08dc4dcc6444">insertBefore</a>(programName, t->getIndex(), text); <a name="l00256"></a>00256 } <a name="l00257"></a>00257 <a name="l00258"></a>00258 <span class="keywordtype">void</span> insertBefore( <span class="keyword">const</span> <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)<span class="keywordtype">string</span>& programName, <a name="l00259"></a><a class="code" href="classTokenStreamRewriteEngine.html#a126a621dbbb2322d1699032d88ce4655">00259</a> <span class="keywordtype">size_t</span> index, <a name="l00260"></a>00260 <span class="keyword">const</span> <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)<span class="keywordtype">string</span>& text ) <a name="l00261"></a>00261 { <a name="l00262"></a>00262 addToSortedRewriteList(programName, <span class="keyword">new</span> <a class="code" href="classTokenStreamRewriteEngine_1_1InsertBeforeOp.html">InsertBeforeOp</a>(index,text)); <a name="l00263"></a>00263 } <a name="l00264"></a>00264 <a name="l00265"></a>00265 <span class="keywordtype">void</span> replace(<span class="keywordtype">size_t</span> index, <span class="keyword">const</span> <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)<span class="keywordtype">string</span>& text) <a name="l00266"></a><a class="code" href="classTokenStreamRewriteEngine.html#a52801e65ab7ce1ba82162033c48ea1c0">00266</a> { <a name="l00267"></a>00267 <a class="code" href="classTokenStreamRewriteEngine.html#a52801e65ab7ce1ba82162033c48ea1c0">replace</a>(DEFAULT_PROGRAM_NAME, index, index, text); <a name="l00268"></a>00268 } <a name="l00269"></a>00269 <a name="l00270"></a>00270 <span class="keywordtype">void</span> replace( <span class="keywordtype">size_t</span> from, <span class="keywordtype">size_t</span> to, <a name="l00271"></a><a class="code" href="classTokenStreamRewriteEngine.html#ab97274aaff93004989f72d396e6e104c">00271</a> <span class="keyword">const</span> <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)<span class="keywordtype">string</span>& text) <a name="l00272"></a>00272 { <a name="l00273"></a>00273 <a class="code" href="classTokenStreamRewriteEngine.html#ab97274aaff93004989f72d396e6e104c">replace</a>(DEFAULT_PROGRAM_NAME, from, to, text); <a name="l00274"></a>00274 } <a name="l00275"></a>00275 <a name="l00276"></a>00276 <span class="keywordtype">void</span> replace( <a class="code" href="classTokenRefCount.html">RefTokenWithIndex</a> indexT, <a name="l00277"></a><a class="code" href="classTokenStreamRewriteEngine.html#a22164ef594f25b10214b0b3c00a22e20">00277</a> <span class="keyword">const</span> <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)<span class="keywordtype">string</span>& text ) <a name="l00278"></a>00278 { <a name="l00279"></a>00279 <a class="code" href="classTokenStreamRewriteEngine.html#a22164ef594f25b10214b0b3c00a22e20">replace</a>(DEFAULT_PROGRAM_NAME, indexT->getIndex(), indexT->getIndex(), text); <a name="l00280"></a>00280 } <a name="l00281"></a>00281 <a name="l00282"></a>00282 <span class="keywordtype">void</span> replace( <a class="code" href="classTokenRefCount.html">RefTokenWithIndex</a> from, <a name="l00283"></a><a class="code" href="classTokenStreamRewriteEngine.html#a7fe599143c749b50a7e33503f2777d02">00283</a> <a class="code" href="classTokenRefCount.html">RefTokenWithIndex</a> to, <a name="l00284"></a>00284 <span class="keyword">const</span> <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)<span class="keywordtype">string</span>& text ) <a name="l00285"></a>00285 { <a name="l00286"></a>00286 <a class="code" href="classTokenStreamRewriteEngine.html#a7fe599143c749b50a7e33503f2777d02">replace</a>(DEFAULT_PROGRAM_NAME, from, to, text); <a name="l00287"></a>00287 } <a name="l00288"></a>00288 <a name="l00289"></a>00289 <span class="keywordtype">void</span> replace(<span class="keyword">const</span> <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)<span class="keywordtype">string</span>& programName, <a name="l00290"></a><a class="code" href="classTokenStreamRewriteEngine.html#adc393f0b0bc9b4a26fc0d36c87a478ae">00290</a> <span class="keywordtype">size_t</span> from, <span class="keywordtype">size_t</span> to, <a name="l00291"></a>00291 <span class="keyword">const</span> <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)<span class="keywordtype">string</span>& text ) <a name="l00292"></a>00292 { <a name="l00293"></a>00293 addToSortedRewriteList(programName,<span class="keyword">new</span> <a class="code" href="classTokenStreamRewriteEngine_1_1ReplaceOp.html">ReplaceOp</a>(from, to, text)); <a name="l00294"></a>00294 } <a name="l00295"></a>00295 <a name="l00296"></a>00296 <span class="keywordtype">void</span> replace( <span class="keyword">const</span> <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)<span class="keywordtype">string</span>& programName, <a name="l00297"></a><a class="code" href="classTokenStreamRewriteEngine.html#ae5ae5b171432b0170eb4db6f89fdedb9">00297</a> <a class="code" href="classTokenRefCount.html">RefTokenWithIndex</a> from, <a name="l00298"></a>00298 <a class="code" href="classTokenRefCount.html">RefTokenWithIndex</a> to, <a name="l00299"></a>00299 <span class="keyword">const</span> <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)<span class="keywordtype">string</span>& text ) <a name="l00300"></a>00300 { <a name="l00301"></a>00301 <a class="code" href="classTokenStreamRewriteEngine.html#ae5ae5b171432b0170eb4db6f89fdedb9">replace</a>(programName, <a name="l00302"></a>00302 from->getIndex(), <a name="l00303"></a>00303 to->getIndex(), <a name="l00304"></a>00304 text); <a name="l00305"></a>00305 } <a name="l00306"></a>00306 <a name="l00307"></a>00307 <span class="keywordtype">void</span> <span class="keyword">remove</span>(<span class="keywordtype">size_t</span> index) { <a name="l00308"></a><a class="code" href="classTokenStreamRewriteEngine.html#ad11f8ef1a62fd2c66292e59d5a186a67">00308</a> <span class="keyword">remove</span>(DEFAULT_PROGRAM_NAME, index, index); <a name="l00309"></a>00309 } <a name="l00310"></a>00310 <a name="l00311"></a>00311 <span class="keywordtype">void</span> <span class="keyword">remove</span>(<span class="keywordtype">size_t</span> from, <span class="keywordtype">size_t</span> to) { <a name="l00312"></a><a class="code" href="classTokenStreamRewriteEngine.html#a2fb59f303a3b01088f0022f2fd252a09">00312</a> <span class="keyword">remove</span>(DEFAULT_PROGRAM_NAME, from, to); <a name="l00313"></a>00313 } <a name="l00314"></a>00314 <a name="l00315"></a>00315 <span class="keywordtype">void</span> <span class="keyword">remove</span>(<a class="code" href="classTokenRefCount.html">RefTokenWithIndex</a> indexT) { <a name="l00316"></a><a class="code" href="classTokenStreamRewriteEngine.html#a79da989a339fe32947a6c8832e9db3c0">00316</a> <span class="keyword">remove</span>(DEFAULT_PROGRAM_NAME, indexT, indexT); <a name="l00317"></a>00317 } <a name="l00318"></a>00318 <a name="l00319"></a>00319 <span class="keywordtype">void</span> <span class="keyword">remove</span>(<a class="code" href="classTokenRefCount.html">RefTokenWithIndex</a> from, <a class="code" href="classTokenRefCount.html">RefTokenWithIndex</a> to) { <a name="l00320"></a><a class="code" href="classTokenStreamRewriteEngine.html#abaf935a703ffb19e06a81df4de978836">00320</a> <span class="keyword">remove</span>(DEFAULT_PROGRAM_NAME, from, to); <a name="l00321"></a>00321 } <a name="l00322"></a>00322 <a name="l00323"></a>00323 <span class="keywordtype">void</span> <span class="keyword">remove</span>( <span class="keyword">const</span> <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)string& programName, <a name="l00324"></a><a class="code" href="classTokenStreamRewriteEngine.html#a932fb1526314fde8a36aa6685bebfa8d">00324</a> <span class="keywordtype">size_t</span> from, <span class="keywordtype">size_t</span> to) <a name="l00325"></a>00325 { <a name="l00326"></a>00326 replace(programName,from,to,<span class="stringliteral">""</span>); <a name="l00327"></a>00327 } <a name="l00328"></a>00328 <a name="l00329"></a>00329 <span class="keywordtype">void</span> <span class="keyword">remove</span>( <span class="keyword">const</span> <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)string& programName, <a name="l00330"></a><a class="code" href="classTokenStreamRewriteEngine.html#a39ba55b97c0a33bf0a5c8ced876792f6">00330</a> <a class="code" href="classTokenRefCount.html">RefTokenWithIndex</a> from, <a class="code" href="classTokenRefCount.html">RefTokenWithIndex</a> to ) <a name="l00331"></a>00331 { <a name="l00332"></a>00332 replace(programName,from,to,<span class="stringliteral">""</span>); <a name="l00333"></a>00333 } <a name="l00334"></a>00334 <a name="l00335"></a>00335 <span class="keywordtype">void</span> discard(<span class="keywordtype">int</span> ttype) { <a name="l00336"></a><a class="code" href="classTokenStreamRewriteEngine.html#a4c55f2ed1bdceb3abb49fc73cbc132a4">00336</a> discardMask.add(ttype); <a name="l00337"></a>00337 } <a name="l00338"></a>00338 <a name="l00339"></a>00339 <a class="code" href="classTokenRefCount.html">RefToken</a> getToken( <span class="keywordtype">size_t</span> i ) <a name="l00340"></a><a class="code" href="classTokenStreamRewriteEngine.html#a0a25e219ca52141d7948a8ced55382a8">00340</a> { <a name="l00341"></a>00341 <span class="keywordflow">return</span> <a class="code" href="TokenRefCount_8hpp.html#a90bf433b9f39606e6bf39757f6910ac7">RefToken</a>(tokens.at(i)); <a name="l00342"></a>00342 } <a name="l00343"></a>00343 <a name="l00344"></a>00344 <span class="keywordtype">size_t</span> getTokenStreamSize()<span class="keyword"> const </span>{ <a name="l00345"></a><a class="code" href="classTokenStreamRewriteEngine.html#a65eabea9748efba6f20c528500f5164a">00345</a> <span class="keywordflow">return</span> tokens.size(); <a name="l00346"></a>00346 } <a name="l00347"></a>00347 <a name="l00348"></a>00348 <span class="keywordtype">void</span> originalToStream( <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)ostream& out )<span class="keyword"> const </span>{ <a name="l00349"></a><a class="code" href="classTokenStreamRewriteEngine.html#a323dba8580df8e3a2916bd9051ecc9b8">00349</a> <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)for_each( tokens.begin(), tokens.end(), <a class="code" href="structTokenStreamRewriteEngine_1_1tokenToStream.html">tokenToStream</a>(out) ); <a name="l00350"></a>00350 } <a name="l00351"></a>00351 <a name="l00352"></a>00352 <span class="keywordtype">void</span> originalToStream( <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)ostream& out, <a name="l00353"></a>00353 <span class="keywordtype">size_t</span> start, <span class="keywordtype">size_t</span> end ) const; <a name="l00354"></a>00354 <a name="l00355"></a>00355 <span class="keywordtype">void</span> toStream( <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)ostream& out )<span class="keyword"> const </span>{ <a name="l00356"></a><a class="code" href="classTokenStreamRewriteEngine.html#a278ba45f59bf15090d701e0508911af8">00356</a> <a class="code" href="classTokenStreamRewriteEngine.html#a278ba45f59bf15090d701e0508911af8">toStream</a>( out, MIN_TOKEN_INDEX, getTokenStreamSize()); <a name="l00357"></a>00357 } <a name="l00358"></a>00358 <a name="l00359"></a>00359 <span class="keywordtype">void</span> toStream( <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)ostream& out, <a name="l00360"></a><a class="code" href="classTokenStreamRewriteEngine.html#a7db4fe3127228031a81da4b3c02071fc">00360</a> <span class="keyword">const</span> <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)<span class="keywordtype">string</span>& programName )<span class="keyword"> const</span> <a name="l00361"></a>00361 <span class="keyword"> </span>{ <a name="l00362"></a>00362 <a class="code" href="classTokenStreamRewriteEngine.html#a7db4fe3127228031a81da4b3c02071fc">toStream</a>( out, programName, MIN_TOKEN_INDEX, getTokenStreamSize()); <a name="l00363"></a>00363 } <a name="l00364"></a>00364 <a name="l00365"></a>00365 <span class="keywordtype">void</span> toStream( <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)ostream& out, <a name="l00366"></a><a class="code" href="classTokenStreamRewriteEngine.html#ae8742278d9a6f02dcf46a92cd496c9be">00366</a> <span class="keywordtype">size_t</span> start, <span class="keywordtype">size_t</span> end )<span class="keyword"> const</span> <a name="l00367"></a>00367 <span class="keyword"> </span>{ <a name="l00368"></a>00368 <a class="code" href="classTokenStreamRewriteEngine.html#ae8742278d9a6f02dcf46a92cd496c9be">toStream</a>(out, DEFAULT_PROGRAM_NAME, start, end); <a name="l00369"></a>00369 } <a name="l00370"></a>00370 <a name="l00371"></a>00371 <span class="keywordtype">void</span> toStream( <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)ostream& out, <a name="l00372"></a>00372 <span class="keyword">const</span> <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)<span class="keywordtype">string</span>& programName, <a name="l00373"></a>00373 <span class="keywordtype">size_t</span> firstToken, <span class="keywordtype">size_t</span> lastToken ) <span class="keyword">const</span>; <a name="l00374"></a>00374 <a name="l00375"></a>00375 <span class="keywordtype">void</span> toDebugStream( <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)ostream& out )<span class="keyword"> const </span>{ <a name="l00376"></a><a class="code" href="classTokenStreamRewriteEngine.html#a055cb441f9e48f5c64cec2b4f537dde9">00376</a> <a class="code" href="classTokenStreamRewriteEngine.html#a055cb441f9e48f5c64cec2b4f537dde9">toDebugStream</a>( out, MIN_TOKEN_INDEX, getTokenStreamSize()); <a name="l00377"></a>00377 } <a name="l00378"></a>00378 <a name="l00379"></a>00379 <span class="keywordtype">void</span> toDebugStream( <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)ostream& out, <a name="l00380"></a>00380 <span class="keywordtype">size_t</span> start, <span class="keywordtype">size_t</span> end ) <span class="keyword">const</span>; <a name="l00381"></a>00381 <a name="l00382"></a>00382 <span class="keywordtype">size_t</span> getLastRewriteTokenIndex()<span class="keyword"> const </span>{ <a name="l00383"></a><a class="code" href="classTokenStreamRewriteEngine.html#a7a2945213aa92ea1347f822320ea9031">00383</a> <span class="keywordflow">return</span> <a class="code" href="classTokenStreamRewriteEngine.html#a7a2945213aa92ea1347f822320ea9031">getLastRewriteTokenIndex</a>(DEFAULT_PROGRAM_NAME); <a name="l00384"></a>00384 } <a name="l00385"></a>00385 <a name="l00390"></a>00390 <span class="keywordtype">size_t</span> getLastRewriteTokenIndex(<span class="keyword">const</span> <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)<span class="keywordtype">string</span>& programName)<span class="keyword"> const </span>{ <a name="l00391"></a><a class="code" href="classTokenStreamRewriteEngine.html#a6ddc14cadc0ec8b2c859cfbc51ac4ef4">00391</a> program_map::const_iterator rewrites = programs.find(programName); <a name="l00392"></a>00392 <a name="l00393"></a>00393 <span class="keywordflow">if</span>( rewrites == programs.end() ) <a name="l00394"></a>00394 <span class="keywordflow">return</span> 0; <a name="l00395"></a>00395 <a name="l00396"></a>00396 <span class="keyword">const</span> <a class="code" href="classTokenStreamRewriteEngine.html#aec9eb3c1fda9f4aff0ac7b6ef9ad33d3" title="list of rewrite operations">operation_list</a>& prog = rewrites->second; <a name="l00397"></a>00397 <span class="keywordflow">if</span>( !prog.empty() ) <a name="l00398"></a>00398 { <a name="l00399"></a>00399 operation_list::const_iterator last = prog.end(); <a name="l00400"></a>00400 --last; <a name="l00401"></a>00401 <span class="keywordflow">return</span> (*last)->getIndex(); <a name="l00402"></a>00402 } <a name="l00403"></a>00403 <span class="keywordflow">return</span> 0; <a name="l00404"></a>00404 } <a name="l00405"></a>00405 <a name="l00406"></a>00406 <span class="keyword">protected</span>: <a name="l00409"></a>00409 <span class="keywordtype">void</span> addToSortedRewriteList(RewriteOperation* op) { <a name="l00410"></a><a class="code" href="classTokenStreamRewriteEngine.html#a42259e3d8b6085f1c97879e53cf3b6e2">00410</a> <a class="code" href="classTokenStreamRewriteEngine.html#a42259e3d8b6085f1c97879e53cf3b6e2">addToSortedRewriteList</a>(DEFAULT_PROGRAM_NAME, op); <a name="l00411"></a>00411 } <a name="l00412"></a>00412 <a name="l00413"></a>00413 <span class="keywordtype">void</span> addToSortedRewriteList( <span class="keyword">const</span> <a class="code" href="config_8hpp.html#ad1e4025d0db4046e6e85a46c92b7ff77">ANTLR_USE_NAMESPACE</a>(std)<span class="keywordtype">string</span>& programName, <a name="l00414"></a>00414 RewriteOperation* op ); <a name="l00415"></a>00415 <a name="l00416"></a>00416 <span class="keyword">protected</span>: <a name="l00418"></a>00418 <a class="code" href="classTokenStream.html">TokenStream</a>& stream; <a name="l00420"></a>00420 <span class="keywordtype">size_t</span> index; <a name="l00421"></a><a class="code" href="classTokenStreamRewriteEngine.html#ab1891a79ff98d85b74d134d2865fe970">00421</a> <a name="l00423"></a>00423 <a class="code" href="classTokenStreamRewriteEngine.html#a2be10b6477784e9cb704a66d9d6273e2">token_list</a> tokens; <a name="l00424"></a><a class="code" href="classTokenStreamRewriteEngine.html#a625e8a6b104e8fc3170191d94f1b3880">00424</a> <a name="l00429"></a>00429 <a class="code" href="classTokenStreamRewriteEngine.html#a6ace1ccee2524d37862c1d68a5a923c4" title="map program name to &lt;program counter,program&gt; tuple">program_map</a> programs; <a name="l00430"></a><a class="code" href="classTokenStreamRewriteEngine.html#a37061e6d6e5b89cee013dc2c89e37327">00430</a> <a name="l00432"></a>00432 <a class="code" href="classBitSet.html">BitSet</a> discardMask; <a name="l00433"></a><a class="code" href="classTokenStreamRewriteEngine.html#a468c8d088b6e1cd49e1c8a1f545b3c8c">00433</a> }; <a name="l00434"></a>00434 <a name="l00435"></a>00435 <span class="preprocessor">#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE</span> <a name="l00436"></a>00436 <span class="preprocessor"></span>} <a name="l00437"></a>00437 <span class="preprocessor">#endif</span> <a name="l00438"></a>00438 <span class="preprocessor"></span> <a name="l00439"></a>00439 <span class="preprocessor">#endif</span> </pre></div></div> </div> <!--- window showing the filter options --> <div id="MSearchSelectWindow" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> <a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark"> </span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark"> </span>Defines</a></div> <!-- iframe showing the search results (closed by default) --> <div id="MSearchResultsWindow"> <iframe src="" frameborder="0" name="MSearchResults" id="MSearchResults"> </iframe> </div> <hr class="footer"/><address class="footer"><small>Generated on Fri Mar 25 2011 for ANTLR Support Libraries 2.7.1+ by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.3 </small></address> </body> </html>