|
FAUST compiler
0.9.9.6b8
|
#include <lateq.hh>
Public Member Functions | |
| Lateq (const int &numInputs, const int &numOutputs) | |
| ~Lateq () | |
| void | addInputSigFormula (const string &str) |
| Add a line of a latex equation code corresponding to a signal. | |
| void | addConstSigFormula (const string &str) |
| void | addParamSigFormula (const string &str) |
| void | addStoreSigFormula (const string &str) |
| void | addRecurSigFormula (const string &str) |
| void | addRDTblSigFormula (const string &str) |
| void | addRWTblSigFormula (const string &str) |
| void | addSelectSigFormula (const string &str) |
| void | addPrefixSigFormula (const string &str) |
| void | addOutputSigFormula (const string &str) |
| void | addUISigFormula (const string &path, const string &str) |
| void | println (ostream &docout) |
| Top-level method to print a whole set of compiled LaTeX formulas. | |
| int | inputs () const |
| int | outputs () const |
Private Member Functions | |
| string | makeItemTitle (const unsigned int formulasListSize, const string &titleName) |
| string | makeSignamesList (const list< string > &formulasList, const string &ending) |
| string | makeSignamesList (const vector< list< string > > &formulasListsVector, const string &ending) |
| For all "internal" signals. | |
| string | getSigName (const string &s) |
| string | makeSigDomain (const list< string > &formulasList) |
| string | getUISigName (const string &s) |
| char | getUISigType (const string &s) |
| vector< list< string > > | makeUISignamesVector (const multimap< string, string > &field) |
| void | printOneLine (const string §ion, ostream &docout) |
| Print a sorted list of input signals names ("x_i"), on a single line, separated by commas. | |
| void | printHierarchy (const string §ion, multimap< string, string > &field, ostream &docout) |
| Print formulas for user interface signals. | |
| void | printDGroup (const string §ion, list< string > &field, ostream &docout) |
| Print a dgroup environment to auto-break long formulas. | |
| void | printMath (const string §ion, list< string > &field, ostream &docout) |
| Print formulas for select2, select3 and prefix signals. | |
| bool | hasNotOnlyEmptyKeys (multimap< string, string > &mm) |
| Find out whether all keys of the multimap are empty or not. | |
| void | tab (int n, ostream &docout) const |
| Simple handling of indentation. | |
Private Attributes | |
| const int | fNumInputs |
| const int | fNumOutputs |
| list< string > | fInputSigsFormulas |
| LaTeX formulas to print. | |
| list< string > | fConstSigsFormulas |
| list< string > | fParamSigsFormulas |
| list< string > | fStoreSigsFormulas |
| list< string > | fRecurSigsFormulas |
| list< string > | fRDTblSigsFormulas |
| list< string > | fRWTblSigsFormulas |
| list< string > | fSelectSigsFormulas |
| list< string > | fPrefixSigsFormulas |
| list< string > | fOutputSigsFormulas |
| multimap< string, string > | fUISigsFormulas |
| Lateq::Lateq | ( | const int & | numInputs, |
| const int & | numOutputs | ||
| ) | [inline] |
Definition at line 60 of file lateq.hh.
: fNumInputs(numInputs), fNumOutputs(numOutputs) {}
| Lateq::~Lateq | ( | ) | [inline] |
| void Lateq::addConstSigFormula | ( | const string & | str | ) | [inline] |
Definition at line 68 of file lateq.hh.
Referenced by DocCompiler::generateVariableStore().
{ fConstSigsFormulas.push_back(str); }

| void Lateq::addInputSigFormula | ( | const string & | str | ) | [inline] |
Add a line of a latex equation code corresponding to a signal.
Definition at line 67 of file lateq.hh.
Referenced by DocCompiler::generateInput().
{ fInputSigsFormulas.push_back(str); }

| void Lateq::addOutputSigFormula | ( | const string & | str | ) | [inline] |
Definition at line 76 of file lateq.hh.
Referenced by DocCompiler::compileLateq(), and DocCompiler::generateOutput().
{ fOutputSigsFormulas.push_back(str); }

| void Lateq::addParamSigFormula | ( | const string & | str | ) | [inline] |
Definition at line 69 of file lateq.hh.
Referenced by DocCompiler::generateVariableStore().
{ fParamSigsFormulas.push_back(str); }

| void Lateq::addPrefixSigFormula | ( | const string & | str | ) | [inline] |
Definition at line 75 of file lateq.hh.
Referenced by DocCompiler::generatePrefix().
{ fPrefixSigsFormulas.push_back(str); }

| void Lateq::addRDTblSigFormula | ( | const string & | str | ) | [inline] |
Definition at line 72 of file lateq.hh.
Referenced by DocCompiler::generateDocConstantTbl().
{ fRDTblSigsFormulas.push_back(str); }

| void Lateq::addRecurSigFormula | ( | const string & | str | ) | [inline] |
Definition at line 71 of file lateq.hh.
Referenced by DocCompiler::generateDelayLine(), and DocCompiler::generateDelayVecNoTemp().
{ fRecurSigsFormulas.push_back(str); }

| void Lateq::addRWTblSigFormula | ( | const string & | str | ) | [inline] |
Definition at line 73 of file lateq.hh.
Referenced by DocCompiler::generateDocWriteTbl().
{ fRWTblSigsFormulas.push_back(str); }

| void Lateq::addSelectSigFormula | ( | const string & | str | ) | [inline] |
Definition at line 74 of file lateq.hh.
Referenced by DocCompiler::generateSelect2(), and DocCompiler::generateSelect3().
{ fSelectSigsFormulas.push_back(str); }

| void Lateq::addStoreSigFormula | ( | const string & | str | ) | [inline] |
Definition at line 70 of file lateq.hh.
Referenced by DocCompiler::generateVariableStore().
{ fStoreSigsFormulas.push_back(str); }

| void Lateq::addUISigFormula | ( | const string & | path, |
| const string & | str | ||
| ) | [inline] |
Definition at line 77 of file lateq.hh.
Referenced by DocCompiler::generateButton(), DocCompiler::generateCheckbox(), DocCompiler::generateHSlider(), DocCompiler::generateNumEntry(), and DocCompiler::generateVSlider().
{ fUISigsFormulas.insert(make_pair(path, str)); };

| string Lateq::getSigName | ( | const string & | s | ) | [private] |
< Looking for a left member.
< Strip "(t)" argument if exists.
< Strip "[t]" argument if exists (for tables).
< Strip indice if exists.
Definition at line 206 of file lateq.cpp.
Referenced by makeSigDomain().
{
size_t found;
string signame;
found = s.find(" =");
if (found != string::npos) {
signame = s.substr (0, found);
}
found = s.find("(t)");
if (found != string::npos) {
signame = s.substr (0, found);
}
found = signame.find("[t]");
if (found != string::npos) {
signame = s.substr (0, found);
}
found = signame.find_last_of("_");
if (found != string::npos) {
signame = signame.substr (0, found);
}
return signame;
}

| string Lateq::getUISigName | ( | const string & | s | ) | [private] |
< Looking for a UI signal name "{u_?}_{i}(t)".
Definition at line 261 of file lateq.cpp.
Referenced by makeUISignamesVector().
{
size_t found;
string signame;
found = s.find("${u_");
if (found != string::npos) {
signame = s.substr (found+1, 12);
}
return signame;
}

| char Lateq::getUISigType | ( | const string & | s | ) | [private] |
< Looking for a UI signal name "{u_?}_{i}".
Definition at line 275 of file lateq.cpp.
Referenced by makeUISignamesVector().
{
size_t found;
char sigtype = '0';
found = s.find("${u_");
if (found != string::npos) {
sigtype = s.at (found+4);
}
return sigtype;
}

| bool Lateq::hasNotOnlyEmptyKeys | ( | multimap< string, string > & | mm | ) | [private] |
Find out whether all keys of the multimap are empty or not.
In other words : Check that some UIs have a path (non empty).
In other other words : Check that all UIs are not at top-level.
< Look for pairs with empty keys.
Definition at line 454 of file lateq.cpp.
Referenced by printHierarchy().
{
typedef multimap<string,string>::iterator MMIT;
pair<MMIT,MMIT> range;
range = mm.equal_range("");
bool hasOnlyEmptyPaths = (range.first == mm.begin()) && (range.second == mm.end());
return !hasOnlyEmptyPaths;
}

| int Lateq::inputs | ( | ) | const [inline] |
Definition at line 82 of file lateq.hh.
Referenced by DocCompiler::generateInput().
{ return fNumInputs; }

| string Lateq::makeItemTitle | ( | const unsigned int | formulasListSize, |
| const string & | titleName | ||
| ) | [private] |
Definition at line 143 of file lateq.cpp.
References gDocMathStringMap.
Referenced by println().
{
string item = "\\item ";
/* Plural handling for titles of sub-sets of formulas. */
string title = formulasListSize > 1 ? gDocMathStringMap[titleName + "2"] : gDocMathStringMap[titleName + "1"];
return item + title;
}

| string Lateq::makeSigDomain | ( | const list< string > & | formulasList | ) | [private] |
< No indices for single input neither single output.
< Indices "1" for all other single signal.
Definition at line 154 of file lateq.cpp.
References gDocMathStringMap, getSigName(), and to_string().
Referenced by makeSignamesList().
{
string signame = "";
string sigDomain = "";
if (formulasList.size() > 0) {
string firstEq = *(formulasList.begin());
signame = getSigName(firstEq);
if(formulasList.size() > 1) {
sigDomain = " $" + signame + "_i$ " + gDocMathStringMap["for"] + " $i \\in [1," + to_string(formulasList.size()) + "]$";
} else {
if(signame == "x" || signame == "y") {
sigDomain = " $" + signame + "$";
} else {
sigDomain = " $" + signame + "_1$";
}
}
} else {
sigDomain = gDocMathStringMap["emptyformulafield"];
}
return sigDomain;
}


| string Lateq::makeSignamesList | ( | const list< string > & | formulasList, |
| const string & | ending | ||
| ) | [private] |
Definition at line 179 of file lateq.cpp.
References gDocMathStringMap, and makeSigDomain().
Referenced by println().
{
if (formulasList.size() > 0) {
return makeSigDomain(formulasList) + " " + ending;
} else {
return " (" + gDocMathStringMap["emptyformulafield"] + ")";
}
}


| string Lateq::makeSignamesList | ( | const vector< list< string > > & | formulasListsVector, |
| const string & | ending | ||
| ) | [private] |
For all "internal" signals.
Definition at line 189 of file lateq.cpp.
References gDocMathStringMap, and makeSigDomain().
{
if (formulasListsVector.size() > 0) {
vector<list<string> >::const_iterator it;
string signames = "";
string sep = " ";
for (it = formulasListsVector.begin(); it != formulasListsVector.end(); ++it) {
signames += sep + makeSigDomain(*it);
(it != (formulasListsVector.end() - 2)) ? sep = ", " : sep = " " + gDocMathStringMap["and"] + " ";
}
return signames + " " + ending;
} else {
return " (" + gDocMathStringMap["emptyformulafield"] + ")";
}
}

| vector< list< string > > Lateq::makeUISignamesVector | ( | const multimap< string, string > & | field | ) | [private] |
Definition at line 232 of file lateq.cpp.
References getUISigName(), and getUISigType().
Referenced by println().
{
map<char,unsigned int> uiTypesMap;
vector<list<string> > uiSignamesVector;
unsigned int vIndex = 0;
multimap<string,string>::const_iterator it;
for (it = field.begin(); it != field.end(); ++it) {
char type = getUISigType(it->second);
string signame = getUISigName(it->second);
map<char,unsigned int>::iterator uiTypesIt;
uiTypesIt = uiTypesMap.find(type);
if( uiTypesIt != uiTypesMap.end()) {
uiSignamesVector[uiTypesMap[uiTypesIt->second]].push_back(signame);
} else {
++vIndex;
uiTypesMap.insert(pair<char,unsigned int>(type, vIndex));
list<string>* tmpList = new(list<string>);
tmpList->push_back(signame);
uiSignamesVector.push_back(*tmpList);
}
}
return uiSignamesVector;
}


| int Lateq::outputs | ( | ) | const [inline] |
Definition at line 83 of file lateq.hh.
Referenced by DocCompiler::compileLateq(), and DocCompiler::generateOutput().
{ return fNumOutputs; }

| void Lateq::printDGroup | ( | const string & | section, |
| list< string > & | field, | ||
| ostream & | docout | ||
| ) | [private] |
Print a dgroup environment to auto-break long formulas.
| [in] | section | The title to print for these formulas. |
| [in] | field | The list of LaTeX formulas. |
| [out] | docout | The LaTeX output file to print into. |
Definition at line 319 of file lateq.cpp.
References tab().
Referenced by println().
{
if (field.size() > 0) {
docout << section << endl;
tab(1,docout); docout << "\\begin{dgroup*}" << endl;
list<string>::const_iterator s;
for (s = field.begin(); s != field.end(); ++s) {
tab(2,docout); docout << "\\begin{" << "dmath*" << "}" << endl;
tab(3,docout); docout << "\t" << *s << endl;
tab(2,docout); docout << "\\end{" << "dmath*" << "}" << endl;
}
tab(1,docout); docout << "\\end{dgroup*}" << endl;
docout << endl;
}
}


| void Lateq::printHierarchy | ( | const string & | section, |
| multimap< string, string > & | field, | ||
| ostream & | docout | ||
| ) | [private] |
Print formulas for user interface signals.
| [in] | section | The title to print for these formulas. |
| [in] | field | This multimap contains pairs :
|
| [out] | docout | The LaTeX output file to print into. |
< Manage itemize printing for pathnames.
< Manage latex indentation offset.
Definition at line 359 of file lateq.cpp.
References gDocMathStringMap, hasNotOnlyEmptyKeys(), and tab().
Referenced by println().
{
if (field.size() > 0) {
docout << section << endl;
bool hasSomePaths = hasNotOnlyEmptyKeys(field);
unsigned int n;
if (hasSomePaths) {
tab(0,docout); docout << "\\begin{itemize}" << endl;
n = 1;
} else {
n = 0;
}
multimap<string,string>::iterator it;
string uidir = "improbable_starting_dirname";
bool startFlag = true;
for (it = field.begin(); it != field.end(); ++it) {
/* Manage supertabular environment bounds and pathname printing. */
if (it->first != uidir) {
if (!startFlag) {
tab(n+2,docout); docout << "\\end{supertabular}" << endl;
tab(n+1,docout); docout << "\\end{center}" << endl;
} else {
startFlag = false;
}
if (hasSomePaths) {
/* Print the current pathname if new and if pathnames requested. */
if (it->first != "") {
tab(n+0,docout); docout << "\\item \\textsf{" << it->first << "}" << endl;
} else {
tab(n+0,docout); docout << "\\item \\emph{" << gDocMathStringMap["rootlevel"] << "}" << endl;
}
}
tab(n+1,docout); docout << "\\begin{center}" << endl;
tab(n+2,docout); docout << "\\begin{supertabular}{lll}" << endl;
}
/* Print the current formula. */
tab(n+3,docout); docout << it->second << endl;
uidir = it->first;
}
tab(n+2,docout); docout << "\\end{supertabular}" << endl;
tab(n+1,docout); docout << "\\end{center}" << endl;
if (hasSomePaths) {
tab(n+0,docout); docout << "\\end{itemize}" << endl;
}
docout << endl;
}
}


| void Lateq::println | ( | ostream & | docout | ) |
Top-level method to print a whole set of compiled LaTeX formulas.
Top-level method to print a whole set of compiled LaTeX formulas, corresponding to an <equation> faustdoc tag.
Definition at line 83 of file lateq.cpp.
References compLateqIndexes(), fConstSigsFormulas, fInputSigsFormulas, fOutputSigsFormulas, fParamSigsFormulas, fPrefixSigsFormulas, fRDTblSigsFormulas, fRecurSigsFormulas, fRWTblSigsFormulas, fSelectSigsFormulas, fStoreSigsFormulas, fUISigsFormulas, gDocMathStringMap, makeItemTitle(), makeSignamesList(), makeUISignamesVector(), printDGroup(), printHierarchy(), printMath(), printOneLine(), and to_string().
Referenced by printDocEqn().
{
/* 1. Make titles of sub-sets of formulas. */
string suchthat = gDocMathStringMap["suchthat"];
string sInputs = makeItemTitle(fInputSigsFormulas.size(), "inputsigtitle") + makeSignamesList(fInputSigsFormulas, "");
string sOutputs = makeItemTitle(fOutputSigsFormulas.size(), "outputsigtitle") + makeSignamesList(fOutputSigsFormulas, suchthat);
string sConstants = makeItemTitle(fConstSigsFormulas.size(), "constsigtitle") + makeSignamesList(fConstSigsFormulas, suchthat);
vector<list<string> > UISignamesVector = makeUISignamesVector(fUISigsFormulas);
string sUIElements = makeItemTitle(fUISigsFormulas.size(), "uisigtitle") + makeSignamesList(UISignamesVector, suchthat);
unsigned int internalSigsCount = fParamSigsFormulas.size() + fStoreSigsFormulas.size() + fRecurSigsFormulas.size() + fRDTblSigsFormulas.size() + fRWTblSigsFormulas.size() + fSelectSigsFormulas.size() + fPrefixSigsFormulas.size();
vector<list<string> > internalSigsFormulasList;
if( ! fParamSigsFormulas.empty() ) internalSigsFormulasList.push_back(fParamSigsFormulas);
if( ! fStoreSigsFormulas.empty() ) internalSigsFormulasList.push_back(fStoreSigsFormulas);
if( ! fRecurSigsFormulas.empty() ) internalSigsFormulasList.push_back(fRecurSigsFormulas);
if( ! fRDTblSigsFormulas.empty() ) internalSigsFormulasList.push_back(fRDTblSigsFormulas);
if( ! fRWTblSigsFormulas.empty() ) internalSigsFormulasList.push_back(fRWTblSigsFormulas);
if( ! fSelectSigsFormulas.empty() ) internalSigsFormulasList.push_back(fSelectSigsFormulas);
if( ! fPrefixSigsFormulas.empty() ) internalSigsFormulasList.push_back(fPrefixSigsFormulas);
string sInternals = makeItemTitle(internalSigsCount, "intermedsigtitle") + makeSignamesList(internalSigsFormulasList, suchthat);
/* 2. Successively print each Lateq field containing LaTeX formulas, with a title. */
docout << endl << gDocMathStringMap["lateqcomment"] << endl;
docout << "\\begin{enumerate}" << endl << endl;
printDGroup (sOutputs, fOutputSigsFormulas, docout);
printOneLine (sInputs, docout);
const string outputsTitle = "\\item " + sOutputs + "\\ $y_i$\\ " + gDocMathStringMap["for"] + " $i \\in [1," + to_string(fOutputSigsFormulas.size()) + "]$: ";
printHierarchy (sUIElements, fUISigsFormulas, docout);
/* The "Internal signals" item gather several fields, like a "super-item"... */
if( internalSigsCount > 0 ) {
docout << sInternals;
}
fStoreSigsFormulas.sort(compLateqIndexes);
printDGroup ("", fParamSigsFormulas, docout);
printDGroup ("", fStoreSigsFormulas, docout);
printDGroup ("", fRecurSigsFormulas, docout);
printDGroup ("", fRDTblSigsFormulas, docout);
printMath ("", fRWTblSigsFormulas, docout);
printMath ("", fSelectSigsFormulas, docout);
printMath ("", fPrefixSigsFormulas, docout);
printDGroup (sConstants, fConstSigsFormulas, docout);
docout << "\\end{enumerate}" << endl << endl;
}


| void Lateq::printMath | ( | const string & | section, |
| list< string > & | field, | ||
| ostream & | docout | ||
| ) | [private] |
Print formulas for select2, select3 and prefix signals.
| [in] | section | The title to print for these formulas. |
| [in] | field | The list of LaTeX arrays (for braces with two lines). |
| [out] | docout | The LaTeX output file to print into. |
Definition at line 423 of file lateq.cpp.
Referenced by println().
{
if (field.size() > 0) {
docout << section;
docout << "\\begin{displaymath}" << endl;
list<string>::iterator s;
for (s = field.begin(); s != field.end(); ++s) {
docout << *s << endl;
}
docout << "\\end{displaymath}" << endl;
docout << endl;
}
}

| void Lateq::printOneLine | ( | const string & | section, |
| ostream & | docout | ||
| ) | [private] |
Print a sorted list of input signals names ("x_i"), on a single line, separated by commas.
| [in] | section | The title to print for these formulas. |
| [out] | docout | The LaTeX output file to print into. |
Definition at line 302 of file lateq.cpp.
Referenced by println().
{
docout << section << endl << endl;
}

| void Lateq::tab | ( | int | n, |
| ostream & | docout | ||
| ) | const [private] |
Simple handling of indentation.
Definition at line 439 of file lateq.cpp.
Referenced by printDGroup(), and printHierarchy().
{
while (n--) docout << '\t';
}

list<string> Lateq::fConstSigsFormulas [private] |
list<string> Lateq::fInputSigsFormulas [private] |
const int Lateq::fNumInputs [private] |
const int Lateq::fNumOutputs [private] |
list<string> Lateq::fOutputSigsFormulas [private] |
list<string> Lateq::fParamSigsFormulas [private] |
list<string> Lateq::fPrefixSigsFormulas [private] |
list<string> Lateq::fRDTblSigsFormulas [private] |
list<string> Lateq::fRecurSigsFormulas [private] |
list<string> Lateq::fRWTblSigsFormulas [private] |
list<string> Lateq::fSelectSigsFormulas [private] |
list<string> Lateq::fStoreSigsFormulas [private] |
multimap<string,string> Lateq::fUISigsFormulas [private] |
1.8.0