1 /*
2   GUIDO Library
3   Copyright (C) 2008  Grame
4 
5   This library is free software; you can redistribute it and/or
6   modify it under the terms of the GNU Lesser General Public
7   License as published by the Free Software Foundation; either
8   version 2.1 of the License, or (at your option) any later version.
9 
10   This library is distributed in the hope that it will be useful,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13   Lesser General Public License for more details.
14 
15   You should have received a copy of the GNU Lesser General Public
16   License along with this library; if not, write to the Free Software
17   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18 
19   Grame Research Laboratory, 9 rue du Garet, 69001 Lyon - France
20   research@grame.fr
21 
22 */
23 
24 #ifndef __guidoExpReader__
25 #define __guidoExpReader__
26 
27 #include <map>
28 #include <string>
29 
30 #include "guidoexpression.h"
31 #include "glangreader.h"
32 
33 namespace guidolang
34 {
35 
36 //______________________________________________________________________________
37 /*!
38 \brief	An concrete class supporting the glang parser interface.
39 */
40 class guidoExpReader : public glangreader
41 {
42 	public:
43 		typedef std::map<std::string, SGLExpr> ExpList;
44 
45 		int				version() const;
46 		const char*		versionStr() const;
47 
48 		bool parseFile  (FILE* fd);
49 		bool parseFile  (const char* file);
50 		bool parseString(const char* string);
51 
52 		virtual void	 newIDExpr			(const char *, SGLExpr*);
53 		virtual SGLExpr* newScoreExpr		(const char *);
54 		virtual SGLExpr* newBinaryExpr		(const char *, SGLExpr*, SGLExpr*);
55 		virtual SGLExpr* newAbstractExpr	(const char *, SGLExpr*, SGLExpr*);
56 		virtual SGLExpr* newNamedExpr		(const char *);
57 		virtual SGLExpr* newGroupExpr		(SGLExpr*);
58 
59 		virtual int error(const char * msg, int lineno);
60 
clear()61 		virtual void			clear()					{ return fExprMap.clear(); }
getEnv()62 		virtual const ExpList&	getEnv()				{ return fExprMap; }
63 		virtual SGLExpr			getId(const std::string& id);
64 
65 	protected:
66 		ExpList	fExprMap;
67 };
68 
69 } // namespace
70 
71 #endif
72