Click here to Skip to main content
15,895,746 members
Articles / Desktop Programming / MFC

Another Enum Viewer

Rate me:
Please Sign up or sign in to vote.
4.50/5 (2 votes)
22 Oct 20015 min read 83K   1.3K   19  
An article on the usage and design of another Enum Viewer
// CPPParserSymExpr.cpp: Creation of expressions for the grammar

#include "CPPParserSym.h"
#include "CPPSymTable.h"
#include "CPPExpr.h"

CPPExprRefI 
CPPParserSym::MakeExprBinary(
   CPPExprRefI lhs,
   CPPExprRefI rhs,
   ANTLRTokenType opToken
)
{
   return new CPPExprBinary(lhs, rhs, opToken);
}

CPPExprRefI 
CPPParserSym::MakeExprUnary(
   CPPExprRefI rhs,
   ANTLRTokenType opToken
)
{
   return new CPPExprUnary(rhs, opToken);
}

CPPExprRefI 
CPPParserSym::MakeExprConditional(
   CPPExprRefI condition,
   CPPExprRefI lhs,
   CPPExprRefI rhs
)
{
   return new CPPExprConditional(condition, lhs, rhs);
}

CPPExprRefI 
CPPParserSym::MakeExprLiteral(
   ANTLRTokenType tokType,
   const JLStr& tokText
)
{
   return new CPPExprLiteral(tokType, tokText);
}

CPPExprRefI 
CPPParserSym::MakeExprSizeofExpr(
   CPPExprRefI expr
)
{
   return new CPPExprSizeofExpr(expr);
}

CPPExprRefI 
CPPParserSym::MakeExprSizeofType(
   CPPTypeRefI type
)
{
   return new CPPExprSizeofType(type);
}

CPPExprRefI 
CPPParserSym::MakeExprId(
   CPPDeclRefI decl
)
{
   return new CPPExprId(decl);
}

CPPExprRefI 
CPPParserSym::MakeExprNewCast(
   ANTLRTokenType castTokenType,
   CPPTypeRefI castType,
   CPPExprRefI expr
) 
{
   CPPExprCast::CastFlavor castFlavor;
   switch (castTokenType)
   {
      case TOK_CONST_CAST:
         castFlavor = CPPExprCast::Const;
         break;
      case TOK_DYNAMIC_CAST:
         castFlavor = CPPExprCast::Dynamic;
         break;
      case TOK_REINTERPRET_CAST:
         castFlavor = CPPExprCast::Reinterpret;
         break;
      case TOK_STATIC_CAST:
         castFlavor = CPPExprCast::Static;
         break;
      default:
         assert(0);
         break;
   }
   return new CPPExprCast(castFlavor, castType, expr);
}

CPPExprRefI 
CPPParserSym::MakeExprTraditionalCast(
   CPPTypeRefI castType,
   CPPExprRefI expr
)
{
   return new CPPExprCast(CPPExprCast::Traditional, castType, expr);
}

CPPExprRefI 
CPPParserSym::MakeExprFunctionLikeCast(
   CPPTypeRefI castType,
   CPPExprRefI expr
)
{
   return new CPPExprCast(CPPExprCast::FunctionLike, castType, expr);
}

CPPExprRefI 
CPPParserSym::MakeExprNew(
   CPPExprRefI placementExpr, 
   CPPTypeRefI rawType, 
   CPPExprRefI arraySizeExpr, 
   CPPExprRefI initExpr,
   const ANTLRTokenPtr& errTok
)
{
   CPPTypeRefI arrayType;

   // Determine the array type, which is the same as the raw type 
   // when the arraySizeExpr is nil
   if (arraySizeExpr.get() == 0)
   {
      arrayType = rawType;
   } else {
      arrayType = symTable->LookupArrayOfType(rawType, CPPExprRefI(), errTok);
   }

   return new CPPExprNew(placementExpr, rawType, arrayType, arraySizeExpr, initExpr);
}


CPPExprRefI 
CPPParserSym::MakeExprDelete(
   CPPExprRefI exprToDelete, 
   bool deleteArray
)
{
   return new CPPExprDelete(exprToDelete, deleteArray);
}


CPPExprRefI 
CPPParserSym::MakeExprFunctionCall(
   CPPExprRefI exprFunction, 
   CPPExprRefI exprArgList
)
{
   return new CPPExprFunctionCall(exprFunction, exprArgList);
}


CPPExprRefI 
CPPParserSym::MakeExprPostop(
   CPPExprRefI exprLhs, 
   ANTLRTokenType tt
)
{
   return new CPPExprPostop(exprLhs, tt);
}


CPPExprRefI 
CPPParserSym::MakeExprThis()
{
   return new CPPExprThis();
}


CPPExprRefI 
CPPParserSym::MakeExprArraySubscript(
   CPPExprRefI lhs,
   CPPExprRefI exprSubscript
)
{
   return new CPPExprArraySubscript(lhs, exprSubscript);
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions