Click here to Skip to main content
15,887,135 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 82.9K   1.3K   19  
An article on the usage and design of another Enum Viewer
// CPPParserSym.h: Subclass of CPPParser that has symbol table support
// This class implements two things:
//   1) Overrides of parser base class pure-virtual methods 
//      for accessing the symbol table.
//   2) Operational functionality that is independent of the grammar.
//

#ifndef INCL_CPPPARSER_SYM_H
#define INCL_CPPPARSER_SYM_H

#include "CPPParser.h"
#include "CPPSymTableIncomplete.h"

class CPPParserSym : public CPPParser
{
public:
   DECLARE_INCOMPLETE(OptionSet);

   // ctor
	CPPParserSym(ANTLRTokenBuffer *input);
   // ctor for template specialization
	CPPParserSym(
      ANTLRTokenBuffer *input,
      CPPSymTableRefI symTable_,
      OptionSetRefI optionSet_
   );
   // init
   virtual void init();
   // dtor
   virtual ~CPPParserSym();

   // Debugging
   void DumpScopes() const;

   // Get/set parser options
   virtual void SetOption(Option option, bool value);
   virtual bool GetOption(Option option) const;
   OptionSetRefI GetOptions() const { return options; }

protected:
   
   //
   // Overrides of the parser base class
   // Most symbol-table management methods are
   // simply forwarded to the symbol table object.
   // Get definitions of pasrer virtual methods from a header file.
   // 
   #define PARSER_PURE_VIRTUAL
   #include "CPPParserVirtual.h"
   #undef PARSER_PURE_VIRTUAL

   // consume the next token
   virtual void consume();

   // Process a #pragma pack()...
   void CPPParserSym::HandleMSPacking();

// private:
   //
   // Helper methods 
   //

   // set for holding option values
   OptionSetRefI options;
   // Internal method for creating an option set
   static OptionSetRefI NewOptionSet();

   // Pointer to symbol table
   CPPSymTableRefI symTable;

   // Stack of token lists that are collecting tokens as
   // they are consumed.  Every list on the stack will 
   // have an additional token added to the end whenever
   // a token is consumed by the parser.
   TokenListListRefI tokenCollectionLists;

   // Stack of integers that are used to store the input token
   // marks as they are made during guess mode, for the purpose of 
   // removing tokens from the token collection lists when a 
   // rewind is made.
   DECLARE_INCOMPLETE(MarkerStack);
   MarkerStackRefI markerStack;
   static MarkerStackRefI NewMarkerStack();
};

#endif

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