X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/c38e3ce98599a410a47dc10253faa4d5830f13b2..427c49bcad63d042b29ada2ac27e3dfc4845c779:/libsecurity_codesigning/antlr2/antlr/ParserSharedInputState.hpp diff --git a/libsecurity_codesigning/antlr2/antlr/ParserSharedInputState.hpp b/libsecurity_codesigning/antlr2/antlr/ParserSharedInputState.hpp new file mode 100644 index 00000000..d1f8d151 --- /dev/null +++ b/libsecurity_codesigning/antlr2/antlr/ParserSharedInputState.hpp @@ -0,0 +1,92 @@ +#ifndef INC_ParserSharedInputState_hpp__ +#define INC_ParserSharedInputState_hpp__ + +/* ANTLR Translator Generator + * Project led by Terence Parr at http://www.jGuru.com + * Software rights: http://www.antlr.org/license.html + * + * $Id: //depot/code/org.antlr/release/antlr-2.7.7/lib/cpp/antlr/ParserSharedInputState.hpp#2 $ + */ + +#include +#include +#include +#include + +#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE +namespace antlr { +#endif + +/** This object contains the data associated with an + * input stream of tokens. Multiple parsers + * share a single ParserSharedInputState to parse + * the same stream of tokens. + */ +class ANTLR_API ParserInputState { +public: + /** Construct a new ParserInputState + * @param in the TokenBuffer to read from. The object is deleted together + * with the ParserInputState object. + */ + ParserInputState( TokenBuffer* in ) + : guessing(0) + , filename() + , input(in) + , inputResponsible(true) + { + } + /** Construct a new ParserInputState + * @param in the TokenBuffer to read from. + */ + ParserInputState( TokenBuffer& in ) + : guessing(0) + , filename("") + , input(&in) + , inputResponsible(false) + { + } + + virtual ~ParserInputState() + { + if (inputResponsible) + delete input; + } + + TokenBuffer& getInput( void ) + { + return *input; + } + + /// Reset the ParserInputState and the underlying TokenBuffer + void reset( void ) + { + input->reset(); + guessing = 0; + } + +public: + /** Are we guessing (guessing>0)? */ + int guessing; + /** What file (if known) caused the problem? + * @todo wrap this one.. + */ + ANTLR_USE_NAMESPACE(std)string filename; +private: + /** Where to get token objects */ + TokenBuffer* input; + /// Do we need to free the TokenBuffer or is it owned by another.. + bool inputResponsible; + + // we don't want these: + ParserInputState(const ParserInputState&); + ParserInputState& operator=(const ParserInputState&); +}; + +/// A reference counted ParserInputState +typedef RefCount ParserSharedInputState; + +#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE +} +#endif + +#endif //INC_ParserSharedInputState_hpp__