1 /************************************************************************
2  ************************************************************************
3   FAUST compiler
4   Copyright (C) 2003-2018 GRAME, Centre National de Creation Musicale
5   ---------------------------------------------------------------------
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2 of the License, or
9   (at your option) any later version.
10 
11   This program is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15 
16   You should have received a copy of the GNU General Public License
17   along with this program; if not, write to the Free Software
18   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  ************************************************************************
20  ************************************************************************/
21 
22 #ifndef __SOURCEREADER__
23 #define __SOURCEREADER__
24 
25 #include "boxes.hh"
26 #include <string>
27 #include <set>
28 #include <vector>
29 
30 using namespace std;
31 
32 Tree formatDefinitions(Tree rldef);
33 Tree checkRulelist (Tree lrules);
34 void declareMetadata(Tree key, Tree value);
35 void declareDefinitionMetadata(Tree id, Tree key, Tree value);
36 void declareDoc(Tree t);
37 
38 /**
39  * Helper class used for additional DSP of library files needed in the parsing process.
40 */
41 class SourceReader
42 {
43 
44     private:
45 
46         map<string, Tree> fFileCache;
47         vector<string> fFilePathnames;
48 
49         Tree parseLocal(const char* fname);
50         Tree expandRec(Tree ldef, set<string>& visited, Tree lresult);
51         bool cached(string fname);
52         Tree parseFile(const char* fname);
53         Tree parseString(const char* fname);
54         void checkName();
55 
56     public:
57 
58         Tree getList(const char* fname);
59         Tree expandList(Tree ldef);
60         vector<string> listSrcFiles();
61         vector<string> listLibraryFiles();
62 
63 };
64 
65 #endif
66