Sophie

Sophie

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

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: sourcereader.cpp Source File</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>
<h1>sourcereader.cpp</h1><a href="sourcereader_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment">    sourcereader : Faust source file reader</span>
<a name="l00003"></a>00003 <span class="comment">    </span>
<a name="l00004"></a>00004 <span class="comment">    This component is in charge of mapping filenames to </span>
<a name="l00005"></a>00005 <span class="comment">    the list of faust definitions they contain.</span>
<a name="l00006"></a>00006 <span class="comment">    </span>
<a name="l00007"></a>00007 <span class="comment">*/</span>
<a name="l00008"></a>00008 <span class="preprocessor">#include &lt;iostream&gt;</span>
<a name="l00009"></a>00009 <span class="preprocessor">#include &lt;map&gt;</span>
<a name="l00010"></a>00010 <span class="preprocessor">#include &lt;list&gt;</span>
<a name="l00011"></a>00011 <span class="preprocessor">#include &lt;string&gt;</span>
<a name="l00012"></a>00012 
<a name="l00013"></a>00013 
<a name="l00014"></a>00014 <span class="preprocessor">#include &quot;<a class="code" href="sourcereader_8hh.html">sourcereader.hh</a>&quot;</span>
<a name="l00015"></a>00015 <span class="preprocessor">#include &quot;<a class="code" href="enrobage_8hh.html">enrobage.hh</a>&quot;</span>
<a name="l00016"></a>00016 <span class="preprocessor">#include &quot;<a class="code" href="ppbox_8hh.html">ppbox.hh</a>&quot;</span>
<a name="l00017"></a>00017 
<a name="l00018"></a>00018 <span class="keyword">using namespace </span>std;
<a name="l00019"></a>00019 
<a name="l00020"></a>00020 <span class="keyword">extern</span> map&lt;Tree, set&lt;Tree&gt; &gt; <a class="code" href="doc_8cpp.html#aaf647729deae314d35817ccb36f088e4">gMetaDataSet</a>;
<a name="l00021"></a>00021 <span class="keyword">extern</span> <span class="keywordtype">string</span> <a class="code" href="doc_8cpp.html#a1c0fac9c77fcd7f4e21daf398e9830de">gMasterDocument</a>;
<a name="l00022"></a>00022 <span class="keyword">extern</span> vector&lt;Tree&gt; <a class="code" href="doc_8cpp.html#a7c306e8c82617863fda51d2c1158f5ab" title="Contains &amp;lt;mdoc&amp;gt; parsed trees: DOCTXT, DOCEQN, DOCDGM.">gDocVector</a>;
<a name="l00023"></a>00023 <span class="keyword">extern</span> <span class="keywordtype">bool</span> <a class="code" href="main_8cpp.html#a232019c7c8d19c2297386944419f66d2">gLatexDocSwitch</a>;
<a name="l00024"></a>00024 
<a name="l00025"></a>00025 <span class="comment">/****************************************************************</span>
<a name="l00026"></a>00026 <span class="comment">                        Parser variables</span>
<a name="l00027"></a>00027 <span class="comment">*****************************************************************/</span>
<a name="l00028"></a>00028 
<a name="l00029"></a>00029 
<a name="l00030"></a>00030 <span class="keywordtype">int</span> <a class="code" href="main_8cpp.html#acd8617a8f2ac0de8bc1cc032cf449e19">yyparse</a>();
<a name="l00031"></a>00031 
<a name="l00032"></a>00032 <span class="keyword">extern</span> <span class="keywordtype">int</span>      <a class="code" href="main_8cpp.html#a22b78670f95f7470a7b16ec70f68c918">yyerr</a>;
<a name="l00033"></a>00033 <span class="keyword">extern</span> <span class="keywordtype">int</span>      <a class="code" href="main_8cpp.html#ab138aa8e11f58bcdcc7134adf240ea8c">yydebug</a>;
<a name="l00034"></a>00034 <span class="keyword">extern</span> FILE*    <a class="code" href="main_8cpp.html#a87a127afa8f6c307fbfba10390675406">yyin</a>;
<a name="l00035"></a>00035 <span class="keyword">extern</span> <span class="keywordtype">int</span>      <a class="code" href="errormsg_8hh.html#a5e36364965360da7b7cdfc2188e0af84">yylineno</a>;
<a name="l00036"></a>00036 <span class="keyword">extern</span> <span class="keyword">const</span> <span class="keywordtype">char</span> * <a class="code" href="errormsg_8cpp.html#a9500354f82b09216c6c22f5e11e3ea90">yyfilename</a>;
<a name="l00037"></a>00037 
<a name="l00038"></a>00038 <span class="keyword">extern</span> <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 class="code" href="main_8cpp.html#ae03dedba3e2f093ff36261c5c37b576c">gResult</a>;
<a name="l00039"></a>00039 <span class="keyword">extern</span> <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 class="code" href="main_8cpp.html#ac9117773cdede043e83f4b32404999b0">gResult2</a>;
<a name="l00040"></a>00040 
<a name="l00041"></a>00041  
<a name="l00042"></a>00042 
<a name="l00043"></a>00043 
<a name="l00052"></a><a class="code" href="sourcereader_8cpp.html#ae249f286a34bd52298dd5a9c7c0d8409">00052</a> <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="sourcereader_8cpp.html#ae249f286a34bd52298dd5a9c7c0d8409" title="Checks an argument list for containing only standard identifiers, no patterns and...">standardArgList</a>(<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> args)
<a name="l00053"></a>00053 {
<a name="l00054"></a>00054     map&lt;Tree,int&gt;   L;
<a name="l00055"></a>00055     <span class="keywordflow">while</span> (<a class="code" href="list_8hh.html#a8bdd73641276e0c0f999f504348eacc1">isList</a>(args)) {
<a name="l00056"></a>00056         <span class="keywordflow">if</span> (!<a class="code" href="boxes_8cpp.html#a15452e8c3476a87963f8a52cb1e905db">isBoxIdent</a>(<a class="code" href="list_8hh.html#a067ad6f83087b420a1c44e48e56be389">hd</a>(args))) <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00057"></a>00057         <span class="keywordflow">if</span> (++L[<a class="code" href="list_8hh.html#a067ad6f83087b420a1c44e48e56be389">hd</a>(args)] &gt; 1) <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00058"></a>00058         args = <a class="code" href="list_8hh.html#a4075748f5c7156306ec898795313a2e0">tl</a>(args);
<a name="l00059"></a>00059     }
<a name="l00060"></a>00060     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00061"></a>00061 }
<a name="l00062"></a>00062 
<a name="l00063"></a>00063 
<a name="l00064"></a><a class="code" href="sourcereader_8cpp.html#aa86500dcc61306ee7f28562d4ee823d0">00064</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="sourcereader_8cpp.html#aa86500dcc61306ee7f28562d4ee823d0">printPatternError</a>(<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, <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> rhs1, <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> lhs2, <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> rhs2)
<a name="l00065"></a>00065 {
<a name="l00066"></a>00066     cerr    &lt;&lt; <span class="stringliteral">&quot;ERROR : inconsistent number of parameters in pattern-matching rule: &quot;</span>
<a name="l00067"></a>00067             &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="l00068"></a>00068             &lt;&lt; <span class="stringliteral">&quot; previous rule was: &quot;</span> 
<a name="l00069"></a>00069             &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="l00070"></a>00070             &lt;&lt; endl;
<a name="l00071"></a>00071 }
<a name="l00072"></a>00072 
<a name="l00073"></a><a class="code" href="sourcereader_8hh.html#ae20e569ace063f690a6649fd3583dc17">00073</a> <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 class="code" href="sourcereader_8cpp.html#a4486672428ae166d8426da654feeb466">checkRulelist</a> (<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> lr)
<a name="l00074"></a>00074 {
<a name="l00075"></a>00075     <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> lrules = lr;
<a name="l00076"></a>00076     <span class="keywordflow">if</span> (<a class="code" href="list_8hh.html#a2569c3a07bbbfa55e0afde62de62aeec">isNil</a>(lrules)) { cerr &lt;&lt; <span class="stringliteral">&quot;ERROR : a case expression can&#39;t be empty&quot;</span> &lt;&lt; endl; exit(1); }
<a name="l00077"></a>00077     <span class="comment">// first pattern used as a reference</span>
<a name="l00078"></a>00078     <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 = <a class="code" href="list_8hh.html#a067ad6f83087b420a1c44e48e56be389">hd</a>(<a class="code" href="list_8hh.html#a067ad6f83087b420a1c44e48e56be389">hd</a>(lrules));
<a name="l00079"></a>00079     <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> rhs1 = <a class="code" href="list_8hh.html#a4075748f5c7156306ec898795313a2e0">tl</a>(<a class="code" href="list_8hh.html#a067ad6f83087b420a1c44e48e56be389">hd</a>(lrules));
<a name="l00080"></a>00080     <span class="keywordtype">int</span> npat = <a class="code" href="list_8cpp.html#a0b58ea1a5d8649e8afb0f70c48776347">len</a>(lhs1); 
<a name="l00081"></a>00081     lrules = <a class="code" href="list_8hh.html#a4075748f5c7156306ec898795313a2e0">tl</a>(lrules);
<a name="l00082"></a>00082     <span class="keywordflow">while</span> (! <a class="code" href="list_8hh.html#a2569c3a07bbbfa55e0afde62de62aeec">isNil</a>(lrules)) {
<a name="l00083"></a>00083         <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> lhs2 = <a class="code" href="list_8hh.html#a067ad6f83087b420a1c44e48e56be389">hd</a>(<a class="code" href="list_8hh.html#a067ad6f83087b420a1c44e48e56be389">hd</a>(lrules));
<a name="l00084"></a>00084         <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> rhs2 = <a class="code" href="list_8hh.html#a4075748f5c7156306ec898795313a2e0">tl</a>(<a class="code" href="list_8hh.html#a067ad6f83087b420a1c44e48e56be389">hd</a>(lrules));
<a name="l00085"></a>00085         <span class="keywordflow">if</span> (npat != <a class="code" href="list_8cpp.html#a0b58ea1a5d8649e8afb0f70c48776347">len</a>(lhs2)) {
<a name="l00086"></a>00086             <a class="code" href="sourcereader_8cpp.html#aa86500dcc61306ee7f28562d4ee823d0">printPatternError</a>(lhs1,rhs1,lhs2,rhs2);
<a name="l00087"></a>00087             exit(1);
<a name="l00088"></a>00088         }
<a name="l00089"></a>00089         
<a name="l00090"></a>00090         lhs1 = lhs2;
<a name="l00091"></a>00091         rhs1 = rhs2;
<a name="l00092"></a>00092         lrules = <a class="code" href="list_8hh.html#a4075748f5c7156306ec898795313a2e0">tl</a>(lrules);
<a name="l00093"></a>00093     }   
<a name="l00094"></a>00094     <span class="keywordflow">return</span> lr;
<a name="l00095"></a>00095 }
<a name="l00096"></a>00096 
<a name="l00097"></a>00097 
<a name="l00104"></a><a class="code" href="sourcereader_8cpp.html#a8a0607da8b9f5fd6028238cce62c4434">00104</a> <span class="keyword">static</span> <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 class="code" href="sourcereader_8cpp.html#a8a0607da8b9f5fd6028238cce62c4434" title="Transforms a list of variants (arglist.body) into an abstraction or a boxCase.">makeDefinition</a>(list&lt;Tree&gt;&amp; variants)
<a name="l00105"></a>00105 {
<a name="l00106"></a>00106     <span class="keywordflow">if</span> (variants.size() == 1) {
<a name="l00107"></a>00107         <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> rhs = *(variants.begin());
<a name="l00108"></a>00108         <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> args= <a class="code" href="list_8hh.html#a067ad6f83087b420a1c44e48e56be389">hd</a>(rhs);
<a name="l00109"></a>00109         <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> body= <a class="code" href="list_8hh.html#a4075748f5c7156306ec898795313a2e0">tl</a>(rhs);
<a name="l00110"></a>00110         
<a name="l00111"></a>00111         <span class="keywordflow">if</span> (<a class="code" href="list_8hh.html#a2569c3a07bbbfa55e0afde62de62aeec">isNil</a>(args)) {
<a name="l00112"></a>00112             <span class="keywordflow">return</span> body;
<a name="l00113"></a>00113         } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="sourcereader_8cpp.html#ae249f286a34bd52298dd5a9c7c0d8409" title="Checks an argument list for containing only standard identifiers, no patterns and...">standardArgList</a>(args)) {
<a name="l00114"></a>00114             <span class="keywordflow">return</span> <a class="code" href="boxes_8cpp.html#afcbfa6cdd8ea0fdfd9267be467cc8087">buildBoxAbstr</a>(args, body);
<a name="l00115"></a>00115         } <span class="keywordflow">else</span> {
<a name="l00116"></a>00116             <span class="keywordflow">return</span> <a class="code" href="boxes_8cpp.html#a8bc3b57470ff5814f5f24ed97dff593b">boxCase</a>(<a class="code" href="list_8hh.html#ae1ed153946fcfc025009c6d9c9c40bee">cons</a>(rhs,<a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>));
<a name="l00117"></a>00117         }
<a name="l00118"></a>00118     } <span class="keywordflow">else</span> {
<a name="l00119"></a>00119         list&lt;Tree&gt;::iterator p;
<a name="l00120"></a>00120         <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>    l = <a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>;
<a name="l00121"></a>00121         <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>    prev = *variants.begin();
<a name="l00122"></a>00122         <span class="keywordtype">int</span>     npat = <a class="code" href="list_8cpp.html#a0b58ea1a5d8649e8afb0f70c48776347">len</a>(<a class="code" href="list_8hh.html#a067ad6f83087b420a1c44e48e56be389">hd</a>(prev));
<a name="l00123"></a>00123         <span class="keywordflow">for</span> (p=variants.begin(); p!=variants.end(); p++) {
<a name="l00124"></a>00124             <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> cur = *p;
<a name="l00125"></a>00125             <span class="keywordflow">if</span> (npat != <a class="code" href="list_8cpp.html#a0b58ea1a5d8649e8afb0f70c48776347">len</a>(<a class="code" href="list_8hh.html#a067ad6f83087b420a1c44e48e56be389">hd</a>(cur))) {
<a name="l00126"></a>00126                 <a class="code" href="sourcereader_8cpp.html#aa86500dcc61306ee7f28562d4ee823d0">printPatternError</a>(<a class="code" href="list_8hh.html#a067ad6f83087b420a1c44e48e56be389">hd</a>(prev), <a class="code" href="list_8hh.html#a4075748f5c7156306ec898795313a2e0">tl</a>(prev), <a class="code" href="list_8hh.html#a067ad6f83087b420a1c44e48e56be389">hd</a>(cur), <a class="code" href="list_8hh.html#a4075748f5c7156306ec898795313a2e0">tl</a>(cur));
<a name="l00127"></a>00127                 exit(1);
<a name="l00128"></a>00128             }
<a name="l00129"></a>00129             prev = cur;
<a name="l00130"></a>00130             l = <a class="code" href="list_8hh.html#ae1ed153946fcfc025009c6d9c9c40bee">cons</a>(*p,l);
<a name="l00131"></a>00131         }
<a name="l00132"></a>00132         <span class="keywordflow">return</span> <a class="code" href="boxes_8cpp.html#a8bc3b57470ff5814f5f24ed97dff593b">boxCase</a>(l);
<a name="l00133"></a>00133     }
<a name="l00134"></a>00134 }
<a name="l00135"></a>00135 
<a name="l00136"></a>00136 
<a name="l00137"></a>00137 
<a name="l00146"></a><a class="code" href="sourcereader_8hh.html#ad90fd80d84dccb47005b13106ed15368">00146</a> <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 class="code" href="sourcereader_8cpp.html#ad90fd80d84dccb47005b13106ed15368" title="Formats a list of raw definitions represented by triplets &amp;lt;name,arglist,body&amp;gt;...">formatDefinitions</a>(<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> rldef)
<a name="l00147"></a>00147 {
<a name="l00148"></a>00148     map&lt;Tree,list&lt;Tree&gt; &gt; dic;
<a name="l00149"></a>00149     map&lt;Tree,list&lt;Tree&gt; &gt;::iterator p;
<a name="l00150"></a>00150     <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> ldef2 = <a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>;
<a name="l00151"></a>00151     <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> file;
<a name="l00152"></a>00152     
<a name="l00153"></a>00153     <span class="comment">//cout &lt;&lt; &quot;Format definitions &quot; &lt;&lt; *rldef &lt;&lt; endl;</span>
<a name="l00154"></a>00154     <span class="comment">// collects the definitions in a dictionnary</span>
<a name="l00155"></a>00155     <span class="keywordflow">while</span> (!<a class="code" href="list_8hh.html#a2569c3a07bbbfa55e0afde62de62aeec">isNil</a>(rldef)) {
<a name="l00156"></a>00156         <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> def = <a class="code" href="list_8hh.html#a067ad6f83087b420a1c44e48e56be389">hd</a>(rldef);       
<a name="l00157"></a>00157         rldef = <a class="code" href="list_8hh.html#a4075748f5c7156306ec898795313a2e0">tl</a>(rldef);
<a name="l00158"></a>00158         <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a669c5f5ddf58b6f22e1497e24577469b">isImportFile</a>(def, file)) {
<a name="l00159"></a>00159             ldef2 = <a class="code" href="list_8hh.html#ae1ed153946fcfc025009c6d9c9c40bee">cons</a>(def,ldef2);
<a name="l00160"></a>00160         } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!<a class="code" href="list_8hh.html#a2569c3a07bbbfa55e0afde62de62aeec">isNil</a>(def)) { 
<a name="l00161"></a>00161             <span class="comment">//cout &lt;&lt; &quot; def : &quot; &lt;&lt; *def &lt;&lt; endl; </span>
<a name="l00162"></a>00162             dic[<a class="code" href="list_8hh.html#a067ad6f83087b420a1c44e48e56be389">hd</a>(def)].push_front(<a class="code" href="list_8hh.html#a4075748f5c7156306ec898795313a2e0">tl</a>(def)); 
<a name="l00163"></a>00163         }
<a name="l00164"></a>00164     }
<a name="l00165"></a>00165     
<a name="l00166"></a>00166     <span class="comment">// produce the definitions</span>
<a name="l00167"></a>00167     
<a name="l00168"></a>00168     <span class="keywordflow">for</span> (p=dic.begin(); p!=dic.end(); p++) {
<a name="l00169"></a>00169         ldef2 = <a class="code" href="list_8hh.html#ae1ed153946fcfc025009c6d9c9c40bee">cons</a> (<a class="code" href="list_8hh.html#ae1ed153946fcfc025009c6d9c9c40bee">cons</a>(p-&gt;first, <a class="code" href="sourcereader_8cpp.html#a8a0607da8b9f5fd6028238cce62c4434" title="Transforms a list of variants (arglist.body) into an abstraction or a boxCase.">makeDefinition</a>(p-&gt;second)), ldef2);
<a name="l00170"></a>00170     }
<a name="l00171"></a>00171     
<a name="l00172"></a>00172     <span class="comment">//cout &lt;&lt; &quot;list of definitions : &quot; &lt;&lt; *ldef2 &lt;&lt; endl;</span>
<a name="l00173"></a>00173     <span class="keywordflow">return</span> ldef2;
<a name="l00174"></a>00174         
<a name="l00175"></a>00175 }
<a name="l00176"></a>00176 
<a name="l00177"></a>00177 
<a name="l00186"></a><a class="code" href="classSourceReader.html#afed53e57be12e2a35cc96137d48b068d">00186</a> <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 class="code" href="classSourceReader.html#afed53e57be12e2a35cc96137d48b068d" title="Parse a single faust source file.">SourceReader::parse</a>(<span class="keywordtype">string</span> fname)
<a name="l00187"></a>00187 {
<a name="l00188"></a>00188     <span class="keywordtype">string</span>  fullpath;
<a name="l00189"></a>00189     
<a name="l00190"></a>00190     <a class="code" href="main_8cpp.html#a22b78670f95f7470a7b16ec70f68c918">yyerr</a> = 0;
<a name="l00191"></a>00191     
<a name="l00192"></a>00192     <a class="code" href="errormsg_8cpp.html#a9500354f82b09216c6c22f5e11e3ea90">yyfilename</a> = fname.c_str();
<a name="l00193"></a>00193     <a class="code" href="main_8cpp.html#a87a127afa8f6c307fbfba10390675406">yyin</a> = <a class="code" href="enrobage_8cpp.html#a1c21ab6ec8fa85af26fc2a335e294d50" title="Try to open the file &amp;lt;filename&amp;gt; searching in various directories.">fopensearch</a>(<a class="code" href="errormsg_8cpp.html#a9500354f82b09216c6c22f5e11e3ea90">yyfilename</a>, fullpath);
<a name="l00194"></a>00194     <span class="keywordflow">if</span> (<a class="code" href="main_8cpp.html#a87a127afa8f6c307fbfba10390675406">yyin</a> == NULL) {
<a name="l00195"></a>00195         fprintf(stderr, <span class="stringliteral">&quot;ERROR : Unable to open file  %s \n&quot;</span>, <a class="code" href="errormsg_8cpp.html#a9500354f82b09216c6c22f5e11e3ea90">yyfilename</a>); 
<a name="l00196"></a>00196         exit(1);
<a name="l00197"></a>00197     }
<a name="l00198"></a>00198     
<a name="l00199"></a>00199     <a class="code" href="errormsg_8hh.html#a5e36364965360da7b7cdfc2188e0af84">yylineno</a> = 1;
<a name="l00200"></a>00200     <span class="keywordtype">int</span> r = <a class="code" href="main_8cpp.html#acd8617a8f2ac0de8bc1cc032cf449e19">yyparse</a>();
<a name="l00201"></a>00201     <span class="keywordflow">if</span> (r) { 
<a name="l00202"></a>00202         fprintf(stderr, <span class="stringliteral">&quot;Parse error : code = %d \n&quot;</span>, r); 
<a name="l00203"></a>00203     }
<a name="l00204"></a>00204     <span class="keywordflow">if</span> (<a class="code" href="main_8cpp.html#a22b78670f95f7470a7b16ec70f68c918">yyerr</a> &gt; 0) {
<a name="l00205"></a>00205         <span class="comment">//fprintf(stderr, &quot;Erreur de parsing 2, count = %d \n&quot;, yyerr); </span>
<a name="l00206"></a>00206         exit(1);
<a name="l00207"></a>00207     }
<a name="l00208"></a>00208 
<a name="l00209"></a>00209     <span class="comment">// we have parsed a valid file</span>
<a name="l00210"></a>00210     <a class="code" href="classSourceReader.html#a651efb442eece4b5e9ef1c4babc56197">fFilePathnames</a>.push_back(fullpath);
<a name="l00211"></a>00211     <span class="keywordflow">return</span> gResult;
<a name="l00212"></a>00212 }
<a name="l00213"></a>00213 
<a name="l00214"></a>00214 
<a name="l00222"></a><a class="code" href="classSourceReader.html#a40383c73e84a9960cd3bc158744f8ae5">00222</a> <span class="keywordtype">bool</span> <a class="code" href="classSourceReader.html#a40383c73e84a9960cd3bc158744f8ae5" title="Check if a file as been read and is in the &amp;quot;cache&amp;quot;.">SourceReader::cached</a>(<span class="keywordtype">string</span> fname)
<a name="l00223"></a>00223 {
<a name="l00224"></a>00224     <span class="keywordflow">return</span> <a class="code" href="classSourceReader.html#a753ead89e2f4443dae6f6e07ea6c97d6">fFileCache</a>.find(fname) != <a class="code" href="classSourceReader.html#a753ead89e2f4443dae6f6e07ea6c97d6">fFileCache</a>.end();
<a name="l00225"></a>00225 }
<a name="l00226"></a>00226 
<a name="l00227"></a>00227 
<a name="l00235"></a><a class="code" href="classSourceReader.html#a74a22bf0b47f7c6684999ad82f72b713">00235</a> <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 class="code" href="classSourceReader.html#a74a22bf0b47f7c6684999ad82f72b713" title="Return the list of definitions file contains.">SourceReader::getlist</a>(<span class="keywordtype">string</span> fname)
<a name="l00236"></a>00236 {
<a name="l00237"></a>00237     <span class="keywordflow">if</span> (!<a class="code" href="classSourceReader.html#a40383c73e84a9960cd3bc158744f8ae5" title="Check if a file as been read and is in the &amp;quot;cache&amp;quot;.">cached</a>(fname)) {
<a name="l00238"></a>00238         <a class="code" href="classSourceReader.html#a753ead89e2f4443dae6f6e07ea6c97d6">fFileCache</a>[fname] = <a class="code" href="classSourceReader.html#afed53e57be12e2a35cc96137d48b068d" title="Parse a single faust source file.">parse</a>(fname);
<a name="l00239"></a>00239     }
<a name="l00240"></a>00240     <span class="keywordflow">if</span> (<a class="code" href="classSourceReader.html#a753ead89e2f4443dae6f6e07ea6c97d6">fFileCache</a>[fname] == 0) exit(1);
<a name="l00241"></a>00241     <span class="keywordflow">return</span> <a class="code" href="classSourceReader.html#a753ead89e2f4443dae6f6e07ea6c97d6">fFileCache</a>[fname];
<a name="l00242"></a>00242 }
<a name="l00243"></a>00243 
<a name="l00244"></a>00244  
<a name="l00251"></a><a class="code" href="classSourceReader.html#a02d4fe696337e6e327b14620ed76b626">00251</a> vector&lt;string&gt; <a class="code" href="classSourceReader.html#a02d4fe696337e6e327b14620ed76b626" title="Return a vector of pathnames representing the list of all the source files that have...">SourceReader::listSrcFiles</a>()
<a name="l00252"></a>00252 {
<a name="l00253"></a>00253 <span class="comment">//  vector&lt;string&gt;                      srcfiles;</span>
<a name="l00254"></a>00254 
<a name="l00255"></a>00255 <span class="comment">//  for (map&lt;string, Tree&gt;::const_iterator p = fFileCache.begin(); p != fFileCache.end(); p++) {</span>
<a name="l00256"></a>00256 <span class="comment">//      srcfiles.push_back(p-&gt;first);</span>
<a name="l00257"></a>00257 <span class="comment">//  }</span>
<a name="l00258"></a>00258 
<a name="l00259"></a>00259 <span class="comment">//  return srcfiles;    </span>
<a name="l00260"></a>00260     <span class="keywordflow">return</span> <a class="code" href="classSourceReader.html#a651efb442eece4b5e9ef1c4babc56197">fFilePathnames</a>;
<a name="l00261"></a>00261 }
<a name="l00262"></a>00262 
<a name="l00263"></a>00263  
<a name="l00271"></a><a class="code" href="classSourceReader.html#a5c9ca766c1efb427ffdd419517775f44">00271</a> <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 class="code" href="classSourceReader.html#a5c9ca766c1efb427ffdd419517775f44" title="Return the list of definitions where all imports have been expanded.">SourceReader::expandlist</a>(<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> ldef)
<a name="l00272"></a>00272 {
<a name="l00273"></a>00273     set&lt;string&gt; visited;
<a name="l00274"></a>00274     <span class="keywordflow">return</span> <a class="code" href="classSourceReader.html#aabf8441cf5e36e14ff480ae384139ec1">expandrec</a>(ldef, visited, <a class="code" href="list_8cpp.html#a538b704dd07794b7237108f1917c471e">nil</a>);   
<a name="l00275"></a>00275 }
<a name="l00276"></a>00276 
<a name="l00277"></a><a class="code" href="classSourceReader.html#aabf8441cf5e36e14ff480ae384139ec1">00277</a> <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 class="code" href="classSourceReader.html#aabf8441cf5e36e14ff480ae384139ec1">SourceReader::expandrec</a>(<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> ldef, set&lt;string&gt;&amp; visited, <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> lresult)
<a name="l00278"></a>00278 {
<a name="l00279"></a>00279     <span class="keywordflow">for</span> (;!<a class="code" href="list_8hh.html#a2569c3a07bbbfa55e0afde62de62aeec">isNil</a>(ldef); ldef = <a class="code" href="list_8hh.html#a4075748f5c7156306ec898795313a2e0">tl</a>(ldef)) {
<a name="l00280"></a>00280         <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> d = <a class="code" href="list_8hh.html#a067ad6f83087b420a1c44e48e56be389">hd</a>(ldef); 
<a name="l00281"></a>00281         <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> fname;
<a name="l00282"></a>00282         <span class="keywordflow">if</span> (<a class="code" href="list_8hh.html#a2569c3a07bbbfa55e0afde62de62aeec">isNil</a>(d)) {
<a name="l00283"></a>00283             <span class="comment">// skill null definitions produced by declarations</span>
<a name="l00284"></a>00284         } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="boxes_8cpp.html#a669c5f5ddf58b6f22e1497e24577469b">isImportFile</a>(d,fname)) {
<a name="l00285"></a>00285             <span class="keywordtype">string</span> f = <a class="code" href="tree_8cpp.html#ac753d60778175e30a86cba647db017ad" title="if t has a node of type symbol, return its name otherwise error">tree2str</a>(fname);
<a name="l00286"></a>00286             <span class="comment">//cerr &lt;&lt; &quot;import(&quot; &lt;&lt; f &lt;&lt; &quot;)&quot; &lt;&lt; endl;</span>
<a name="l00287"></a>00287             
<a name="l00288"></a>00288             <span class="comment">//string f = tree2str(fname);</span>
<a name="l00289"></a>00289             <span class="keywordflow">if</span> (visited.find(f) == visited.end()) {
<a name="l00290"></a>00290                 visited.insert(f);
<a name="l00291"></a>00291                 <span class="comment">//Tree l = getlist(f);</span>
<a name="l00292"></a>00292                 lresult = <a class="code" href="classSourceReader.html#aabf8441cf5e36e14ff480ae384139ec1">expandrec</a>(<a class="code" href="classSourceReader.html#a74a22bf0b47f7c6684999ad82f72b713" title="Return the list of definitions file contains.">getlist</a>(f), visited, lresult);
<a name="l00293"></a>00293             }
<a name="l00294"></a>00294             
<a name="l00295"></a>00295         } <span class="keywordflow">else</span> {
<a name="l00296"></a>00296             lresult = <a class="code" href="list_8hh.html#ae1ed153946fcfc025009c6d9c9c40bee">cons</a>(d, lresult);
<a name="l00297"></a>00297         }
<a name="l00298"></a>00298     }
<a name="l00299"></a>00299     <span class="keywordflow">return</span> lresult;
<a name="l00300"></a>00300 }
<a name="l00301"></a>00301                 
<a name="l00302"></a>00302 
<a name="l00303"></a><a class="code" href="sourcereader_8hh.html#acc24bbca610e76ca8b8da1c62c50d449">00303</a> <span class="keywordtype">void</span> <a class="code" href="sourcereader_8cpp.html#acc24bbca610e76ca8b8da1c62c50d449">declareMetadata</a>(<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> key, <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> value)
<a name="l00304"></a>00304 {
<a name="l00305"></a>00305     <span class="keywordflow">if</span> (<a class="code" href="doc_8cpp.html#a1c0fac9c77fcd7f4e21daf398e9830de">gMasterDocument</a> == <a class="code" href="errormsg_8cpp.html#a9500354f82b09216c6c22f5e11e3ea90">yyfilename</a>) {
<a name="l00306"></a>00306         <span class="comment">// inside master document, no prefix needed to declare metadata</span>
<a name="l00307"></a>00307         <a class="code" href="doc_8cpp.html#aaf647729deae314d35817ccb36f088e4">gMetaDataSet</a>[key].insert(value);
<a name="l00308"></a>00308     } <span class="keywordflow">else</span> {
<a name="l00309"></a>00309         <span class="keywordtype">string</span> fkey(<a class="code" href="errormsg_8cpp.html#a9500354f82b09216c6c22f5e11e3ea90">yyfilename</a>);
<a name="l00310"></a>00310         fkey += <span class="stringliteral">&quot;/&quot;</span>;
<a name="l00311"></a>00311         fkey += <a class="code" href="tree_8cpp.html#ac753d60778175e30a86cba647db017ad" title="if t has a node of type symbol, return its name otherwise error">tree2str</a>(key);
<a name="l00312"></a>00312         <a class="code" href="doc_8cpp.html#aaf647729deae314d35817ccb36f088e4">gMetaDataSet</a>[<a class="code" href="tree_8hh.html#a61c13e9361cfa80bbb3cd6ce60a8f595">tree</a>(fkey.c_str())].insert(value);
<a name="l00313"></a>00313     }
<a name="l00314"></a>00314 }
<a name="l00315"></a>00315 <span class="comment">/*</span>
<a name="l00316"></a>00316 <span class="comment">    }</span>
<a name="l00317"></a>00317 <span class="comment">    cout &lt;&lt; &quot;Master &quot; &lt;&lt; gMasterDocument  &lt;&lt; &quot;, file &quot; &lt;&lt; yyfilename &lt;&lt;  &quot; : declare &quot; &lt;&lt; *key &lt;&lt; &quot;,&quot; &lt;&lt; *value &lt;&lt; endl;</span>
<a name="l00318"></a>00318 <span class="comment">    gMetaDataSet[key].insert(value);</span>
<a name="l00319"></a>00319 <span class="comment">}       */</span>
<a name="l00320"></a>00320 
<a name="l00321"></a><a class="code" href="sourcereader_8hh.html#a7cd651735195e5651ebee01a3f6e914c">00321</a> <span class="keywordtype">void</span> <a class="code" href="sourcereader_8cpp.html#a7cd651735195e5651ebee01a3f6e914c">declareDoc</a>(<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> t)
<a name="l00322"></a>00322 {
<a name="l00323"></a>00323     <span class="comment">//gLatexDocSwitch = true;</span>
<a name="l00324"></a>00324     <a class="code" href="doc_8cpp.html#a7c306e8c82617863fda51d2c1158f5ab" title="Contains &amp;lt;mdoc&amp;gt; parsed trees: DOCTXT, DOCEQN, DOCDGM.">gDocVector</a>.push_back(t);
<a name="l00325"></a>00325 }
</pre></div></div>
<hr class="footer"/><address style="text-align: right;"><small>Generated on Wed Apr 28 23:59:59 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>