Sophie

Sophie

distrib > Mandriva > 2010.1 > x86_64 > by-pkgid > aaf33964de706a538481c929c1da6a44 > files > 5008

faust-doc-0.9.10-5mdv2010.1.x86_64.rpm

<!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>FAUST compiler: patternmatcher.hh File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.3 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="pages.html"><span>Related&nbsp;Pages</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>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
</div>
<div class="contents">
<h1>patternmatcher.hh File Reference</h1><code>#include &lt;vector&gt;</code><br/>
<code>#include &quot;<a class="el" href="tlib_8hh_source.html">tlib.hh</a>&quot;</code><br/>
<div class="dynheader">
Include dependency graph for patternmatcher.hh:</div>
<div class="dynsection">
</div>
<div class="dynheader">
This graph shows which files directly or indirectly include this file:</div>
<div class="dynsection">
</div>

<p><a href="patternmatcher_8hh_source.html">Go to the source code of this file.</a></p>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td colspan="2"><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="structAutomaton.html">Automaton</a> *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="patternmatcher_8hh.html#a81bb4084b45da5ba7e9bf6f562877543">make_pattern_matcher</a> (<a class="el" href="classCTree.html">Tree</a> R)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="patternmatcher_8hh.html#a9a0cd806f9df515fe14799df5760021b">apply_pattern_matcher</a> (<a class="el" href="structAutomaton.html">Automaton</a> *A, int s, <a class="el" href="classCTree.html">Tree</a> X, <a class="el" href="classCTree.html">Tree</a> &amp;C, vector&lt; <a class="el" href="classCTree.html">Tree</a> &gt; &amp;E)</td></tr>
</table>
<hr/><h2>Function Documentation</h2>
<a class="anchor" id="a9a0cd806f9df515fe14799df5760021b"></a><!-- doxytag: member="patternmatcher.hh::apply_pattern_matcher" ref="a9a0cd806f9df515fe14799df5760021b" args="(Automaton *A, int s, Tree X, Tree &amp;C, vector&lt; Tree &gt; &amp;E)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int apply_pattern_matcher </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structAutomaton.html">Automaton</a> *&nbsp;</td>
          <td class="paramname"> <em>A</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>s</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classCTree.html">Tree</a>&nbsp;</td>
          <td class="paramname"> <em>X</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classCTree.html">Tree</a> &amp;&nbsp;</td>
          <td class="paramname"> <em>C</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">vector&lt; <a class="el" href="classCTree.html">Tree</a> &gt; &amp;&nbsp;</td>
          <td class="paramname"> <em>E</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Definition at line <a class="el" href="patternmatcher_8cpp_source.html#l00660">660</a> of file <a class="el" href="patternmatcher_8cpp_source.html">patternmatcher.cpp</a>.</p>

<p>References <a class="el" href="patternmatcher_8cpp_source.html#l00593">apply_pattern_matcher_internal()</a>, <a class="el" href="boxes_8cpp_source.html#l00214">boxError()</a>, <a class="el" href="boxes_8cpp_source.html#l00204">closure()</a>, <a class="el" href="patternmatcher_8cpp_source.html#l00200">Automaton::final()</a>, <a class="el" href="boxes_8cpp_source.html#l00219">isBoxError()</a>, <a class="el" href="patternmatcher_8cpp_source.html#l00194">Automaton::n_rules()</a>, <a class="el" href="list_8cpp_source.html#l00116">nil</a>, <a class="el" href="eval_8cpp_source.html#l01189">pushValueDef()</a>, <a class="el" href="patternmatcher_8cpp_source.html#l00189">Automaton::rhs</a>, <a class="el" href="patternmatcher_8cpp_source.html#l00196">Automaton::rules()</a>, <a class="el" href="eval_8cpp_source.html#l01229">searchIdDef()</a>, <a class="el" href="Text_8cpp_source.html#l00060">subst()</a>, and <a class="el" href="patternmatcher_8cpp_source.html#l00062">subtree()</a>.</p>

<p>Referenced by <a class="el" href="eval_8cpp_source.html#l00974">applyList()</a>, and <a class="el" href="patternmatcher_8cpp_source.html#l00479">make_pattern_matcher()</a>.</p>

<p><div class="fragment"><pre class="fragment"><a name="l00665"></a>00665 {
<a name="l00666"></a>00666   <span class="keywordtype">int</span> n = A-&gt;<a class="code" href="structAutomaton.html#ac244771866c62c3bbca1ec5201d5ed54">n_rules</a>();
<a name="l00667"></a>00667   vector&lt;Subst&gt; <a class="code" href="Text_8cpp.html#af50e951c134c2c98c4c75d687f8fca7a">subst</a>(n, <a class="code" href="patternmatcher_8cpp.html#a67cf4bdbfb11718a7a1b859dcb7195af">Subst</a>());
<a name="l00668"></a>00668   <span class="comment">/* perform matching, record variable substitutions */</span>
<a name="l00669"></a>00669 <span class="preprocessor">#ifdef DEBUG</span>
<a name="l00670"></a>00670 <span class="preprocessor"></span>  cout &lt;&lt; <span class="stringliteral">&quot;automaton &quot;</span> &lt;&lt; A &lt;&lt; <span class="stringliteral">&quot;, state &quot;</span> &lt;&lt; s &lt;&lt; <span class="stringliteral">&quot;, start match on arg: &quot;</span> &lt;&lt; *X &lt;&lt; endl;
<a name="l00671"></a>00671 <span class="preprocessor">#endif</span>
<a name="l00672"></a>00672 <span class="preprocessor"></span>  s = <a class="code" href="patternmatcher_8cpp.html#a7d18b0f8abb16b7a412e8a1cc8608052">apply_pattern_matcher_internal</a>(A, s, X, <a class="code" href="Text_8cpp.html#af50e951c134c2c98c4c75d687f8fca7a">subst</a>);
<a name="l00673"></a>00673   C = <a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>;
<a name="l00674"></a>00674   <span class="keywordflow">if</span> (s &lt; 0)
<a name="l00675"></a>00675     <span class="comment">/* failed match */</span>
<a name="l00676"></a>00676     <span class="keywordflow">return</span> s;
<a name="l00677"></a>00677   <span class="comment">/* process variable substitutions */</span>
<a name="l00678"></a>00678   list&lt;Rule&gt;::const_iterator r;
<a name="l00679"></a>00679   <span class="keywordflow">for</span> (r = A-&gt;<a class="code" href="structAutomaton.html#adb969b0985e71dd5415ed70369b937f4">rules</a>(s).begin(); r != A-&gt;<a class="code" href="structAutomaton.html#adb969b0985e71dd5415ed70369b937f4">rules</a>(s).end(); r++) {
<a name="l00680"></a>00680     <span class="comment">// all rules still active in state s</span>
<a name="l00681"></a>00681     <span class="keywordflow">if</span> (!<a class="code" href="boxes_8cpp.html#a0f492ef7453000e0b40455ac32bd76d4">isBoxError</a>(E[r-&gt;r])) { <span class="comment">// and still viable</span>
<a name="l00682"></a>00682       Subst::const_iterator assoc;
<a name="l00683"></a>00683       <span class="keywordflow">for</span> (assoc = <a class="code" href="Text_8cpp.html#af50e951c134c2c98c4c75d687f8fca7a">subst</a>[r-&gt;r].begin(); assoc != <a class="code" href="Text_8cpp.html#af50e951c134c2c98c4c75d687f8fca7a">subst</a>[r-&gt;r].end(); assoc++) {
<a name="l00684"></a>00684     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> Z, Z1 = <a class="code" href="patternmatcher_8cpp.html#abf5fce930015999bd6e95513ee9aee2a">subtree</a>(X, 0, assoc-&gt;p);
<a name="l00685"></a>00685     <span class="keywordflow">if</span> (<a class="code" href="eval_8cpp.html#adf6ba37a28536372e3be65128c79e615" title="Search the environment for the definition of a symbol ID and return it.">searchIdDef</a>(assoc-&gt;id, Z, E[r-&gt;r])) {
<a name="l00686"></a>00686       <span class="keywordflow">if</span> (Z != Z1) {
<a name="l00687"></a>00687         <span class="comment">/* failed nonlinearity, add to the set of nonviable rules */</span>
<a name="l00688"></a>00688 <span class="preprocessor">#ifdef DEBUG</span>
<a name="l00689"></a>00689 <span class="preprocessor"></span>      cout &lt;&lt; <span class="stringliteral">&quot;state &quot;</span> &lt;&lt; s &lt;&lt; <span class="stringliteral">&quot;, rule #&quot;</span> &lt;&lt; r-&gt;r &lt;&lt; <span class="stringliteral">&quot;: &quot;</span> &lt;&lt;
<a name="l00690"></a>00690         *assoc-&gt;id &lt;&lt; <span class="stringliteral">&quot; := &quot;</span> &lt;&lt; *Z1 &lt;&lt; <span class="stringliteral">&quot; *** failed *** old value: &quot;</span> &lt;&lt;
<a name="l00691"></a>00691         *Z &lt;&lt; endl;
<a name="l00692"></a>00692 <span class="preprocessor">#endif</span>
<a name="l00693"></a>00693 <span class="preprocessor"></span>        E[r-&gt;r] = <a class="code" href="boxes_8cpp.html#ab4f4d00d6bc173a3c9d20cd7054ffdb7">boxError</a>();
<a name="l00694"></a>00694       }
<a name="l00695"></a>00695     } <span class="keywordflow">else</span> {
<a name="l00696"></a>00696       <span class="comment">/* bind a variable for the current rule */</span>
<a name="l00697"></a>00697 <span class="preprocessor">#ifdef DEBUG</span>
<a name="l00698"></a>00698 <span class="preprocessor"></span>      cout &lt;&lt; <span class="stringliteral">&quot;state &quot;</span> &lt;&lt; s &lt;&lt; <span class="stringliteral">&quot;, rule #&quot;</span> &lt;&lt; r-&gt;r &lt;&lt; <span class="stringliteral">&quot;: &quot;</span> &lt;&lt;
<a name="l00699"></a>00699         *assoc-&gt;id &lt;&lt; <span class="stringliteral">&quot; := &quot;</span> &lt;&lt; *Z1 &lt;&lt; endl;
<a name="l00700"></a>00700 <span class="preprocessor">#endif</span>
<a name="l00701"></a>00701 <span class="preprocessor"></span>      E[r-&gt;r] = <a class="code" href="eval_8cpp.html#ad057f174a67a40fd689fc379a5a21c2d" title="Push a new layer and add a single definition.">pushValueDef</a>(assoc-&gt;id, Z1, E[r-&gt;r]);
<a name="l00702"></a>00702     }
<a name="l00703"></a>00703       }
<a name="l00704"></a>00704     }
<a name="l00705"></a>00705   }
<a name="l00706"></a>00706   <span class="keywordflow">if</span> (A-&gt;<a class="code" href="structAutomaton.html#a92020994f3a89b85ac0f8f6ccd3273ff">final</a>(s)) {
<a name="l00707"></a>00707     <span class="comment">/* if in a final state then return the right-hand side together with the</span>
<a name="l00708"></a>00708 <span class="comment">       corresponding variable environment */</span>
<a name="l00709"></a>00709     <span class="keywordflow">for</span> (r = A-&gt;<a class="code" href="structAutomaton.html#adb969b0985e71dd5415ed70369b937f4">rules</a>(s).begin(); r != A-&gt;<a class="code" href="structAutomaton.html#adb969b0985e71dd5415ed70369b937f4">rules</a>(s).end(); r++) <span class="comment">// all rules matched in state s</span>
<a name="l00710"></a>00710       <span class="keywordflow">if</span> (!<a class="code" href="boxes_8cpp.html#a0f492ef7453000e0b40455ac32bd76d4">isBoxError</a>(E[r-&gt;r])) { <span class="comment">// and still viable</span>
<a name="l00711"></a>00711     <span class="comment">/* return the rhs of the matched rule */</span>
<a name="l00712"></a>00712     C = <a class="code" href="boxes_8cpp.html#a321a193061eae875a5a8763bfd992f38">closure</a>(A-&gt;<a class="code" href="structAutomaton.html#a11d18ab1675e9d32433e799a2b20d26e">rhs</a>[r-&gt;r], <a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>, <a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>, E[r-&gt;r]);
<a name="l00713"></a>00713 <span class="preprocessor">#ifdef DEBUG</span>
<a name="l00714"></a>00714 <span class="preprocessor"></span>    cout &lt;&lt; <span class="stringliteral">&quot;state &quot;</span> &lt;&lt; s &lt;&lt; <span class="stringliteral">&quot;, complete match yields rhs #&quot;</span> &lt;&lt; r-&gt;r &lt;&lt;
<a name="l00715"></a>00715       <span class="stringliteral">&quot;: &quot;</span> &lt;&lt; *A-&gt;<a class="code" href="structAutomaton.html#a11d18ab1675e9d32433e799a2b20d26e">rhs</a>[r-&gt;r] &lt;&lt; endl;
<a name="l00716"></a>00716 <span class="preprocessor">#endif</span>
<a name="l00717"></a>00717 <span class="preprocessor"></span>    <span class="keywordflow">return</span> s;
<a name="l00718"></a>00718       }
<a name="l00719"></a>00719     <span class="comment">/* if none of the rules were matched then declare a failed match */</span>
<a name="l00720"></a>00720 <span class="preprocessor">#ifdef DEBUG</span>
<a name="l00721"></a>00721 <span class="preprocessor"></span>    cout &lt;&lt; <span class="stringliteral">&quot;state &quot;</span> &lt;&lt; s &lt;&lt; <span class="stringliteral">&quot;, *** match failed ***&quot;</span> &lt;&lt; endl;
<a name="l00722"></a>00722 <span class="preprocessor">#endif</span>
<a name="l00723"></a>00723 <span class="preprocessor"></span>    <span class="keywordflow">return</span> -1;
<a name="l00724"></a>00724   }
<a name="l00725"></a>00725 <span class="preprocessor">#ifdef DEBUG</span>
<a name="l00726"></a>00726 <span class="preprocessor"></span>  cout &lt;&lt; <span class="stringliteral">&quot;state &quot;</span> &lt;&lt; s &lt;&lt; <span class="stringliteral">&quot;, successful incomplete match&quot;</span> &lt;&lt; endl;
<a name="l00727"></a>00727 <span class="preprocessor">#endif</span>
<a name="l00728"></a>00728 <span class="preprocessor"></span>  <span class="keywordflow">return</span> s;
<a name="l00729"></a>00729 }
</pre></div></p>

<p><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dynsection">
</div>
</p>

<p><div class="dynheader">
Here is the caller graph for this function:</div>
<div class="dynsection">
</div>
</p>

</div>
</div>
<a class="anchor" id="a81bb4084b45da5ba7e9bf6f562877543"></a><!-- doxytag: member="patternmatcher.hh::make_pattern_matcher" ref="a81bb4084b45da5ba7e9bf6f562877543" args="(Tree R)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="structAutomaton.html">Automaton</a>* make_pattern_matcher </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classCTree.html">Tree</a>&nbsp;</td>
          <td class="paramname"> <em>R</em></td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Definition at line <a class="el" href="patternmatcher_8cpp_source.html#l00479">479</a> of file <a class="el" href="patternmatcher_8cpp_source.html">patternmatcher.cpp</a>.</p>

<p>References <a class="el" href="patternmatcher_8cpp_source.html#l00660">apply_pattern_matcher()</a>, <a class="el" href="patternmatcher_8cpp_source.html#l00211">Automaton::build()</a>, <a class="el" href="patternmatcher_8cpp_source.html#l00200">Automaton::final()</a>, <a class="el" href="boxes_8cpp_source.html#l00219">isBoxError()</a>, <a class="el" href="patternmatcher_8cpp_source.html#l00025">isCons()</a>, <a class="el" href="list_8cpp_source.html#l00198">len()</a>, <a class="el" href="patternmatcher_8cpp_source.html#l00300">make_state()</a>, <a class="el" href="patternmatcher_8cpp_source.html#l00470">merge_state()</a>, <a class="el" href="list_8cpp_source.html#l00116">nil</a>, <a class="el" href="list_8cpp_source.html#l00240">reverse()</a>, <a class="el" href="patternmatcher_8cpp_source.html#l00189">Automaton::rhs</a>, <a class="el" href="patternmatcher_8cpp_source.html#l00196">Automaton::rules()</a>, and <a class="el" href="patternmatcher_8cpp_source.html#l00136">State::rules</a>.</p>

<p>Referenced by <a class="el" href="eval_8cpp_source.html#l01321">evalCase()</a>.</p>

<p><div class="fragment"><pre class="fragment"><a name="l00482"></a>00482           :
<a name="l00483"></a>00483 
<a name="l00484"></a>00484    Rules    ::= <a class="code" href="list_8hh.html#ae1ed153946fcfc025009c6d9c9c40bee">cons</a> <a class="code" href="structRule.html">Rule</a> (<a class="code" href="list_8hh.html#ae1ed153946fcfc025009c6d9c9c40bee">cons</a> <a class="code" href="structRule.html">Rule</a> ... <a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>)
<a name="l00485"></a>00485    <a class="code" href="structRule.html">Rule</a>     ::= <a class="code" href="list_8hh.html#ae1ed153946fcfc025009c6d9c9c40bee">cons</a> Lhs Rhs
<a name="l00486"></a>00486    Lhs      ::= <a class="code" href="list_8hh.html#ae1ed153946fcfc025009c6d9c9c40bee">cons</a> Pattern (<a class="code" href="list_8hh.html#ae1ed153946fcfc025009c6d9c9c40bee">cons</a> Pattern ... <a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>)
<a name="l00487"></a>00487    Pattern  ::= <a class="code" href="tree_8hh.html#a550445c18f13907b563fa164d2aa5c4e">Tree</a> (parameter pattern)
<a name="l00488"></a>00488    Rhs      ::= <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>
<a name="l00489"></a>00489 
<a name="l00490"></a>00490    NOTE: The lists of rules and patterns are actually delivered in <a class="code" href="list_8cpp.html#a8e15f8d6fcc6cd319059c2e0544145bb">reverse</a>
<a name="l00491"></a>00491    order by the parser, so we have to <a class="code" href="list_8cpp.html#a8e15f8d6fcc6cd319059c2e0544145bb">reverse</a> them on the fly. */
<a name="l00492"></a>00492 {
<a name="l00493"></a>00493   <a class="code" href="structAutomaton.html">Automaton</a> *A = <span class="keyword">new</span> <a class="code" href="structAutomaton.html">Automaton</a>;
<a name="l00494"></a>00494   <span class="keywordtype">int</span> n = <a class="code" href="list_8cpp.html#a0b58ea1a5d8649e8afb0f70c48776347">len</a>(R), r = n;
<a name="l00495"></a>00495   <a class="code" href="structState.html">State</a> *start = <span class="keyword">new</span> <a class="code" href="structState.html">State</a>;
<a name="l00496"></a>00496   <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> rule, rest;
<a name="l00497"></a>00497   vector&lt;Tree&gt; rules(n, (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>)NULL);
<a name="l00498"></a>00498   vector&lt; vector&lt;Tree&gt; &gt; testpats(n);
<a name="l00499"></a>00499   <span class="keywordflow">while</span> (<a class="code" href="patternmatcher_8cpp.html#a50ea341d53b07dacd749c6bd25d57452">isCons</a>(R, rule, rest)) {
<a name="l00500"></a>00500     rules[--r] = rule;
<a name="l00501"></a>00501     R = rest;
<a name="l00502"></a>00502   }
<a name="l00503"></a>00503   <span class="keywordflow">for</span> (r = 0; r &lt; n; r++) {
<a name="l00504"></a>00504     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> lhs, rhs;
<a name="l00505"></a>00505     <span class="keywordflow">if</span> (<a class="code" href="patternmatcher_8cpp.html#a50ea341d53b07dacd749c6bd25d57452">isCons</a>(rules[r], lhs, rhs)) {
<a name="l00506"></a>00506       <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> pat, rest;
<a name="l00507"></a>00507       <span class="keywordtype">int</span> m = <a class="code" href="list_8cpp.html#a0b58ea1a5d8649e8afb0f70c48776347">len</a>(lhs), i = m;
<a name="l00508"></a>00508       vector&lt;Tree&gt; pats(<a class="code" href="list_8cpp.html#a0b58ea1a5d8649e8afb0f70c48776347">len</a>(lhs), (<a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a>)NULL);
<a name="l00509"></a>00509       <a class="code" href="structState.html">State</a> *state0 = <span class="keyword">new</span> <a class="code" href="structState.html">State</a>, *state = state0;
<a name="l00510"></a>00510       A-&gt;<a class="code" href="structAutomaton.html#a11d18ab1675e9d32433e799a2b20d26e">rhs</a>.push_back(rhs);
<a name="l00511"></a>00511       <span class="keywordflow">while</span> (<a class="code" href="patternmatcher_8cpp.html#a50ea341d53b07dacd749c6bd25d57452">isCons</a>(lhs, pat, rest)) {
<a name="l00512"></a>00512     pats[--i] = pat;
<a name="l00513"></a>00513     lhs = rest;
<a name="l00514"></a>00514       }
<a name="l00515"></a>00515       testpats[r] = pats;
<a name="l00516"></a>00516       <span class="keywordflow">for</span> (i = 0; i &lt; m; i++) {
<a name="l00517"></a>00517     <a class="code" href="patternmatcher_8cpp.html#a9d962b10c8fdb6619915dd0807f8fcec">Path</a> p;
<a name="l00518"></a>00518     state = <a class="code" href="patternmatcher_8cpp.html#a32860dbb992bf1f234543c6a4da4c2bb">make_state</a>(state, r, pats[i], p);
<a name="l00519"></a>00519       }
<a name="l00520"></a>00520       <a class="code" href="structRule.html">Rule</a> rule(r, NULL);
<a name="l00521"></a>00521       state-&gt;<a class="code" href="structState.html#a5016f714ddfc2dc5890cbb949b7c2c70">rules</a>.push_back(rule);
<a name="l00522"></a>00522       <a class="code" href="patternmatcher_8cpp.html#abd7baff1fa736df511b4e584faf9b94c">merge_state</a>(start, state0);
<a name="l00523"></a>00523       <span class="keyword">delete</span> state0;
<a name="l00524"></a>00524     }
<a name="l00525"></a>00525   }
<a name="l00526"></a>00526   A-&gt;<a class="code" href="structAutomaton.html#a3305f434c8c0e6b2d3e446da7cd4ec74">build</a>(start);
<a name="l00527"></a>00527   <span class="comment">/* Check for shadowed rules. Note that because of potential nonlinearities</span>
<a name="l00528"></a>00528 <span class="comment">     it is *not* enough to just check the rule lists of final states and</span>
<a name="l00529"></a>00529 <span class="comment">     determine whether they have multiple matched rules. */</span>
<a name="l00530"></a>00530   <span class="keywordflow">for</span> (r = 0; r &lt; n; r++) {
<a name="l00531"></a>00531     <span class="keywordtype">int</span> s = 0, m = testpats[r].size();
<a name="l00532"></a>00532     <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> C;
<a name="l00533"></a>00533     vector&lt;Tree&gt; E(n, <a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>);
<a name="l00534"></a>00534     <span class="comment">/* try to match the lhs of rule #r */</span>
<a name="l00535"></a>00535     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; m; i++) {
<a name="l00536"></a>00536       s = <a class="code" href="patternmatcher_8cpp.html#a9a0cd806f9df515fe14799df5760021b">apply_pattern_matcher</a>(A, s, testpats[r][i], C, E);
<a name="l00537"></a>00537       <span class="keywordflow">if</span> (s &lt; 0) <span class="keywordflow">break</span>;
<a name="l00538"></a>00538     }
<a name="l00539"></a>00539     <span class="keywordflow">if</span> (A-&gt;<a class="code" href="structAutomaton.html#a92020994f3a89b85ac0f8f6ccd3273ff">final</a>(s)) {
<a name="l00540"></a>00540       list&lt;Rule&gt;::const_iterator ru;
<a name="l00541"></a>00541       <span class="keywordflow">for</span> (ru = A-&gt;<a class="code" href="structAutomaton.html#adb969b0985e71dd5415ed70369b937f4">rules</a>(s).begin(); ru != A-&gt;<a class="code" href="structAutomaton.html#adb969b0985e71dd5415ed70369b937f4">rules</a>(s).end(); ru++)
<a name="l00542"></a>00542     <span class="keywordflow">if</span> (!<a class="code" href="boxes_8cpp.html#a0f492ef7453000e0b40455ac32bd76d4">isBoxError</a>(E[ru-&gt;r]))
<a name="l00543"></a>00543       <span class="keywordflow">if</span> (ru-&gt;r &lt; r) {
<a name="l00544"></a>00544         <span class="comment">/* Lhs of rule #r matched a higher-priority rule, so rule #r may</span>
<a name="l00545"></a>00545 <span class="comment">           be shadowed. */</span>
<a name="l00546"></a>00546         <a class="code" href="classCTree.html" title="A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches...">Tree</a> lhs1, rhs1, lhs2, rhs2;
<a name="l00547"></a>00547         <span class="keywordflow">if</span> (<a class="code" href="patternmatcher_8cpp.html#a50ea341d53b07dacd749c6bd25d57452">isCons</a>(rules[ru-&gt;r], lhs1, rhs1) &amp;&amp;  <a class="code" href="patternmatcher_8cpp.html#a50ea341d53b07dacd749c6bd25d57452">isCons</a>(rules[r], lhs2, rhs2)) {
<a name="l00548"></a>00548             cerr    &lt;&lt; <span class="stringliteral">&quot;WARNING : shadowed pattern-matching rule: &quot;</span>
<a name="l00549"></a>00549                 &lt;&lt; <a class="code" href="classboxpp.html">boxpp</a>(<a class="code" href="list_8cpp.html#a8e15f8d6fcc6cd319059c2e0544145bb">reverse</a>(lhs2)) &lt;&lt; <span class="stringliteral">&quot; =&gt; &quot;</span> &lt;&lt; <a class="code" href="classboxpp.html">boxpp</a>(rhs2) &lt;&lt; <span class="stringliteral">&quot;;&quot;</span>
<a name="l00550"></a>00550                 &lt;&lt; <span class="stringliteral">&quot; previous rule was: &quot;</span> 
<a name="l00551"></a>00551                 &lt;&lt; <a class="code" href="classboxpp.html">boxpp</a>(<a class="code" href="list_8cpp.html#a8e15f8d6fcc6cd319059c2e0544145bb">reverse</a>(lhs1)) &lt;&lt; <span class="stringliteral">&quot; =&gt; &quot;</span> &lt;&lt; <a class="code" href="classboxpp.html">boxpp</a>(rhs1) &lt;&lt; <span class="stringliteral">&quot;;&quot;</span>
<a name="l00552"></a>00552                 &lt;&lt; endl;
<a name="l00553"></a>00553         } <span class="keywordflow">else</span> {
<a name="l00554"></a>00554             cerr &lt;&lt; <span class="stringliteral">&quot;INTERNAL ERROR : &quot;</span> &lt;&lt; __FILE__ &lt;&lt; <span class="stringliteral">&quot;:&quot;</span> &lt;&lt; __LINE__ &lt;&lt; endl;
<a name="l00555"></a>00555             exit(1);
<a name="l00556"></a>00556         }
<a name="l00557"></a>00557       } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ru-&gt;r &gt;= r)
<a name="l00558"></a>00558         <span class="keywordflow">break</span>;
<a name="l00559"></a>00559     }
<a name="l00560"></a>00560   }
<a name="l00561"></a>00561 <span class="preprocessor">#ifdef DEBUG</span>
<a name="l00562"></a>00562 <span class="preprocessor"></span>  cout &lt;&lt; <span class="stringliteral">&quot;automaton &quot;</span> &lt;&lt; A &lt;&lt; endl &lt;&lt; *A &lt;&lt; <span class="stringliteral">&quot;end automaton&quot;</span> &lt;&lt; endl;
<a name="l00563"></a>00563 <span class="preprocessor">#endif</span>
<a name="l00564"></a>00564 <span class="preprocessor"></span>  <span class="keywordflow">return</span> A;
}
</pre></div></p>

<p><div class="dynheader">
Here is the call graph for this function:</div>
<div class="dynsection">
</div>
</p>

<p><div class="dynheader">
Here is the caller graph for this function:</div>
<div class="dynsection">
</div>
</p>

</div>
</div>
</div>
<hr class="footer"/><address style="text-align: right;"><small>Generated on Thu Apr 29 00:00:09 2010 for FAUST compiler by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address>
</body>
</html>