4 /************************************************************************
5 ************************************************************************
7 Copyright (C) 2003-2004 GRAME, Centre National de Creation Musicale
8 ---------------------------------------------------------------------
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 ************************************************************************
23 ************************************************************************/
27 /*****************************************************************************
28 ******************************************************************************
30 Y. Orlarey, (c) Grame 2002
31 ------------------------------------------------------------------------------
32 box ::= i | f | p0 | p1 | p3
33 | _ | ! | a:b | a<:b | a,b | a:>b | a~b
37 2002-06-06 : First version
39 ******************************************************************************
40 *****************************************************************************/
47 /*****************************************************************************
48 ******************************************************************************
52 ******************************************************************************
53 *****************************************************************************/
56 /*****************************************************************************
58 *****************************************************************************/
60 Tree boxIdent(const char* name);
61 bool isBoxIdent(Tree t);
62 bool isBoxIdent(Tree t, const char** name);
65 /*****************************************************************************
67 *****************************************************************************/
70 Tree boxReal(double n);
72 bool isBoxInt(Tree t);
73 bool isBoxReal(Tree t);
75 bool isBoxInt(Tree t, int* i);
76 bool isBoxReal(Tree t, double* r);
79 /*****************************************************************************
81 *****************************************************************************/
86 bool isBoxWire(Tree t);
87 bool isBoxCut(Tree t);
90 /*****************************************************************************
91 Symbolic Boxes with symbolic slots
92 *****************************************************************************/
95 Tree boxSymbolic(Tree slot, Tree body);
97 bool isBoxSlot(Tree t);
98 bool isBoxSymbolic(Tree t);
100 bool isBoxSlot(Tree t, int* id);
101 bool isBoxSymbolic(Tree t, Tree& slot, Tree& body);
104 /*****************************************************************************
106 *****************************************************************************/
108 Tree boxSeq (Tree x, Tree y);
109 Tree boxPar (Tree x, Tree y);
110 Tree boxRec (Tree x, Tree y);
111 Tree boxSplit (Tree x, Tree y);
112 Tree boxMerge (Tree x, Tree y);
114 bool isBoxSeq (Tree t, Tree& x, Tree& y);
115 bool isBoxPar (Tree t, Tree& x, Tree& y);
116 bool isBoxRec (Tree t, Tree& x, Tree& y);
117 bool isBoxSplit (Tree t, Tree& x, Tree& y);
118 bool isBoxMerge (Tree t, Tree& x, Tree& y);
120 /*****************************************************************************
121 Algorithmic Composition of Boxes
122 *****************************************************************************/
124 Tree boxIPar(Tree x, Tree y, Tree z);
125 Tree boxISeq(Tree x, Tree y, Tree z);
126 Tree boxISum(Tree x, Tree y, Tree z);
127 Tree boxIProd(Tree x, Tree y, Tree z);
129 bool isBoxIPar(Tree t, Tree& x, Tree& y, Tree& z);
130 bool isBoxISeq(Tree t, Tree& x, Tree& y, Tree& z);
131 bool isBoxISum(Tree t, Tree& x, Tree& y, Tree& z);
132 bool isBoxIProd(Tree t, Tree& x, Tree& y, Tree& z);
135 /*****************************************************************************
136 Lambda-Calculus of Boxes
137 *****************************************************************************/
139 Tree buildBoxAbstr (Tree x, Tree y);
140 Tree buildBoxAppl (Tree x, Tree y);
142 Tree boxAbstr (Tree x, Tree y);
143 Tree boxAppl (Tree x, Tree y);
145 bool isBoxAbstr (Tree t);
146 bool isBoxAppl (Tree t);
148 bool isBoxAbstr (Tree t, Tree& x, Tree& y);
149 bool isBoxAppl (Tree t, Tree& x, Tree& y);
151 Tree closure (Tree abstr, Tree genv, Tree vis, Tree lenv);
153 bool isClosure (Tree t, Tree& abstr, Tree& genv, Tree& vis, Tree& lenv);
155 // for foo(x,y).faa expressions
156 Tree boxAccess (Tree exp, Tree id);
157 bool isBoxAccess(Tree t, Tree& exp, Tree& id);
160 /*****************************************************************************
161 Boxes with local definitions
162 *****************************************************************************/
164 Tree boxWithLocalDef (Tree body, Tree ldef);
165 bool isBoxWithLocalDef (Tree t, Tree& body, Tree& ldef);
168 /*****************************************************************************
169 Modification of local definitions
170 *****************************************************************************/
172 Tree boxModifLocalDef (Tree body, Tree ldef);
173 bool isBoxModifLocalDef (Tree t, Tree& body, Tree& ldef);
176 /*****************************************************************************
178 *****************************************************************************/
181 bool isBoxError(Tree t);
183 /*****************************************************************************
184 Primitive Boxes (n -> 1)
185 *****************************************************************************/
187 typedef Tree (*prim0)();
188 typedef Tree (*prim1)(Tree x);
189 typedef Tree (*prim2)(Tree x, Tree y);
190 typedef Tree (*prim3)(Tree x, Tree y, Tree z);
191 typedef Tree (*prim4)(Tree w, Tree x, Tree y, Tree z);
192 typedef Tree (*prim5)(Tree v, Tree w, Tree x, Tree y, Tree z);
194 Tree boxPrim0 (prim0 foo);
195 Tree boxPrim1 (prim1 foo);
196 Tree boxPrim2 (prim2 foo);
197 Tree boxPrim3 (prim3 foo);
198 Tree boxPrim4 (prim4 foo);
199 Tree boxPrim5 (prim5 foo);
201 bool isBoxPrim0 (Tree s);
202 bool isBoxPrim1 (Tree s);
203 bool isBoxPrim2 (Tree s);
204 bool isBoxPrim3 (Tree s);
205 bool isBoxPrim4 (Tree s);
206 bool isBoxPrim5 (Tree s);
208 bool isBoxPrim0 (Tree s, prim0* p);
209 bool isBoxPrim1 (Tree s, prim1* p);
210 bool isBoxPrim2 (Tree s, prim2* p);
211 bool isBoxPrim3 (Tree s, prim3* p);
212 bool isBoxPrim4 (Tree s, prim4* p);
213 bool isBoxPrim5 (Tree s, prim5* p);
216 /*****************************************************************************
218 *****************************************************************************/
220 Tree boxFFun (Tree ff);
221 bool isBoxFFun (Tree s);
222 bool isBoxFFun (Tree s, Tree& ff);
225 Tree boxFConst (Tree type, Tree name, Tree file);
226 bool isBoxFConst (Tree s);
227 bool isBoxFConst (Tree s, Tree& type, Tree& name, Tree& file);
230 Tree boxFVar (Tree type, Tree name, Tree file);
231 bool isBoxFVar (Tree s);
232 bool isBoxFVar (Tree s, Tree& type, Tree& name, Tree& file);
235 /*****************************************************************************
237 *****************************************************************************/
239 Tree boxEnvironment();
240 bool isBoxEnvironment (Tree s);
242 Tree boxComponent (Tree filename);
243 bool isBoxComponent (Tree s, Tree& filename);
245 Tree boxLibrary (Tree filename);
246 bool isBoxLibrary (Tree s, Tree& filename);
248 Tree importFile(Tree filename);
249 bool isImportFile(Tree s, Tree& filename);
252 /*****************************************************************************
253 User Interface Elements
254 *****************************************************************************/
256 Tree boxButton (Tree label);
257 bool isBoxButton (Tree s);
258 bool isBoxButton (Tree s, Tree& label);
260 Tree boxCheckbox (Tree label);
261 bool isBoxCheckbox (Tree s);
262 bool isBoxCheckbox (Tree s, Tree& label);
264 Tree boxVSlider (Tree label, Tree cur, Tree min, Tree max, Tree step);
265 bool isBoxVSlider (Tree s);
266 bool isBoxVSlider (Tree s, Tree& label, Tree& cur, Tree& min, Tree& max, Tree& step);
268 Tree boxHSlider (Tree label, Tree cur, Tree min, Tree max, Tree step);
269 bool isBoxHSlider (Tree s);
270 bool isBoxHSlider (Tree s, Tree& label, Tree& cur, Tree& min, Tree& max, Tree& step);
272 Tree boxNumEntry (Tree label, Tree cur, Tree min, Tree max, Tree step);
273 bool isBoxNumEntry (Tree s);
274 bool isBoxNumEntry (Tree s, Tree& label, Tree& cur, Tree& min, Tree& max, Tree& step);
276 Tree boxVGroup (Tree label, Tree x);
277 bool isBoxVGroup (Tree s);
278 bool isBoxVGroup (Tree s, Tree& label, Tree& x);
280 Tree boxHGroup (Tree label, Tree x);
281 bool isBoxHGroup (Tree s);
282 bool isBoxHGroup (Tree s, Tree& label, Tree& x);
284 Tree boxTGroup (Tree label, Tree x);
285 bool isBoxTGroup (Tree s);
286 bool isBoxTGroup (Tree s, Tree& label, Tree& x);
289 Tree boxVBargraph (Tree label, Tree min, Tree max);
290 bool isBoxVBargraph (Tree s);
291 bool isBoxVBargraph (Tree s, Tree& label, Tree& min, Tree& max);
293 Tree boxHBargraph (Tree label, Tree min, Tree max);
294 bool isBoxHBargraph (Tree s);
295 bool isBoxHBargraph (Tree s, Tree& label, Tree& min, Tree& max);
298 /*****************************************************************************
299 case (pattern matching)
300 *****************************************************************************/
301 Tree boxCase (Tree rules);
302 bool isBoxCase (Tree s);
303 bool isBoxCase (Tree s, Tree& rules);
305 Tree boxPatternMatcher (Automaton* a, int state, Tree env, Tree origRules, Tree revParamList);
306 bool isBoxPatternMatcher (Tree s);
307 bool isBoxPatternMatcher (Tree s, Automaton*& a, int& state, Tree& env, Tree& origRules, Tree& revParamList);
309 // wrap an id into a pattern variable
310 Tree boxPatternVar (Tree id);
311 bool isBoxPatternVar(Tree s, Tree& id);
314 /*****************************************************************************
315 ******************************************************************************
319 ******************************************************************************
320 *****************************************************************************/
322 // return the number of input
323 bool getBoxType (Tree box, int* inum, int* onum);