cpp_token_stream.cxx

Go to the documentation of this file.
00001 
00002 //
00003 // Copyright 2002, Lowell Boggs Jr.
00004 //
00005 // This file or directory, containing source code for a computer program,
00006 // is Copyrighted by Lowell Boggs, Jr.  987 Regency Drive, Lewisville
00007 // TX (USA), 75067.  You may use, copy, modify, and distribute this
00008 // source file without charge or obligation so long as you agree to
00009 // the following:
00010 //
00011 //  1.  You must indemnify Lowell Boggs against any and all financial
00012 //      obligations caused by its use, misuse, function, or malfunction.
00013 //      Further, you acknowledge that there is no warranty of any kind,
00014 //      whatsoever.
00015 //
00016 //  2.  You agree not to attempt to patent any portion of this original
00017 //      work -- though you may attempt to patent your own extensions to
00018 //      it if you so choose.
00019 //
00020 //  3.  You keep this copyright notice with the file and all copies
00021 //      of the file and do not change it anyway except language translation.
00022 //
00023 // You are responsible for enforcing your own compliance with these
00024 // conditions and may not use this source file if you cannot agree to the
00025 // above terms and conditions.
00026 
00029 
00030 
00031 #include <cxxtls/cpp_token_stream.h>
00032 #include <portable_io.h>
00033 
00034 namespace cxxtls
00035 {
00036 
00037 std::string
00038 CPP_Token::
00039 type_name(int id)
00040 {
00041   switch(id)
00042   {
00043     case eof : return "<eof>";
00044     case eql : return "==";
00045     case neq : return "!=";
00046     case leq : return "<=";
00047     case geq : return ">=";
00048     case sle : return "<<=";
00049     case sre : return ">>=";
00050     case dve : return "/=";
00051     case ple : return "+=";
00052     case mne : return "-=";
00053     case tme : return "*=";
00054     case mde : return "%=";
00055     case adr : return "& ";
00056     case orr : return "||";
00057     case ore : return "|=";
00058     case ade : return "&=";
00059     case inc : return "++";
00060     case dec : return "--";
00061     case shr : return ">>";
00062     case shl : return "<<";
00063     case lan : return "&&";
00064     case der : return "::";
00065     case teq : return "~=";
00066     case ceq : return "^=";
00067     case eli : return "...";
00068     case nmb : return "number";
00069     case aln : return "identifier";
00070     case inv : return "invalid operator";
00071 
00072     default:
00073 
00074       if(id > 0x100)
00075       {
00076         char buf[40];
00077         
00078         sprintf(buf, "<%03x>", id);
00079         
00080         return buf;
00081       }
00082   }
00083 
00084   char buffer[2];
00085 
00086   buffer[0] = id;
00087   buffer[1] = 0;
00088 
00089   return buffer;
00090 
00091 }
00092 } // namespace cxxtls
Generated on Wed Feb 29 22:50:04 2012 for CXXUtilities by  doxygen 1.6.3