123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272 |
- #ifndef _ANTLR3_RECOGNIZER_SHARED_STATE_HPP
- #define _ANTLR3_RECOGNIZER_SHARED_STATE_HPP
- namespace antlr3 {
- template<class ImplTraits, class StreamType>
- class RecognizerSharedState : public ImplTraits::AllocPolicyType
- {
- public:
- typedef typename ImplTraits::AllocPolicyType AllocPolicyType;
- typedef typename StreamType::UnitType TokenType;
- typedef typename ImplTraits::CommonTokenType CommonTokenType;
-
- typedef typename ComponentTypeFinder<ImplTraits, StreamType>::ComponentType ComponentType;
- typedef typename ImplTraits::template RewriteStreamType< ComponentType > RewriteStreamType;
- typedef typename ImplTraits::StringType StringType;
- typedef typename ImplTraits::TokenSourceType TokenSourceType;
- typedef typename ImplTraits::template ExceptionBaseType<StreamType> ExceptionBaseType;
- typedef typename ImplTraits::BitsetType BitsetType;
- typedef typename ImplTraits::BitsetListType BitsetListType;
- typedef typename ImplTraits::TreeAdaptorType TreeAdaptorType;
- typedef typename AllocPolicyType::template StackType< BitsetListType > FollowingType;
- typedef typename AllocPolicyType::template StackType< typename ImplTraits::InputStreamType* > InputStreamsType;
- typedef InputStreamsType StreamsType;
- typedef typename AllocPolicyType::template VectorType<RewriteStreamType> RewriteStreamsType;
- typedef IntTrie<ImplTraits, ANTLR_MARKER> RuleListType;
- typedef IntTrie<ImplTraits, std::shared_ptr<RuleListType>> RuleMemoType;
- private:
-
- ExceptionBaseType* m_exception;
-
- FollowingType m_following;
-
- ANTLR_UINT32 m_sizeHint;
-
- bool m_error;
-
- bool m_errorRecovery;
-
- bool m_failed;
-
- bool m_token_present;
-
- ANTLR_MARKER m_lastErrorIndex;
-
- ANTLR_UINT32 m_errorCount;
-
- ANTLR_INT32 m_backtracking;
-
- RuleMemoType* m_ruleMemo;
-
- ANTLR_UINT8** m_tokenNames;
-
- CommonTokenType m_token;
-
- TokenSourceType* m_tokSource;
-
- ANTLR_UINT32 m_channel;
-
- ANTLR_UINT32 m_type;
-
- ANTLR_INT32 m_tokenStartLine;
-
- ANTLR_INT32 m_tokenStartCharPositionInLine;
-
- ANTLR_MARKER m_tokenStartCharIndex;
-
- StringType m_text;
-
- InputStreamsType m_streams;
-
- TreeAdaptorType* m_treeAdaptor;
- public:
- RecognizerSharedState();
- ExceptionBaseType* get_exception() const;
- FollowingType& get_following();
- ANTLR_UINT32 get_sizeHint() const;
- bool get_error() const;
- bool get_errorRecovery() const;
- bool get_failed() const;
- bool get_token_present() const;
- ANTLR_MARKER get_lastErrorIndex() const;
- ANTLR_UINT32 get_errorCount() const;
- ANTLR_INT32 get_backtracking() const;
- RuleMemoType* get_ruleMemo() const;
- ANTLR_UINT8** get_tokenNames() const;
- ANTLR_UINT8* get_tokenName( ANTLR_UINT32 i ) const;
- CommonTokenType* get_token();
- TokenSourceType* get_tokSource() const;
- ANTLR_UINT32& get_channel();
- ANTLR_UINT32 get_type() const;
- ANTLR_INT32 get_tokenStartLine() const;
- ANTLR_INT32 get_tokenStartCharPositionInLine() const;
- ANTLR_MARKER get_tokenStartCharIndex() const;
- StringType& get_text();
- InputStreamsType& get_streams();
- TreeAdaptorType* get_treeAdaptor() const;
-
- void set_following( const FollowingType& following );
- void set_sizeHint( ANTLR_UINT32 sizeHint );
- void set_error( bool error );
- void set_errorRecovery( bool errorRecovery );
- void set_failed( bool failed );
- void set_token_present(bool token_present);
- void set_lastErrorIndex( ANTLR_MARKER lastErrorIndex );
- void set_errorCount( ANTLR_UINT32 errorCount );
- void set_backtracking( ANTLR_INT32 backtracking );
- void set_ruleMemo( RuleMemoType* ruleMemo );
- void set_tokenNames( ANTLR_UINT8** tokenNames );
- void set_tokSource( TokenSourceType* tokSource );
- void set_channel( ANTLR_UINT32 channel );
- void set_exception( ExceptionBaseType* exception );
- void set_type( ANTLR_UINT32 type );
- void set_token( const CommonTokenType* tok);
- void set_tokenStartLine( ANTLR_INT32 tokenStartLine );
- void set_tokenStartCharPositionInLine( ANTLR_INT32 tokenStartCharPositionInLine );
- void set_tokenStartCharIndex( ANTLR_MARKER tokenStartCharIndex );
- void set_text( const StringType& text );
- void set_streams( const InputStreamsType& streams );
- void set_treeAdaptor( TreeAdaptorType* adaptor );
-
- void inc_errorCount();
- void inc_backtracking();
- void dec_backtracking();
- };
- }
- #include "antlr3recognizersharedstate.inl"
- #endif
|