sourcereader.hh File Reference

#include "boxes.hh"
#include <string>
#include <set>
#include <vector>
Include dependency graph for sourcereader.hh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  SourceReader

Functions

Tree formatDefinitions (Tree rldef)
 Formats a list of raw definitions represented by triplets <name,arglist,body> into abstractions or pattern matching rules when appropriate.
Tree checkRulelist (Tree lrules)
void declareMetadata (Tree key, Tree value)
void declareDoc (Tree t)

Function Documentation

Tree checkRulelist ( Tree  lrules  ) 

Definition at line 73 of file sourcereader.cpp.

References hd(), isNil(), len(), printPatternError(), and tl().

Referenced by yyparse().

00074 {
00075     Tree lrules = lr;
00076     if (isNil(lrules)) { cerr << "ERROR : a case expression can't be empty" << endl; exit(1); }
00077     // first pattern used as a reference
00078     Tree lhs1 = hd(hd(lrules));
00079     Tree rhs1 = tl(hd(lrules));
00080     int npat = len(lhs1); 
00081     lrules = tl(lrules);
00082     while (! isNil(lrules)) {
00083         Tree lhs2 = hd(hd(lrules));
00084         Tree rhs2 = tl(hd(lrules));
00085         if (npat != len(lhs2)) {
00086             printPatternError(lhs1,rhs1,lhs2,rhs2);
00087             exit(1);
00088         }
00089         
00090         lhs1 = lhs2;
00091         rhs1 = rhs2;
00092         lrules = tl(lrules);
00093     }   
00094     return lr;
00095 }

Here is the call graph for this function:

Here is the caller graph for this function:

void declareDoc ( Tree  t  ) 

Definition at line 318 of file sourcereader.cpp.

References gDocVector.

Referenced by declareAutoDoc(), and yyparse().

00319 {
00320     //gLatexDocSwitch = true;
00321     gDocVector.push_back(t);
00322 }

Here is the caller graph for this function:

void declareMetadata ( Tree  key,
Tree  value 
)

Definition at line 303 of file sourcereader.cpp.

References gMasterDocument, gMetaDataSet, tree(), tree2str(), and yyfilename.

Referenced by yyparse().

00304 {
00305     if (gMasterDocument == yyfilename) {
00306         // inside master document, no prefix needed to declare metadata
00307         gMetaDataSet[key].insert(value);
00308     } else {
00309         string fkey(yyfilename);
00310         fkey += "/";
00311         fkey += tree2str(key);
00312         gMetaDataSet[tree(fkey.c_str())].insert(value);
00313     }
00314     //cout << "Master " << gMasterDocument  << ", file " << yyfilename <<  " : declare " << *key << "," << *value << endl;
00315 }

Here is the call graph for this function:

Here is the caller graph for this function:

Tree formatDefinitions ( Tree  rldef  ) 

Formats a list of raw definitions represented by triplets <name,arglist,body> into abstractions or pattern matching rules when appropriate.

Parameters:
rldef list of raw definitions in reverse order
Returns:
the list of formatted definitions

Definition at line 146 of file sourcereader.cpp.

References cons(), hd(), isImportFile(), isNil(), makeDefinition(), nil, and tl().

Referenced by yyparse().

00147 {
00148     map<Tree,list<Tree> > dic;
00149     map<Tree,list<Tree> >::iterator p;
00150     Tree ldef2 = nil;
00151     Tree file;
00152     
00153     //cout << "Format definitions " << *rldef << endl;
00154     // collects the definitions in a dictionnary
00155     while (!isNil(rldef)) {
00156         Tree def = hd(rldef);       
00157         rldef = tl(rldef);
00158         if (isImportFile(def, file)) {
00159             ldef2 = cons(def,ldef2);
00160         } else if (!isNil(def)) { 
00161             //cout << " def : " << *def << endl; 
00162             dic[hd(def)].push_front(tl(def)); 
00163         }
00164     }
00165     
00166     // produce the definitions
00167     
00168     for (p=dic.begin(); p!=dic.end(); p++) {
00169         ldef2 = cons (cons(p->first, makeDefinition(p->second)), ldef2);
00170     }
00171     
00172     //cout << "list of definitions : " << *ldef2 << endl;
00173     return ldef2;
00174         
00175 }

Here is the call graph for this function:

Here is the caller graph for this function:

Generated on Tue Aug 10 08:04:18 2010 for FAUST compiler by  doxygen 1.6.3