Dictionary.hh
Go to the documentation of this file.
00001 /*
00002  * PUBLIC DOMAIN PCCTS-BASED C++ GRAMMAR (cplusplus.g, stat.g, expr.g)
00003  *
00004  * Authors: Sumana Srinivasan, NeXT Inc.;            sumana_srinivasan@next.com
00005  *          Terence Parr, Parr Research Corporation; parrt@parr-research.com
00006  *          Russell Quong, Purdue University;        quong@ecn.purdue.edu
00007  *
00008  * SOFTWARE RIGHTS
00009  *
00010  * This file is a part of the ANTLR-based C++ grammar and is free
00011  * software.  We do not reserve any LEGAL rights to its use or
00012  * distribution, but you may NOT claim ownership or authorship of this
00013  * grammar or support code.  An individual or company may otherwise do
00014  * whatever they wish with the grammar distributed herewith including the
00015  * incorporation of the grammar or the output generated by ANTLR into
00016  * commerical software.  You may redistribute in source or binary form
00017  * without payment of royalties to us as long as this header remains
00018  * in all source distributions.
00019  *
00020  * We encourage users to develop parsers/tools using this grammar.
00021  * In return, we ask that credit is given to us for developing this
00022  * grammar.  By "credit", we mean that if you incorporate our grammar or
00023  * the generated code into one of your programs (commercial product,
00024  * research project, or otherwise) that you acknowledge this fact in the
00025  * documentation, research report, etc....  In addition, you should say nice
00026  * things about us at every opportunity.
00027  *
00028  * As long as these guidelines are kept, we expect to continue enhancing
00029  * this grammar.  Feel free to send us enhancements, fixes, bug reports,
00030  * suggestions, or general words of encouragement at parrt@parr-research.com.
00031  * 
00032  * NeXT Computer Inc.
00033  * 900 Chesapeake Dr.
00034  * Redwood City, CA 94555
00035  * 12/02/1994
00036  * 
00037  * Restructured for public consumption by Terence Parr late February, 1995.
00038  *
00039  * Requires PCCTS 1.32b4 or higher to get past ANTLR. 
00040  * 
00041  * DISCLAIMER: we make no guarantees that this grammar works, makes sense,
00042  *             or can be used to do anything useful.
00043  */
00044 /*
00045  * Dictionary.h -- A cool hash table
00046  *
00047  * Terence Parr
00048  * Parr Research Corporation
00049  * January 1995
00050  */
00051 /* 1999-2004 Version 3.0 July 2004
00052  * Modified by David Wigg at London South Bank University for CPP_parser.g
00053  *
00054  * See MyReadMe.txt for further information
00055  *
00056  * This file is best viewed in courier font with tabs set to 4 spaces
00057  */
00058 
00059 #ifndef Dictionary_hpp
00060 #define Dictionary_hpp
00061 
00062 #include <iostream>
00063 #include "DictEntry.hh"
00064 
00065 class Dictionary 
00066 {
00067     protected:
00068         DictEntry **scope, **endScope;
00069         int nscopes, currentScope;
00070         DictEntry **bucket;
00071         int nbuckets;
00072         static unsigned char randomNumbers[];
00073 //        static char *strings;
00074 //        static char *strp;
00075 //        static unsigned strsize;
00076 
00077         virtual void dumpSymbol(FILE *, DictEntry *);
00078 
00079         virtual int hash(const std::string& s);
00080 
00081     public:
00082         Dictionary(int nb=43, int ns=60, int nc=30000);
00083         virtual ~Dictionary();
00084         DictEntry *lookup(const std::string&);
00085 
00086         void define(const std::string&, DictEntry *);
00087         void defineInScope(const std::string&, DictEntry *, int);
00088 
00089         void saveScope();
00090         void restoreScope();
00091 
00092         DictEntry *getCurrentScope();
00093         int getCurrentScopeIndex();
00094         
00095         DictEntry *removeScope(int scope=-1);
00096         DictEntry *remove(const std::string&);
00097         DictEntry *remove(DictEntry *);
00098 
00099         void dumpScope(FILE *, int scope=-1);
00100         void dumpScopes();
00101 
00102         virtual void panic(char const *);
00103 };
00104 
00105 #endif
00106 


typelib
Author(s): Sylvain Joyeux/sylvain.joyeux@m4x.org
autogenerated on Mon Oct 6 2014 03:17:12