|
FAUST compiler
0.9.9.6b8
|
Implementation of documentation trees support and printing. More...
#include <stdio.h>#include <string.h>#include <errno.h>#include <sys/stat.h>#include <time.h>#include <algorithm>#include <functional>#include <iostream>#include <fstream>#include <sstream>#include <map>#include <string>#include <vector>#include "ppbox.hh"#include "prim2.hh"#include "doc.hh"#include "eval.hh"#include "errormsg.hh"#include "doc_Text.hh"#include "sigprint.hh"#include "propagate.hh"#include "enrobage.hh"#include "drawschema.hh"#include "names.hh"#include "simplify.hh"#include "privatise.hh"#include "recursivness.hh"#include "sourcereader.hh"#include "lateq.hh"#include "doc_compile.hh"#include "doc_lang.hh"#include "doc_notice.hh"#include "doc_autodoc.hh"#include "compatibility.hh"#include "files.hh"
Go to the source code of this file.
Macros | |
| #define | MAXIDCHARS 5 |
| max numbers (characters) to represent ids (e.g. for directories). More... | |
Enumerations | |
| enum | { langEN, langFR, langIT } |
Functions | |
| static void | printlatexheader (istream &latexheader, const string &faustversion, ostream &docout) |
| Print a static LaTeX header. More... | |
| static void | printfaustlistings (ostream &docout) |
| Print listings of each Faust code ".dsp" files, calling the 'printfaustlisting' function. More... | |
| static void | printfaustlisting (string &faustfile, ostream &docout) |
| Print a listing of the Faust code, in a LaTeX "listing" environment. More... | |
| static void | printlatexfooter (ostream &docout) |
| Print the static LaTeX footer. More... | |
| static void | printdoccontent (const char *svgTopDir, const vector< Tree > &docVector, const string &faustversion, ostream &docout) |
| Main documentator loop. More... | |
| static void | printfaustdocstamp (const string &faustversion, ostream &docout) |
| Print a "doc stamp" in the LaTeX document : More... | |
| static void | printDocEqn (Lateq *ltq, ostream &docout) |
| Print doc equations, following the Lateq::println method. More... | |
| static void | printDocDgm (const Tree expr, const char *svgTopDir, ostream &docout, int i) |
| Doc diagrams handling. More... | |
| static void | printDocMetadata (const Tree expr, ostream &docout) |
| Print a metadata set. More... | |
| static void | prepareDocEqns (const vector< Tree > &docBoxes, vector< Lateq * > &docCompiledEqnsVector) |
| Caller function. More... | |
| static void | collectDocEqns (const vector< Tree > &docBoxes, vector< Tree > &eqBoxes) |
| step 0. Feed a vector. More... | |
| static void | mapEvalDocEqn (const vector< Tree > &eqBoxes, const Tree &env, vector< Tree > &evalEqBoxes) |
| step 1. Evaluate boxes. More... | |
| static void | mapGetEqName (const vector< Tree > &evalEqBoxes, vector< string > &eqNames) |
| step 2. Get boxes name. More... | |
| static void | calcEqnsNicknames (const vector< string > &eqNames, vector< string > &eqNicknames) |
| step 3. Calculate nicknames. More... | |
| static void | mapPrepareEqSig (const vector< Tree > &evalEqBoxes, vector< int > &eqInputs, vector< int > &eqOutputs, vector< Tree > &eqSigs) |
| step 4&5. Propagate and prepare signals. More... | |
| static void | mapSetSigNickname (const vector< string > &eqNicknames, const vector< int > &eqInputs, const vector< Tree > &eqSigs) |
| step 6. Set signals nicknames. More... | |
| static void | collectEqSigs (const vector< Tree > &eqSigs, Tree &superEqList) |
| step 7. Collect all signals in a superlist. More... | |
| static void | annotateSuperList (DocCompiler *DC, Tree superEqList) |
| step 8. Annotate superlist. More... | |
| static void | mapCompileDocEqnSigs (const vector< Tree > &eqSigs, const vector< int > &eqInputs, const vector< int > &eqOutputs, DocCompiler *DC, vector< Lateq * > &docCompiledEqnsVector) |
| step 10. Compile equations. More... | |
| static string | calcNumberedName (const char *base, int i) |
| Simply concat a string with a number in a "%03d" format. More... | |
| static void | getBoxInputsAndOutputs (const Tree t, int &numInputs, int &numOutputs) |
| Just get the number of inputs and the number of outputs of a box. More... | |
| static string | calcDocEqnInitial (const string s) |
| Calculate an appropriate nickname for equations, from previous names. More... | |
| static void | initCompilationDate () |
| static struct tm * | getCompilationDate () |
| static istream * | openArchFile (const string &filename) |
| Open architecture file. More... | |
| static char * | legalFileName (const Tree t, int n, char *dst) |
| Transform the definition name property of tree <t> into a legal file name. More... | |
| static string | rmExternalDoubleQuotes (const string &s) |
| Remove the leading and trailing double quotes of a string (but not those in the middle of the string) More... | |
| static void | copyFaustSources (const char *projname, const vector< string > &pathnames) |
| Copy all Faust source files into an 'src' subdirectory. More... | |
| vector< string > & | docCodeSlicer (const string &faustfile, vector< string > &codeSlices) |
| Slice faust code between "mdoc" sections. More... | |
| static void | printdocCodeSlices (const string &code, ostream &docout) |
| Print faust code inside a listing environment. More... | |
| static bool | doesFileBeginWithCode (const string &faustfile) |
| Test whether a file does begin with some faust code or not. More... | |
| Tree | docTxt (const char *name) |
| bool | isDocTxt (Tree t) |
| bool | isDocTxt (Tree t0, const char **str) |
| Tree | docEqn (Tree x) |
| bool | isDocEqn (Tree t, Tree &x) |
| Tree | docDgm (Tree x) |
| bool | isDocDgm (Tree t, Tree &x) |
| Tree | docNtc () |
| bool | isDocNtc (Tree t) |
| Tree | docLst () |
| bool | isDocLst (Tree t) |
| Tree | docMtd (Tree x) |
| bool | isDocMtd (Tree t, Tree &x) |
| void | printDoc (const char *projname, const char *docdev, const char *faustversion) |
| The entry point to generate faust doc files. More... | |
Variables | |
| Tree | gExpandedDefList |
| map< Tree, set< Tree > > | gMetaDataSet |
| map< string, string > | gDocMetadatasStringMap |
| map< string, string > | gDocMathStringMap |
| bool | gDetailsSwitch |
| bool | gStripDocSwitch |
| string | gFaustDirectory |
| string | gFaustSuperDirectory |
| string | gFaustSuperSuperDirectory |
| string | gMasterDocument |
| string | gMasterName |
| SourceReader | gReader |
| string | gDocName |
| Contains the filename for out documentation. More... | |
| static const char * | gDocDevSuffix |
| ".tex" (or .??? - used to choose output device). More... | |
| static const string | gLatexheaderfilename = "latexheader.tex" |
| vector< Tree > | gDocVector |
| Contains <mdoc> parsed trees: DOCTXT, DOCEQN, DOCDGM. More... | |
| static struct tm | gCompilationDate |
| bool | gLstDependenciesSwitch = true |
| mdoc listing management. More... | |
| bool | gLstMdocTagsSwitch = true |
| mdoc listing management. More... | |
| bool | gLstDistributedSwitch = true |
| mdoc listing management. More... | |
| string | gDocLang |
| Sym | DOCTXT = symbol ("DocTxt") |
| Sym | DOCEQN = symbol ("DocEqn") |
| Sym | DOCDGM = symbol ("DocDgm") |
| Sym | DOCNTC = symbol ("DocNtc") |
| Sym | DOCLST = symbol ("DocLst") |
| Sym | DOCMTD = symbol ("DocMtd") |
Implementation of documentation trees support and printing.
Definition in file doc.cpp.
| #define MAXIDCHARS 5 |
max numbers (characters) to represent ids (e.g. for directories).
Definition at line 83 of file doc.cpp.
Referenced by calcNumberedName(), and printDocDgm().
| anonymous enum |
| Enumerator | |
|---|---|
| langEN | |
| langFR | |
| langIT | |
|
static |
step 8. Annotate superlist.
#8.
Annotate superEqList (to find candidate signals to be named later).
| [in] | DC | The signals compiler. |
| [out] | superEqList | The super equations signal tree to annotate. |
Definition at line 732 of file doc.cpp.
References DocCompiler::annotate().
Referenced by prepareDocEqns().


|
static |
Calculate an appropriate nickname for equations, from previous names.
| The | string to parse. |
Definition at line 783 of file doc.cpp.
Referenced by calcEqnsNicknames().

|
static |
step 3. Calculate nicknames.
#3.
Calculate a nickname for each equation and store it.
| [in] | eqNames | Equations names to parse. |
| [out] | eqNicknames | The place to store calculated nicknames. |
Check duplicates
Definition at line 618 of file doc.cpp.
References calcDocEqnInitial().
Referenced by prepareDocEqns().


|
static |
Simply concat a string with a number in a "%03d" format.
The number has MAXIDCHARS characters.
Definition at line 1021 of file doc.cpp.
References MAXIDCHARS, and subst().
Referenced by mapGetEqName().


step 0. Feed a vector.
#0.
Collect every <equation> found in all <mdoc> faust comments.
| [in] | docBoxes | The <mdoc> boxes to filter. |
| [out] | eqBoxes | The place to store only <equation> boxes. |
Definition at line 544 of file doc.cpp.
References doc, hd(), isDocEqn(), isList(), reverse(), and tl().
Referenced by prepareDocEqns().


step 7. Collect all signals in a superlist.
#7.
Collect each prepared list of signals to construct a super list.
| [in] | eqSigs | Contains well-prepared and nicknamed signals. |
| [out] | superEqList | The root where to 'cons' signals all together. |
Definition at line 711 of file doc.cpp.
Referenced by prepareDocEqns().


|
static |
Copy all Faust source files into an 'src' subdirectory.
| [in] | projname | Basename of the new doc directory ("*-math"). |
| [in] | pathnames | The paths list of the source files to copy. |
Definition at line 1051 of file doc.cpp.
References filebasename(), makedir(), and subst().
Referenced by printDoc().


| vector< string > & docCodeSlicer | ( | const string & | faustfile, |
| vector< string > & | codeSlices | ||
| ) |
Slice faust code between "mdoc" sections.
| [in] | faustfile | Name of the input faust file to parse. |
| [in] | codeSlices | The place to store code "slices". |
Caution: we suppose there's only one <mdoc> tag per line!
A change has come. ;)
Definition at line 891 of file doc.cpp.
Referenced by printdoccontent().

| Tree docLst | ( | ) |
| Tree docNtc | ( | ) |
| Tree docTxt | ( | const char * | name | ) |
Definition at line 171 of file doc.cpp.
References DOCTXT, symbol(), and tree().
Referenced by declareAutoDoc(), and yyparse().


|
static |
Test whether a file does begin with some faust code or not.
| [in] | faustfile | Name of the input faust file to parse. |
Definition at line 949 of file doc.cpp.
Referenced by printdoccontent().

|
static |
Just get the number of inputs and the number of outputs of a box.
| [in] | t | The box tree to get inputs and outputs from. |
| [out] | numInputs | The place to store the number of inputs. |
| [out] | numOutputs | The place to store the number of outputs. |
Definition at line 803 of file doc.cpp.
References getBoxType().
Referenced by mapPrepareEqSig().


|
static |
Definition at line 1083 of file doc.cpp.
References gCompilationDate, and initCompilationDate().
Referenced by printfaustdocstamp(), and printlatexheader().


|
static |
Definition at line 1075 of file doc.cpp.
References gCompilationDate.
Referenced by getCompilationDate().

Definition at line 190 of file doc.cpp.
References DOCDGM, and isTree().
Referenced by printdoccontent().


Definition at line 186 of file doc.cpp.
References DOCEQN, and isTree().
Referenced by collectDocEqns(), and printdoccontent().


| bool isDocLst | ( | Tree | t | ) |
Definition at line 198 of file doc.cpp.
References DOCLST, and isTree().
Referenced by printdoccontent().


Definition at line 202 of file doc.cpp.
References DOCMTD, and isTree().
Referenced by printdoccontent().


| bool isDocNtc | ( | Tree | t | ) |
Definition at line 194 of file doc.cpp.
References DOCNTC, and isTree().
Referenced by printdoccontent().


| bool isDocTxt | ( | Tree | t | ) |
Definition at line 172 of file doc.cpp.
References DOCTXT, and CTree::node().
Referenced by printdoccontent().


| bool isDocTxt | ( | Tree | t0, |
| const char ** | str | ||
| ) |
Definition at line 173 of file doc.cpp.
References DOCTXT, isSym(), isTree(), name(), and CTree::node().

|
static |
Transform the definition name property of tree <t> into a legal file name.
The resulting file name is stored in <dst> a table of at least <n> chars. Returns the <dst> pointer for convenience.
Definition at line 999 of file doc.cpp.
References getDefNameProperty(), and tree2str().
Referenced by printDocDgm().


|
static |
step 10. Compile equations.
#9.
Calculated and set lateq (LaTeX equation) names. Note : Transfered into mapCompileDocEqnSigs (DocCompiler::compileMultiSignal). #10. Name and compile prepared doc <equation> signals.
| [in] | eqSigs | Contains well-prepared and nicknamed signals. |
| [in] | DC | The signals compiler. |
| [out] | docCompiledEqnsVector | The place to store each compiled Lateq* object. |
Definition at line 755 of file doc.cpp.
References DocCompiler::compileLateq().
Referenced by prepareDocEqns().


|
static |
step 1. Evaluate boxes.
#1.
Evaluate every doc <equation> (evaluation replaces abstractions by symbolic boxes).
| [in] | eqBoxes | The boxes to evaluate. |
| [in] | env | The environment for the evaluation. |
| [out] | evalEqBoxes | The place to store evaluated equations boxes. |
Definition at line 570 of file doc.cpp.
References evaldocexpr().
Referenced by prepareDocEqns().


|
static |
step 2. Get boxes name.
#2.
Get name if exists, else create one, and store it.
| [in] | evalEqBoxes | Evaluated box trees, eventually containing an equation name. |
| [out] | eqNames | The place to store equations names. |
Definition at line 588 of file doc.cpp.
References calcNumberedName(), getBoxType(), getDefNameProperty(), and tree2str().
Referenced by prepareDocEqns().


|
static |
step 4&5. Propagate and prepare signals.
#4&5.
Propagate and prepare every doc <equation>.
Call boxPropagateSig, deBruijn2Sym, simplify, and privatise.
| [in] | evalEqBoxes | Equations boxes to propagate as signals. |
| [out] | eqSigs | The place to store prepared signals. |
< Convert debruijn recursion into symbolic recursion
< Simplify by executing every computable operation
< convert regular tables into special doctables (regular tables are difficult to translate to equations)
Definition at line 658 of file doc.cpp.
References boxPropagateSig(), deBruijn2Sym(), docTableConvertion(), getBoxInputsAndOutputs(), makeSigInputList(), nil, and simplify().
Referenced by prepareDocEqns().


|
static |
step 6. Set signals nicknames.
#6.
Set signals nicknames.
Do nothing for the moment !
| [in] | eqNicknames | Contains previously calculated nicknames. |
| [out] | eqSigs | The signals to tag with a NICKNAMEPROPERTY. |
Definition at line 692 of file doc.cpp.
Referenced by prepareDocEqns().

|
static |
Open architecture file.
Definition at line 977 of file doc.cpp.
References cholddir(), getCurrentDir(), and open_arch_stream().
Referenced by printDoc().


|
static |
Caller function.
Caller function for all steps of doc equations preparation.
Note : many of the functions called put their result into their last argument in a "source / destination" manner, the "destination" being declared before the function call.
| [in] | docBoxes | The <mdoc> boxes to collect and prepare. |
| [out] | docCompiledEqnsVector | The place to store compiled equations. |
< step 0. Feed a vector.
< step 1. Evaluate boxes.
< step 2. Get boxes name.
< step 3. Calculate nicknames.
< step 4&5. Propagate and prepare signals.
< step 6. Set signals nicknames.
< step 7. Collect all signals in a superlist.
< step 8. Annotate superEqList.
< step 10. Compile every signal.
Definition at line 515 of file doc.cpp.
References annotateSuperList(), calcEqnsNicknames(), collectDocEqns(), collectEqSigs(), gExpandedDefList, mapCompileDocEqnSigs(), mapEvalDocEqn(), mapGetEqName(), mapPrepareEqSig(), and mapSetSigNickname().
Referenced by printdoccontent().


| void printDoc | ( | const char * | projname, |
| const char * | docdev, | ||
| const char * | faustversion | ||
| ) |
The entry point to generate faust doc files.
The entry point to generate the output LaTeX file, stored in the directory "<projname>-math/". This file eventually references images for diagrams, generated in SVG subdirectories. The device system was adapted from drawSchema's device system.
| [in] | projname | Basename of the new doc directory ("*-math"). |
| [in] | docdev | The doc device; only ".tex" is supported for the moment. |
| [in] | faustversion | The current version of this Faust compiler. |
File stuff : create doc directories and a tex file.
Create THE mathdoc tex file.
Init and load translation file.
Simulate a default doc if no <mdoc> tag detected.
Printing stuff : in the '.tex' ouptut file, eventually including SVG files.
< Faust version and compilation date (comment).
< Static LaTeX header (packages and setup).
< Generate math contents (main stuff!).
< Static LaTeX footer.
Definition at line 224 of file doc.cpp.
References cholddir(), copyFaustSources(), declareAutoDoc(), gDocDevSuffix, gDocLang, gDocName, gDocVector, gLatexheaderfilename, gReader, SourceReader::listSrcFiles(), loadTranslationFile(), makedir(), mkchdir(), openArchFile(), printdoccontent(), printfaustdocstamp(), printlatexfooter(), printlatexheader(), and subst().
Referenced by main().


|
static |
Print faust code inside a listing environment.
| [in] | code | Faust code as a string (may contain ' ' characters). |
| [out] | docout | The output file to print into. |
Definition at line 934 of file doc.cpp.
Referenced by printdoccontent().

|
static |
Main documentator loop.
First loop on gDocVector, which contains the faust <mdoc> trees. Second loop for each of these <mdoc> trees, which contain parsed input expressions of 3 types : DOCEQN for <equation> tags, DOCDGM for <diagram> tags, and DOCTXT for direct LaTeX text (no tag).
| [in] | projname | Basename of the new doc directory ("*-math"). |
| [in] | docVector | Contains all <mdoc> parsed content (as boxes). |
| [in] | faustversion | The current version of this Faust compiler. |
| [out] | docout | The output file to print into. |
Equations need to be prepared (named and compiled) before printing.
< Quite a lot of stuff there.
< For diagram directories numbering.
First level printing loop, on docVector.
Second level printing loop, on each <mdoc>.
< After equations are well prepared and named.
Definition at line 436 of file doc.cpp.
References CTree::branch(), doc, docCodeSlicer(), doesFileBeginWithCode(), gLstDistributedSwitch, gMasterDocument, hd(), isDocDgm(), isDocEqn(), isDocLst(), isDocMtd(), isDocNtc(), isDocTxt(), isList(), prepareDocEqns(), printdocCodeSlices(), printDocDgm(), printDocEqn(), printDocMetadata(), printDocNotice(), printfaustlistings(), reverse(), and tl().
Referenced by printDoc().


|
static |
Doc diagrams handling.
Three steps :
| [in] | expr | Parsed input expression, as boxes tree. |
| [in] | svgTopDir | Basename of the new doc directory ("*-math/svg"). |
| [out] | docout | The output file to print into. |
Definition at line 842 of file doc.cpp.
References drawSchema(), evaldocexpr(), gDocMathStringMap, gDocNoticeFlagMap, gErrorCount, gExpandedDefList, legalFileName(), MAXIDCHARS, and subst().
Referenced by printdoccontent().


|
static |
Print doc equations, following the Lateq::println method.
| [in] | ltq | The object containing compiled LaTeX code of equations. |
| [out] | docout | The output file to print into. |
Definition at line 819 of file doc.cpp.
References Lateq::println().
Referenced by printdoccontent().


|
static |
Print a metadata set.
Each metadata is a set, in order to handle multiple items, like multiple authors, even if most of metadatas have unique items.
| [in] | expr | Parsed metadata keyname, as boxes tree. |
| [out] | docout | The output file to print into. |
Definition at line 311 of file doc.cpp.
References gMetaDataSet, rmExternalDoubleQuotes(), and tree2str().
Referenced by printdoccontent().


|
static |
Print a "doc stamp" in the LaTeX document :
| [in] | faustversion | The current version of this Faust compiler. |
| [out] | docout | The LaTeX output file to print into. |
Definition at line 404 of file doc.cpp.
References getCompilationDate().
Referenced by printDoc().


|
static |
Print a listing of the Faust code, in a LaTeX "listing" environment.
Strip content of <mdoc> tags.
| [in] | faustfile | The source file containing the Faust code. |
| [out] | docout | The LaTeX output file to print into. |
We suppose there's only one <mdoc> tag per line.
Definition at line 351 of file doc.cpp.
References filebasename(), and gStripDocSwitch.
Referenced by printfaustlistings().


|
static |
Print listings of each Faust code ".dsp" files, calling the 'printfaustlisting' function.
| [out] | docout | The LaTeX output file to print into. |
Definition at line 331 of file doc.cpp.
References gLstDependenciesSwitch, gMasterDocument, gReader, SourceReader::listSrcFiles(), and printfaustlisting().
Referenced by printdoccontent().


|
static |
Print the static LaTeX footer.
| [out] | docout | The LaTeX output file to print into. |
Definition at line 389 of file doc.cpp.
Referenced by printDoc().

|
static |
Print a static LaTeX header.
| [in] | latexheader | The file containing the static part of the LaTeX header. |
| [in] | faustversion | The current version of this Faust compiler. |
| [out] | docout | The LaTeX output file to print into. |
Specific LaTeX macros for Faust
Definition at line 283 of file doc.cpp.
References getCompilationDate(), gMasterDocument, and gMasterName.
Referenced by printDoc().


|
static |
Remove the leading and trailing double quotes of a string (but not those in the middle of the string)
Definition at line 1032 of file doc.cpp.
Referenced by printDocMetadata().

Definition at line 188 of file doc.cpp.
Referenced by docDgm(), and isDocDgm().
Definition at line 184 of file doc.cpp.
Referenced by docEqn(), and isDocEqn().
Definition at line 196 of file doc.cpp.
Referenced by docLst(), and isDocLst().
Definition at line 200 of file doc.cpp.
Referenced by docMtd(), and isDocMtd().
Definition at line 192 of file doc.cpp.
Referenced by docNtc(), and isDocNtc().
Definition at line 170 of file doc.cpp.
Referenced by docTxt(), and isDocTxt().
|
static |
Definition at line 111 of file doc.cpp.
Referenced by getCompilationDate(), and initCompilationDate().
|
static |
".tex" (or .??? - used to choose output device).
Definition at line 106 of file doc.cpp.
Referenced by printDoc().
| string gDocLang |
Definition at line 118 of file doc.cpp.
Referenced by printDoc(), and process_cmdline().
| map<string, string> gDocMathStringMap |
Definition at line 51 of file lateq.cpp.
Referenced by printDocDgm().
| map<string, string> gDocMetadatasStringMap |
Definition at line 35 of file doc_metadatas.cpp.
| string gDocName |
Contains the filename for out documentation.
Definition at line 107 of file main.cpp.
Referenced by printDoc().
| vector<Tree> gDocVector |
Contains <mdoc> parsed trees: DOCTXT, DOCEQN, DOCDGM.
Definition at line 109 of file doc.cpp.
Referenced by declareDoc(), and printDoc().
| Tree gExpandedDefList |
Definition at line 108 of file main.cpp.
Referenced by main(), prepareDocEqns(), and printDocDgm().
|
static |
Definition at line 107 of file doc.cpp.
Referenced by printDoc().
| bool gLstDependenciesSwitch = true |
mdoc listing management.
Definition at line 113 of file doc.cpp.
Referenced by printfaustlistings(), and yyparse().
| bool gLstDistributedSwitch = true |
mdoc listing management.
Definition at line 115 of file doc.cpp.
Referenced by printdoccontent(), and yyparse().
| string gMasterDocument |
Definition at line 104 of file main.cpp.
Referenced by printdoccontent(), printfaustlistings(), and printlatexheader().
| string gMasterName |
Definition at line 106 of file main.cpp.
Referenced by printlatexheader().
Definition at line 91 of file main.cpp.
Referenced by printDocMetadata().
| SourceReader gReader |
Definition at line 89 of file main.cpp.
Referenced by printDoc(), and printfaustlistings().
| bool gStripDocSwitch |
Definition at line 124 of file main.cpp.
Referenced by printfaustlisting().
1.8.7