00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef _XMLPROGPARSER_H_
00020 #define _XMLPROGPARSER_H_
00021
00022 class Global;
00023 class Cluster;
00024 class Prog;
00025 class Proc;
00026 class UserProc;
00027 class LibProc;
00028 class Signature;
00029 class StatementSet;
00030 class Cluster;
00031 class Context;
00032 class Type;
00033 class Exp;
00034 class Cfg;
00035 class BasicBlock;
00036 class RTL;
00037
00038 #define MAX_STACK 1024
00039
00040 typedef struct {
00041 const char *tag;
00042 void (XMLProgParser::*start_proc)(const char**);
00043 void (XMLProgParser::*end_proc)(Context *c, int e);
00044 } _tag;
00045
00046 class XMLProgParser
00047 {
00048 public:
00049 XMLProgParser() { }
00050 Prog *parse(const char *filename);
00051 void persistToXML(Prog *prog);
00052 void handleElementStart(const char *el, const char **attr);
00053 void handleElementEnd(const char *el);
00054
00055 protected:
00056
00057 void parseFile(const char *filename);
00058 void parseChildren(Cluster *c);
00059
00060 #define TAGD(x) void start_ ## x (const char **attr); \
00061 void addToContext_ ## x (Context *c, int e);
00062
00063 TAGD(prog)
00064 TAGD(procs)
00065 TAGD(global)
00066 TAGD(cluster)
00067 TAGD(libproc)
00068 TAGD(userproc)
00069 TAGD(local)
00070 TAGD(symbol)
00071 TAGD(secondexp)
00072 TAGD(proven_true)
00073 TAGD(callee)
00074 TAGD(caller)
00075 TAGD(defines)
00076 TAGD(signature)
00077 TAGD(param)
00078 TAGD(return)
00079 TAGD(rettype)
00080 TAGD(prefparam)
00081 TAGD(prefreturn)
00082 TAGD(cfg)
00083 TAGD(bb)
00084 TAGD(inedge)
00085 TAGD(outedge)
00086 TAGD(livein)
00087 TAGD(order)
00088 TAGD(revorder)
00089 TAGD(rtl)
00090 TAGD(stmt)
00091 TAGD(assign)
00092 TAGD(assignment)
00093 TAGD(phiassign)
00094 TAGD(lhs)
00095 TAGD(rhs)
00096 TAGD(callstmt)
00097 TAGD(dest)
00098 TAGD(argument)
00099 TAGD(returnexp)
00100 TAGD(returntype)
00101 TAGD(returnstmt)
00102 TAGD(returns)
00103 TAGD(modifieds)
00104 TAGD(gotostmt)
00105 TAGD(branchstmt)
00106 TAGD(cond)
00107 TAGD(casestmt)
00108 TAGD(boolasgn)
00109 TAGD(type)
00110 TAGD(exp)
00111 TAGD(voidtype)
00112 TAGD(integertype)
00113 TAGD(pointertype)
00114 TAGD(chartype)
00115 TAGD(namedtype)
00116 TAGD(arraytype)
00117 TAGD(basetype)
00118 TAGD(sizetype)
00119 TAGD(location)
00120 TAGD(unary)
00121 TAGD(binary)
00122 TAGD(ternary)
00123 TAGD(const)
00124 TAGD(terminal)
00125 TAGD(typedexp)
00126 TAGD(refexp)
00127 TAGD(def)
00128 TAGD(subexp1)
00129 TAGD(subexp2)
00130 TAGD(subexp3)
00131
00132 void persistToXML(std::ostream &out, Global *g);
00133 void persistToXML(std::ostream &out, Cluster *c);
00134 void persistToXML(std::ostream &out, Proc *proc);
00135 void persistToXML(std::ostream &out, LibProc *proc);
00136 void persistToXML(std::ostream &out, UserProc *proc);
00137 void persistToXML(std::ostream &out, Signature *sig);
00138 void persistToXML(std::ostream &out, Type *ty);
00139 void persistToXML(std::ostream &out, Exp *e);
00140 void persistToXML(std::ostream &out, Cfg *cfg);
00141 void persistToXML(std::ostream &out, BasicBlock *bb);
00142 void persistToXML(std::ostream &out, RTL *rtl);
00143 void persistToXML(std::ostream &out, Statement *stmt);
00144
00145 static _tag tags[];
00146
00147 int operFromString(const char *s);
00148 const char *getAttr(const char **attr, const char *name);
00149
00150 std::list<Context*> stack;
00151 std::map<int, void*> idToX;
00152 int phase;
00153
00154 void addId(const char **attr, void *x);
00155 void *findId(const char *id);
00156 };
00157
00158 #endif