00001 /* 00002 * File: macro_expander.hh 00003 * $Id: macro_token_expander.hh,v 1.3 2002/06/26 20:48:55 alec Exp $ 00004 * 00005 * Author: Alec Panovici (alecu@email.com) 00006 * 00007 * Comments: 00008 * 00009 * Revision history: 00010 * 00011 * $Log: macro_token_expander.hh,v $ 00012 * Revision 1.3 2002/06/26 20:48:55 alec 00013 * g++ 3.x happy 00014 * 00015 * Revision 1.2 2002/05/27 03:02:10 alec 00016 * doc update 00017 * 00018 * Revision 1.1 2002/04/29 17:57:35 alec 00019 * *** empty log message *** 00020 * 00021 */ 00022 00023 00024 /* 00025 Copyright (C) 2002 Alexandru Panoviciu (alecu@email.com) 00026 00027 This program is free software; you can redistribute it and/or modify 00028 it under the terms of the GNU General Public License as published by 00029 the Free Software Foundation; either version 2 of the License, or 00030 (at your option) any later version. 00031 00032 This program is distributed in the hope that it will be useful, 00033 but WITHOUT ANY WARRANTY; without even the implied warranty of 00034 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00035 GNU General Public License for more details. 00036 00037 You should have received a copy of the GNU General Public License 00038 along with this program; if not, write to the Free Software 00039 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00040 00041 */ 00042 00043 #ifndef __MACRO_TOKEN_EXPANDER_HH__ 00044 #define __MACRO_TOKEN_EXPANDER_HH__ 00045 00046 #include <string> 00047 #include <map> 00048 using namespace std; 00049 00050 00051 #include "parse_util.hh" 00052 00053 class ReNode; 00054 00060 class MacroTokenExpander 00061 { 00062 public: 00063 00068 void addMacro (const string &name, ReNode *regexp, const Position &pos); 00069 00075 ReNode* getMacro (const string &name) throw (ParseException); 00076 00077 typedef struct t_MacroDef 00078 { 00079 Position pos; 00080 ReNode *regexp; 00081 00082 t_MacroDef (ReNode *regexp_, const Position &pos_) : 00083 regexp(regexp_), pos(pos_) 00084 {} 00085 00086 t_MacroDef (const t_MacroDef &o) : 00087 regexp(o.regexp), pos(o.pos) 00088 {} 00089 00090 t_MacroDef () : regexp(NULL) 00091 {} 00092 00093 } MacroDef; 00094 00095 private: 00096 00097 map<string, MacroDef> macros; 00098 }; 00099 00100 #endif /* #ifndef __MACRO_TOKEN_EXPANDER_HH__ */