Modules | Files | Inheritance Tree | Inheritance Graph | Name Index | Config
File: Synopsis/Parser/C++/occ/encoding.h
    1| /*
    2|   Copyright (C) 1997-2000 Shigeru Chiba, University of Tsukuba.
    3| 
    4|   Permission to use, copy, distribute and modify this software and   
    5|   its documentation for any purpose is hereby granted without fee,        
    6|   provided that the above copyright notice appear in all copies and that 
    7|   both that copyright notice and this permission notice appear in 
    8|   supporting documentation.
    9| 
   10|   Shigeru Chiba makes no representations about the suitability of this 
   11|   software for any purpose.  It is provided "as is" without express or
   12|   implied warranty.
   13| */
   14| 
   15| #ifndef _encoding_h
   16| #define _encoding_h
   17| 
   18| #include <iosfwd>
   19| #include "types.h"
   20| 
   21| class Ptree;
   22| class Environment;
   23| class Bind;
   24| 
   25| class Encoding {
   26| public:
   27|     enum { MaxNameLen = 4096 }; // const MaxNameLen = 256;
   28|                              // MSVC doesn't compile
   29|     Encoding() { len = 0; }
   30|     Encoding(Encoding& e) { Reset(e); }
   31|     static void do_init_static();
   32|     void Clear() { len = 0; }
   33|     void Reset(Encoding&);
   34|     charGet();
   35|     bool IsEmpty() { return len == 0; }
   36| 
   37|     void CvQualify(Ptree*, Ptree* = nil);
   38|     void SimpleConst() { Append("Ci"2); }
   39|     void GlobalScope();               // ::Type
   40|     void SimpleName(Ptree*);
   41|     void NoName();
   42|     void Template(Ptree*, Encoding&);
   43|     void Qualified(int);
   44|     void Destructor(Ptree*);
   45|     void PtrOperator(int);
   46|     void PtrToMember(Encoding&, int);
   47|     void CastOperator(Encoding&);
   48|     void Array() { Insert('A'); }
   49|     void Function(Encoding& args) { Insert((char*)args.nameargs.len); }
   50|     void Recursion(Encoding& e) { Insert((char*)e.namee.len); }
   51|     void StartFuncArgs() { Append((unsigned char)'F'); }
   52|     void EndFuncArgs() { Append((unsigned char)'_'); }
   53|     void Void() { Append((unsigned char)'v'); }
   54|     void EllipsisArg() { Append((unsigned char)'e'); }
   55|     void NoReturnType() { Append((unsigned char)'?'); }
   56|     void ValueTempParam() { Append((unsigned char)'*'); }
   57| 
   58|     void Insert(unsigned char);
   59|     void Insert(char*, int);
   60|     void Append(unsigned char);
   61|     void Append(char*, int);
   62|     void Append(Encoding& e) { Append((char*)e.namee.len); }
   63|     void AppendWithLen(char*, int);
   64|     void AppendWithLen(Encoding& e) { AppendWithLen((char*)e.namee.len); }
   65| 
   66|     static void Print(std::ostream&, char*);
   67|     static charGetBaseName(char*, int&, Environment*&);
   68|     static Ptree* MakePtree(unsigned char*&, Ptree*);
   69| 
   70|     static Ptree* MakeQname(unsigned char*&);
   71|     static Ptree* MakeLeaf(unsigned char*&);
   72|     static bool IsSimpleName(unsigned char*);
   73|     static Ptree* NameToPtree(char*, int);
   74| 
   75|     static unsigned charGetTemplateArguments(unsigned char*, int&);
   76| 
   77| private:
   78|     static Environment* ResolveTypedefName(Environment*, char*, int);
   79|     static int GetBaseNameIfTemplate(unsigned char*, Environment*&);
   80| 
   81| private:
   82|     unsigned char name[MaxNameLen];
   83|     int len;
   84| 
   85| public:
   86|     static Ptree *bool_t, *char_t, *int_t, *short_t, *long_t,
   87|                 *float_t, *double_t, *void_t;
   88| 
   89|     static Ptree *signed_t, *unsigned_t, *const_t, *volatile_t;
   90| 
   91|     static Ptree *operator_name, *new_operator, *anew_operator,
   92|                 *delete_operator, *adelete_operator;
   93| 
   94|     static Ptree *star, *ampersand, *comma, *dots, *scope, *tilder,
   95|                 *left_paren, *right_paren, *left_bracket, *right_bracket,
   96|                 *left_angle, *right_angle;
   97| };
   98| 
   99| #endif /* _encoding_h */