FAUST compiler  0.9.9.6b8
Classes | Functions
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().

{
    Tree lrules = lr;
    if (isNil(lrules)) { cerr << "ERROR : a case expression can't be empty" << endl; exit(1); }
    // first pattern used as a reference
    Tree lhs1 = hd(hd(lrules));
    Tree rhs1 = tl(hd(lrules));
    int npat = len(lhs1); 
    lrules = tl(lrules);
    while (! isNil(lrules)) {
        Tree lhs2 = hd(hd(lrules));
        Tree rhs2 = tl(hd(lrules));
        if (npat != len(lhs2)) {
            printPatternError(lhs1,rhs1,lhs2,rhs2);
            exit(1);
        }
        
        lhs1 = lhs2;
        rhs1 = rhs2;
        lrules = tl(lrules);
    }   
    return lr;
}

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().

{
    //gLatexDocSwitch = true;
    gDocVector.push_back(t);
}

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().

{
    if (gMasterDocument == yyfilename) {
        // inside master document, no prefix needed to declare metadata
        gMetaDataSet[key].insert(value);
    } else {
        string fkey(yyfilename);
        fkey += "/";
        fkey += tree2str(key);
        gMetaDataSet[tree(fkey.c_str())].insert(value);
    }
    //cout << "Master " << gMasterDocument  << ", file " << yyfilename <<  " : declare " << *key << "," << *value << endl;
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Parameters:
rldeflist 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().

{
    map<Tree,list<Tree> > dic;
    map<Tree,list<Tree> >::iterator p;
    Tree ldef2 = nil;
    Tree file;
    
    //cout << "Format definitions " << *rldef << endl;
    // collects the definitions in a dictionnary
    while (!isNil(rldef)) {
        Tree def = hd(rldef);       
        rldef = tl(rldef);
        if (isImportFile(def, file)) {
            ldef2 = cons(def,ldef2);
        } else if (!isNil(def)) { 
            //cout << " def : " << *def << endl; 
            dic[hd(def)].push_front(tl(def)); 
        }
    }
    
    // produce the definitions
    
    for (p=dic.begin(); p!=dic.end(); p++) {
        ldef2 = cons (cons(p->first, makeDefinition(p->second)), ldef2);
    }
    
    //cout << "list of definitions : " << *ldef2 << endl;
    return ldef2;
        
}

Here is the call graph for this function:

Here is the caller graph for this function: