KDevelop API Documentation

TreeParser.hpp

Go to the documentation of this file.
00001 #ifndef INC_TreeParser_hpp__
00002 #define INC_TreeParser_hpp__
00003 
00004 /* ANTLR Translator Generator
00005  * Project led by Terence Parr at http://www.jGuru.com
00006  * Software rights: http://www.antlr.org/RIGHTS.html
00007  *
00008  * $Id: TreeParser.hpp,v 1.2 2003/05/02 00:36:19 okellogg Exp $
00009  */
00010 
00011 #include <antlr/config.hpp>
00012 #include <antlr/AST.hpp>
00013 #include <antlr/ASTFactory.hpp>
00014 #include <antlr/BitSet.hpp>
00015 #include <antlr/RecognitionException.hpp>
00016 #include <antlr/TreeParserSharedInputState.hpp>
00017 
00018 #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
00019 namespace antlr {
00020 #endif
00021 
00022 class ANTLR_API TreeParser {
00023 public:
00024     TreeParser();
00025     TreeParser(const TreeParserSharedInputState& state);
00026     virtual ~TreeParser();
00027 
00029     RefAST getAST() const
00030     {
00031         return returnAST;
00032     }
00033 
00038     virtual void match(RefAST t, const BitSet& b);
00039 
00046     virtual void setASTFactory(ASTFactory* factory)
00047     {
00048         astFactory = factory;
00049     }
00051     virtual ASTFactory* getASTFactory() const
00052     {
00053         return astFactory;
00054     }
00056     virtual const char* getTokenName(int num) const = 0;
00057     virtual int getNumTokens() const = 0;
00058 
00060     virtual void reportError(const RecognitionException& ex);
00062     virtual void reportError(const ANTLR_USE_NAMESPACE(std)string& s);
00064     virtual void reportWarning(const ANTLR_USE_NAMESPACE(std)string& s);
00066     static void panic();
00067 
00069     virtual void traceIndent();
00070     virtual void traceIn(const char* rname, RefAST t);
00071     virtual void traceOut(const char* rname, RefAST t);
00072 
00078     static RefAST ASTNULL;
00079 
00080 protected:
00081     virtual void match(RefAST t, int ttype);
00082     virtual void matchNot(RefAST t, int ttype);
00083 
00085     RefAST _retTree;
00087     RefAST returnAST;
00089     ASTFactory* astFactory;
00090 
00092     TreeParserSharedInputState inputState;
00093 
00095     int traceDepth;
00096 
00100     class Tracer {
00101     private:
00102         TreeParser* parser;
00103         const char* text;
00104         RefAST tree;
00105     public:
00106         Tracer(TreeParser* p, const char* t, RefAST a)
00107         : parser(p), text(t), tree(a)
00108         {
00109             parser->traceIn(text,tree);
00110         }
00111         ~Tracer()
00112         {
00113             parser->traceOut(text,tree);
00114         }
00115     private:
00116         Tracer(const Tracer&);                          // undefined
00117         const Tracer& operator=(const Tracer&); // undefined
00118     };
00119 
00120 private:
00121     // no copying of treeparser instantiations...
00122     TreeParser(const TreeParser& other);
00123     TreeParser& operator=(const TreeParser& other);
00124 };
00125 
00126 #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
00127 }
00128 #endif
00129 
00130 #endif //INC_TreeParser_hpp__
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Feb 22 09:22:34 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003