Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

TokenStreamSelector.hpp

Go to the documentation of this file.
00001 #ifndef INC_TokenStreamSelector_hpp__
00002 #define INC_TokenStreamSelector_hpp__
00003 
00004 /* ANTLR Translator Generator
00005  * Project led by Terence Parr at http://www.jGuru.com
00006  * Software rights: http://www.antlr.org/license.html
00007  *
00008  * $Id: TokenStreamSelector.hpp,v 1.1 2004/10/08 16:27:34 dfisher Exp $
00009  */
00010 
00011 #include <antlr/config.hpp>
00012 #include <antlr/TokenStream.hpp>
00013 #include <map>
00014 #include <stack>
00015 
00016 #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
00017 namespace antlr {
00018 #endif
00019 
00027 class ANTLR_API TokenStreamSelector : public TokenStream {
00028 protected:
00030 #ifdef OS_NO_ALLOCATOR
00031         typedef ANTLR_USE_NAMESPACE(std)less<ANTLR_USE_NAMESPACE(std)string> lessp;
00032         typedef ANTLR_USE_NAMESPACE(std)map<ANTLR_USE_NAMESPACE(std)string,TokenStream*,lessp> inputStreamNames_coll;
00033 #else
00034         typedef ANTLR_USE_NAMESPACE(std)map<ANTLR_USE_NAMESPACE(std)string,TokenStream*> inputStreamNames_coll;
00035 #endif
00036         inputStreamNames_coll inputStreamNames;
00037 
00039         TokenStream* input;
00040 
00042 #ifdef OS_NO_ALLOCATOR
00043         typedef ANTLR_USE_NAMESPACE(std)stack<TokenStream*, ANTLR_USE_NAMESPACE(std)deque<TokenStream*> > streamStack_coll;
00044 #else
00045         typedef ANTLR_USE_NAMESPACE(std)stack<TokenStream*> streamStack_coll;
00046 #endif
00047         streamStack_coll streamStack;
00048 
00049 public:
00050         TokenStreamSelector();
00051         ~TokenStreamSelector();
00052 
00053         void addInputStream(TokenStream* stream, const ANTLR_USE_NAMESPACE(std)string& key);
00054 
00056         TokenStream* getCurrentStream() const;
00057 
00058         TokenStream* getStream(const ANTLR_USE_NAMESPACE(std)string& sname) const;
00059 
00060         RefToken nextToken();
00061 
00062         TokenStream* pop();
00063 
00064         void push(TokenStream* stream);
00065 
00066         void push(const ANTLR_USE_NAMESPACE(std)string& sname);
00067 
00075         void retry();
00076 
00078         void select(TokenStream* stream);
00079 
00080         void select(const ANTLR_USE_NAMESPACE(std)string& sname);
00081 };
00082 
00083 #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
00084 }
00085 #endif
00086 
00087 #endif //INC_TokenStreamSelector_hpp__

Generated on Wed Nov 3 12:59:06 2004 for Lemur Toolkit by doxygen1.2.18