FAUST compiler  0.9.9.6b8
ppbox.hh
Go to the documentation of this file.
1 /************************************************************************
2  ************************************************************************
3  FAUST compiler
4  Copyright (C) 2003-2004 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 
23 
24 #ifndef _PPBOX_H
25 #define _PPBOX_H
26 
27 /**********************************************************************
28  - ppbox.h : pretty print box expressions (projet FAUST) -
29 
30 
31  Historique :
32  -----------
33  12-07-2002 first implementation (yo)
34 
35 ***********************************************************************/
36 
37 #include <iostream>
38 #include <sstream>
39 #include "boxes.hh"
40 
41 using namespace std;
42 
43 //void fppbox (FILE* fout, Tree box, int priority=0);
44 //inline void ppbox (Tree box, int priority=0) { fppbox(stdout, box, priority); }
45 
46 
47 const char * prim0name(CTree *(*ptr) ());
48 const char * prim1name(CTree *(*ptr) (CTree *));
49 const char * prim2name(CTree *(*ptr) (CTree *, CTree *));
50 const char * prim3name(CTree *(*ptr) (CTree *, CTree *, CTree *));
51 const char * prim4name(CTree *(*ptr) (CTree *, CTree *, CTree *, CTree *));
52 const char * prim5name(CTree *(*ptr) (CTree *, CTree *, CTree *, CTree *, CTree *));
53 
54 
55 // box pretty printer.
56 // usage : out << boxpp(aBoxExp);
57 
58 class boxpp
59 {
60 
61 protected:
63  int priority;
64 public:
65  boxpp(Tree b, int p=0) : box(b), priority(p) {}
66  virtual ostream& print (ostream& fout) const;
67 };
68 
69 inline ostream& operator << (ostream& file, const boxpp& bpp) { return bpp.print(file); }
70 
71 
72 // box pretty printer.
73 // usage : out << boxpp(aBoxExp);
74 
75 class envpp
76 {
78 public:
79  envpp(Tree e) : fEnv(e) {}
80  ostream& print (ostream& fout) const;
81 };
82 
83 inline ostream& operator << (ostream& file, const envpp& epp) { return epp.print(file); }
84 
85 
86 #endif
const char * prim5name(CTree *(*ptr)(CTree *, CTree *, CTree *, CTree *, CTree *))
Definition: ppbox.cpp:89
Tree box
Definition: ppbox.hh:62
const char * prim2name(CTree *(*ptr)(CTree *, CTree *))
Definition: ppbox.cpp:47
ostream & print(ostream &fout) const
Definition: ppbox.cpp:386
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
int priority
Definition: ppbox.hh:63
const char * prim1name(CTree *(*ptr)(CTree *))
Definition: ppbox.cpp:39
ostream & operator<<(ostream &file, const boxpp &bpp)
Definition: ppbox.hh:69
const char * prim3name(CTree *(*ptr)(CTree *, CTree *, CTree *))
Definition: ppbox.cpp:76
virtual ostream & print(ostream &fout) const
Definition: ppbox.cpp:144
boxpp(Tree b, int p=0)
Definition: ppbox.hh:65
const char * prim4name(CTree *(*ptr)(CTree *, CTree *, CTree *, CTree *))
Definition: ppbox.cpp:83
Definition: ppbox.hh:58
Definition: ppbox.hh:75
envpp(Tree e)
Definition: ppbox.hh:79
const char * prim0name(CTree *(*ptr)())
Definition: ppbox.cpp:34
Tree fEnv
Definition: ppbox.hh:77
void print(Tree t, FILE *out)
Definition: list.cpp:154