Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

ptree.h

Go to the documentation of this file.
00001 /*
00002   Copyright (C) 1997-2001 Shigeru Chiba, Tokyo Institute of Technology.
00003 
00004   Permission to use, copy, distribute and modify this software and   
00005   its documentation for any purpose is hereby granted without fee,        
00006   provided that the above copyright notice appear in all copies and that 
00007   both that copyright notice and this permission notice appear in 
00008   supporting documentation.
00009 
00010   Shigeru Chiba makes no representations about the suitability of this 
00011   software for any purpose.  It is provided "as is" without express or
00012   implied warranty.
00013 */
00014 
00015 #ifndef _ptree_h
00016 #define _ptree_h
00017 
00018 #include "ptree-core.h"
00019 #include "token.h"
00020 #include "buffer.h"
00021 
00022 class Encoding;
00023 
00024 class Leaf : public Ptree {
00025 public:
00026     Leaf(char*, int);
00027     Leaf(Token&);
00028     bool IsLeaf();
00029 
00030     void Print(ostream&, int, int);
00031     int Write(ostream&, int);
00032     void WritePS(ProgramString&);
00033 };
00034 
00035 class LeafName : public Leaf {
00036 public:
00037     LeafName(Token&);
00038     Ptree* Translate(Walker*);
00039     void Typeof(Walker*, TypeInfo&);
00040 };
00041 
00042 // class DupLeaf is used by Ptree::Make() and QuoteClass (qMake()).
00043 // The string given to the constructors are duplicated.
00044 
00045 class DupLeaf : public Leaf {
00046 public:
00047     DupLeaf(char*, int);
00048     DupLeaf(char*, int, char*, int);
00049 
00050     void Print(ostream&, int, int);
00051 };
00052 
00053 class LeafReserved : public Leaf {
00054 public:
00055     LeafReserved(Token& t) : Leaf(t) {}
00056     LeafReserved(char* str, int len) : Leaf(str, len) {}
00057 };
00058 
00059 class LeafThis : public LeafReserved {
00060 public:
00061     LeafThis(Token& t) : LeafReserved(t) {}
00062     int What();
00063     Ptree* Translate(Walker*);
00064     void Typeof(Walker*, TypeInfo&);
00065 };
00066 
00067 #define ResearvedWordDecl(w) \
00068 class Leaf##w : public LeafReserved { \
00069 public: \
00070     Leaf##w(Token& t) : LeafReserved(t) {} \
00071     Leaf##w(char* str, int len) : LeafReserved(str, len) {} \
00072     int What(); \
00073 }
00074 
00075 ResearvedWordDecl(AUTO);
00076 ResearvedWordDecl(BOOLEAN);
00077 ResearvedWordDecl(CHAR);
00078 ResearvedWordDecl(CONST);
00079 ResearvedWordDecl(DOUBLE);
00080 ResearvedWordDecl(EXTERN);
00081 ResearvedWordDecl(FLOAT);
00082 ResearvedWordDecl(FRIEND);
00083 ResearvedWordDecl(INLINE);
00084 ResearvedWordDecl(INT);
00085 ResearvedWordDecl(LONG);
00086 ResearvedWordDecl(MUTABLE);
00087 ResearvedWordDecl(NAMESPACE);
00088 ResearvedWordDecl(PRIVATE);
00089 ResearvedWordDecl(PROTECTED);
00090 ResearvedWordDecl(PUBLIC);
00091 ResearvedWordDecl(REGISTER);
00092 ResearvedWordDecl(SHORT);
00093 ResearvedWordDecl(SIGNED);
00094 ResearvedWordDecl(STATIC);
00095 ResearvedWordDecl(UNSIGNED);
00096 ResearvedWordDecl(USING);
00097 ResearvedWordDecl(VIRTUAL);
00098 ResearvedWordDecl(VOID);
00099 ResearvedWordDecl(VOLATILE);
00100 
00101 ResearvedWordDecl(UserKeyword2);
00102 
00103 #undef ResearvedWordDecl
00104 
00105 class NonLeaf : public Ptree {
00106 public:
00107     NonLeaf(Ptree*, Ptree*);
00108     bool IsLeaf();
00109 
00110     void Print(ostream&, int, int);
00111     int Write(ostream&, int);
00112     void PrintWithEncodeds(ostream&, int, int);
00113     void WritePS(ProgramString&);
00114 
00115 protected:
00116     bool TooDeep(ostream&, int);
00117 };
00118 
00119 class PtreeBrace : public NonLeaf {
00120 public:
00121     PtreeBrace(Ptree* p, Ptree* q) : NonLeaf(p, q) {}
00122     PtreeBrace(Ptree* ob, Ptree* body, Ptree* cb)
00123         : NonLeaf(ob, Ptree::List(body, cb)) {}
00124 
00125     void Print(ostream&, int, int);
00126     int Write(ostream&, int);
00127 
00128     Ptree* Translate(Walker*);
00129 };
00130 
00131 class PtreeBlock : public PtreeBrace {
00132 public:
00133     PtreeBlock(Ptree* p, Ptree* q) : PtreeBrace(p, q) {}
00134     PtreeBlock(Ptree* ob, Ptree* bdy, Ptree* cb) : PtreeBrace(ob, bdy, cb) {}
00135 
00136     Ptree* Translate(Walker*);
00137 };
00138 
00139 class PtreeClassBody : public PtreeBrace {
00140 public:
00141     PtreeClassBody(Ptree* p, Ptree* q) : PtreeBrace(p, q) {}
00142     PtreeClassBody(Ptree* ob, Ptree* bdy, Ptree* cb)
00143                                                 : PtreeBrace(ob, bdy, cb) {}
00144 
00145     Ptree* Translate(Walker*);
00146 };
00147 
00148 class PtreeTypedef : public NonLeaf {
00149 public:
00150     PtreeTypedef(Ptree* p) : NonLeaf(p, nil) {}
00151     PtreeTypedef(Ptree* p, Ptree* q) : NonLeaf(p, q) {}
00152     int What();
00153     Ptree* Translate(Walker*);
00154 };
00155 
00156 class PtreeTemplateDecl : public NonLeaf {
00157 public:
00158     PtreeTemplateDecl(Ptree* p, Ptree* q) : NonLeaf(p, q) {}
00159     PtreeTemplateDecl(Ptree* p) : NonLeaf(p, nil) {}
00160     int What();
00161     Ptree* Translate(Walker*);
00162 };
00163 
00164 class PtreeTemplateInstantiation : public NonLeaf {
00165 public:
00166     PtreeTemplateInstantiation(Ptree* p) : NonLeaf(p, nil) {}
00167     int What();
00168     Ptree* Translate(Walker*);
00169 };
00170 
00171 class PtreeExternTemplate : public NonLeaf {
00172 public:
00173     PtreeExternTemplate(Ptree* p, Ptree* q) : NonLeaf(p, q) {}
00174     PtreeExternTemplate(Ptree* p) : NonLeaf(p, nil) {}
00175     int What();
00176     Ptree* Translate(Walker*);
00177 };
00178 
00179 class PtreeMetaclassDecl : public NonLeaf {
00180 public:
00181     PtreeMetaclassDecl(Ptree* p, Ptree* q) : NonLeaf(p, q) {}
00182     int What();
00183     Ptree* Translate(Walker*);
00184 };
00185 
00186 class PtreeLinkageSpec : public NonLeaf {
00187 public:
00188     PtreeLinkageSpec(Ptree* p, Ptree* q) : NonLeaf(p, q) {}
00189     int What();
00190     Ptree* Translate(Walker*);
00191 };
00192 
00193 class PtreeNamespaceSpec : public NonLeaf {
00194 public:
00195     PtreeNamespaceSpec(Ptree* p, Ptree* q) : NonLeaf(p, q) {}
00196     int What();
00197     Ptree* Translate(Walker*);
00198 };
00199 
00200 class PtreeUsing : public NonLeaf {
00201 public:
00202     PtreeUsing(Ptree* p, Ptree* q, Ptree* r, Encoding& e, Ptree* s);
00203     int What();
00204     Ptree* Translate(Walker*);
00205 
00206     /* the encoded name of the symbol or namespace specified
00207      * by this using declaration.
00208      */
00209     char* GetEncodedName();
00210 
00211     /* true if this using declaration specifies a namespace.
00212      */
00213     bool isNamespace() { return bool(Cadr() != nil); }
00214 
00215 private:
00216     char* name;
00217 };
00218 
00219 class PtreeDeclaration : public NonLeaf {
00220 public:
00221     PtreeDeclaration(Ptree* p, Ptree* q) : NonLeaf(p, q) {}
00222     int What();
00223     Ptree* Translate(Walker*);
00224 };
00225 
00226 class PtreeDeclarator : public NonLeaf {
00227 public:
00228     PtreeDeclarator(Ptree*, Encoding&, Encoding&, Ptree*);
00229     PtreeDeclarator(Encoding&, Encoding&, Ptree*);
00230     PtreeDeclarator(Ptree*, Ptree*, Encoding&, Encoding&, Ptree*);
00231     PtreeDeclarator(Ptree*, Encoding&);
00232     PtreeDeclarator(Encoding&);
00233     PtreeDeclarator(PtreeDeclarator*, Ptree*, Ptree*);
00234 
00235     int What();
00236     char* GetEncodedType();
00237     char* GetEncodedName();
00238     Ptree* Name() { return declared_name; }
00239     void Print(ostream&, int, int);
00240 
00241     Ptree* GetComments() { return comments; }
00242     void SetComments(Ptree* c) { comments = c; }
00243 
00244 private:
00245     char* type;
00246     char* name;
00247     Ptree* declared_name;
00248     Ptree* comments;
00249 };
00250 
00251 class PtreeName : public NonLeaf {
00252 public:
00253     PtreeName(Ptree*, Encoding&);
00254     int What();
00255     char* GetEncodedName();
00256     void Print(ostream&, int, int);
00257     Ptree* Translate(Walker*);
00258     void Typeof(Walker*, TypeInfo&);
00259 
00260 private:
00261     char* name;
00262 };
00263 
00264 class PtreeFstyleCastExpr : public NonLeaf {
00265 public:
00266     PtreeFstyleCastExpr(Encoding&, Ptree*, Ptree*);
00267     PtreeFstyleCastExpr(char*, Ptree*, Ptree*);
00268     int What();
00269     char* GetEncodedType();
00270     void Print(ostream&, int, int);
00271     Ptree* Translate(Walker*);
00272     void Typeof(Walker*, TypeInfo&);
00273 
00274 private:
00275     char* type;
00276 };
00277 
00278 class PtreeClassSpec : public NonLeaf {
00279 public:
00280     PtreeClassSpec(Ptree*, Ptree*, Ptree*);
00281     PtreeClassSpec(Ptree*, Ptree*, Ptree*, char*);
00282     int What();
00283     Ptree* Translate(Walker*);
00284     char* GetEncodedName();
00285     Ptree* GetComments();
00286 
00287 private:
00288     char* encoded_name;
00289     Ptree* comments;
00290 
00291 friend class Parser;
00292 };
00293 
00294 class PtreeEnumSpec : public NonLeaf {
00295 public:
00296     PtreeEnumSpec(Ptree*);
00297     int What();
00298     Ptree* Translate(Walker*);
00299     char* GetEncodedName();
00300 
00301 private:
00302     char* encoded_name;
00303 
00304 friend class Parser;
00305 };
00306 
00307 class PtreeAccessSpec : public NonLeaf {
00308 public:
00309     PtreeAccessSpec(Ptree*, Ptree*);
00310     int What();
00311     Ptree* Translate(Walker*);
00312 };
00313 
00314 class PtreeAccessDecl : public NonLeaf {
00315 public:
00316     PtreeAccessDecl(Ptree*, Ptree*);
00317     int What();
00318     Ptree* Translate(Walker*);
00319 };
00320 
00321 class PtreeUserAccessSpec : public NonLeaf {
00322 public:
00323     PtreeUserAccessSpec(Ptree*, Ptree*);
00324     int What();
00325     Ptree* Translate(Walker*);
00326 };
00327 
00328 class PtreeUserdefKeyword : public NonLeaf {
00329 public:
00330     PtreeUserdefKeyword(Ptree*, Ptree*);
00331     int What();
00332 };
00333 
00334 #define PtreeStatementDecl(s)\
00335 class Ptree##s##Statement : public NonLeaf {\
00336 public:\
00337     Ptree##s##Statement(Ptree* p, Ptree* q) : NonLeaf(p, q) {}\
00338     int What();\
00339     Ptree* Translate(Walker*);\
00340 }
00341 
00342 PtreeStatementDecl(If);
00343 PtreeStatementDecl(Switch);
00344 PtreeStatementDecl(While);
00345 PtreeStatementDecl(Do);
00346 PtreeStatementDecl(For);
00347 PtreeStatementDecl(Try);
00348 PtreeStatementDecl(Break);
00349 PtreeStatementDecl(Continue);
00350 PtreeStatementDecl(Return);
00351 PtreeStatementDecl(Goto);
00352 PtreeStatementDecl(Case);
00353 PtreeStatementDecl(Default);
00354 PtreeStatementDecl(Label);
00355 PtreeStatementDecl(Expr);
00356 
00357 #undef PtreeStatementDecl
00358 
00359 #define PtreeExprDecl(n)\
00360 class Ptree##n##Expr : public NonLeaf {\
00361 public:\
00362     Ptree##n##Expr(Ptree* p, Ptree* q) : NonLeaf(p, q) {}\
00363     int What();\
00364     Ptree* Translate(Walker*);\
00365     void Typeof(Walker*, TypeInfo&);\
00366 }
00367 
00368 PtreeExprDecl(Comma);
00369 PtreeExprDecl(Assign);
00370 PtreeExprDecl(Cond);
00371 PtreeExprDecl(Infix);
00372 PtreeExprDecl(Pm);
00373 PtreeExprDecl(Cast);
00374 PtreeExprDecl(Unary);
00375 PtreeExprDecl(Throw);
00376 PtreeExprDecl(Sizeof);
00377 PtreeExprDecl(New);
00378 PtreeExprDecl(Delete);
00379 PtreeExprDecl(Array);
00380 PtreeExprDecl(Funcall);
00381 PtreeExprDecl(Postfix);
00382 PtreeExprDecl(UserStatement);
00383 PtreeExprDecl(DotMember);
00384 PtreeExprDecl(ArrowMember);
00385 PtreeExprDecl(Paren);
00386 PtreeExprDecl(StaticUserStatement);
00387 
00388 #undef PtreeExprDecl
00389 
00390 #endif /* _ptree_h */

Generated on Mon Feb 10 17:32:55 2003 for VFiasco Semantics Compiler by doxygen1.2.15