1*16467b97STreehugger Robot /** \file 2*16467b97STreehugger Robot * Defines the the class interface for an antlr3 INTSTREAM. 3*16467b97STreehugger Robot * 4*16467b97STreehugger Robot * Certain functionality (such as DFAs for instance) abstract the stream of tokens 5*16467b97STreehugger Robot * or characters in to a steam of integers. Hence this structure should be included 6*16467b97STreehugger Robot * in any stream that is able to provide the output as a stream of integers (which is anything 7*16467b97STreehugger Robot * basically. 8*16467b97STreehugger Robot * 9*16467b97STreehugger Robot * There are no specific implementations of the methods in this interface in general. Though 10*16467b97STreehugger Robot * for purposes of casting and so on, it may be necesssary to implement a function with 11*16467b97STreehugger Robot * the signature in this interface which abstracts the base immplementation. In essence though 12*16467b97STreehugger Robot * the base stream provides a pointer to this interface, within which it installs its 13*16467b97STreehugger Robot * normal match() functions and so on. Interaces such as DFA are then passed the pANTLR3_INT_STREAM 14*16467b97STreehugger Robot * and can treat any input as an int stream. 15*16467b97STreehugger Robot * 16*16467b97STreehugger Robot * For instance, a lexer implements a pANTLR3_BASE_RECOGNIZER, within which there is a pANTLR3_INT_STREAM. 17*16467b97STreehugger Robot * However, a pANTLR3_INPUT_STREAM also provides a pANTLR3_INT_STREAM, which it has constructed from 18*16467b97STreehugger Robot * it's normal interface when it was created. This is then pointed at by the pANTLR_BASE_RECOGNIZER 19*16467b97STreehugger Robot * when it is intialized with a pANTLR3_INPUT_STREAM. 20*16467b97STreehugger Robot * 21*16467b97STreehugger Robot * Similarly if a pANTLR3_BASE_RECOGNIZER is initialized with a pANTLR3_TOKEN_STREAM, then the 22*16467b97STreehugger Robot * pANTLR3_INT_STREAM is taken from the pANTLR3_TOKEN_STREAM. 23*16467b97STreehugger Robot * 24*16467b97STreehugger Robot * If a pANTLR3_BASE_RECOGNIZER is initialized with a pANTLR3_TREENODE_STREAM, then guess where 25*16467b97STreehugger Robot * the pANTLR3_INT_STREAM comes from? 26*16467b97STreehugger Robot * 27*16467b97STreehugger Robot * Note that because the context pointer points to the actual interface structure that is providing 28*16467b97STreehugger Robot * the ANTLR3_INT_STREAM it is defined as a (void *) in this interface. There is no direct implementation 29*16467b97STreehugger Robot * of an ANTLR3_INT_STREAM (unless someone did not understand what I was doing here =;?P 30*16467b97STreehugger Robot */ 31*16467b97STreehugger Robot #ifndef _ANTLR3_INTSTREAM_HPP 32*16467b97STreehugger Robot #define _ANTLR3_INTSTREAM_HPP 33*16467b97STreehugger Robot 34*16467b97STreehugger Robot // [The "BSD licence"] 35*16467b97STreehugger Robot // Copyright (c) 2005-2009 Gokulakannan Somasundaram, ElectronDB 36*16467b97STreehugger Robot 37*16467b97STreehugger Robot // 38*16467b97STreehugger Robot // All rights reserved. 39*16467b97STreehugger Robot // 40*16467b97STreehugger Robot // Redistribution and use in source and binary forms, with or without 41*16467b97STreehugger Robot // modification, are permitted provided that the following conditions 42*16467b97STreehugger Robot // are met: 43*16467b97STreehugger Robot // 1. Redistributions of source code must retain the above copyright 44*16467b97STreehugger Robot // notice, this list of conditions and the following disclaimer. 45*16467b97STreehugger Robot // 2. Redistributions in binary form must reproduce the above copyright 46*16467b97STreehugger Robot // notice, this list of conditions and the following disclaimer in the 47*16467b97STreehugger Robot // documentation and/or other materials provided with the distribution. 48*16467b97STreehugger Robot // 3. The name of the author may not be used to endorse or promote products 49*16467b97STreehugger Robot // derived from this software without specific prior written permission. 50*16467b97STreehugger Robot // 51*16467b97STreehugger Robot // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 52*16467b97STreehugger Robot // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 53*16467b97STreehugger Robot // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 54*16467b97STreehugger Robot // IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 55*16467b97STreehugger Robot // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 56*16467b97STreehugger Robot // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 57*16467b97STreehugger Robot // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 58*16467b97STreehugger Robot // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 59*16467b97STreehugger Robot // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 60*16467b97STreehugger Robot // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 61*16467b97STreehugger Robot 62*16467b97STreehugger Robot #include <cassert> 63*16467b97STreehugger Robot 64*16467b97STreehugger Robot #include "antlr3defs.hpp" 65*16467b97STreehugger Robot 66*16467b97STreehugger Robot ANTLR_BEGIN_NAMESPACE() 67*16467b97STreehugger Robot 68*16467b97STreehugger Robot enum STREAM_TYPE 69*16467b97STreehugger Robot { 70*16467b97STreehugger Robot /** Type indicator for a character stream 71*16467b97STreehugger Robot * \remark if a custom stream is created but it can be treated as 72*16467b97STreehugger Robot * a char stream, then you may OR in this value to your type indicator 73*16467b97STreehugger Robot */ 74*16467b97STreehugger Robot CHARSTREAM = 0x0001 75*16467b97STreehugger Robot 76*16467b97STreehugger Robot /** Type indicator for a Token stream 77*16467b97STreehugger Robot * \remark if a custom stream is created but it can be treated as 78*16467b97STreehugger Robot * a token stream, then you may OR in this value to your type indicator 79*16467b97STreehugger Robot */ 80*16467b97STreehugger Robot , TOKENSTREAM = 0x0002 81*16467b97STreehugger Robot 82*16467b97STreehugger Robot /** Type indicator for a common tree node stream 83*16467b97STreehugger Robot * \remark if a custom stream is created but it can be treated as 84*16467b97STreehugger Robot * a common tree node stream, then you may OR in this value to your type indicator 85*16467b97STreehugger Robot */ 86*16467b97STreehugger Robot , COMMONTREENODE = 0x0004 87*16467b97STreehugger Robot 88*16467b97STreehugger Robot /** Type mask for input stream so we can switch in the above types 89*16467b97STreehugger Robot * \remark DO NOT USE 0x0000 as a stream type! 90*16467b97STreehugger Robot */ 91*16467b97STreehugger Robot , INPUT_MASK = 0x0007 92*16467b97STreehugger Robot }; 93*16467b97STreehugger Robot 94*16467b97STreehugger Robot class RESOLVE_ENDIAN_AT_RUNTIME {}; 95*16467b97STreehugger Robot class BYTE_AGNOSTIC {}; 96*16467b97STreehugger Robot class ANTLR_LITTLE_ENDIAN {}; 97*16467b97STreehugger Robot class ANTLR_BIG_ENDIAN {}; 98*16467b97STreehugger Robot 99*16467b97STreehugger Robot template<class ImplTraits, class SuperType> 100*16467b97STreehugger Robot class IntStream : public ImplTraits::AllocPolicyType 101*16467b97STreehugger Robot { 102*16467b97STreehugger Robot public: 103*16467b97STreehugger Robot typedef typename ImplTraits::StringType StringType; 104*16467b97STreehugger Robot 105*16467b97STreehugger Robot protected: 106*16467b97STreehugger Robot /** Potentially useful in error reporting and so on, this string is 107*16467b97STreehugger Robot * an identification of the input source. It may be NULL, so anything 108*16467b97STreehugger Robot * attempting to access it needs to check this and substitute a sensible 109*16467b97STreehugger Robot * default. 110*16467b97STreehugger Robot */ 111*16467b97STreehugger Robot StringType m_streamName; 112*16467b97STreehugger Robot 113*16467b97STreehugger Robot /** Last marker position allocated 114*16467b97STreehugger Robot */ 115*16467b97STreehugger Robot ANTLR_MARKER m_lastMarker; 116*16467b97STreehugger Robot 117*16467b97STreehugger Robot bool m_upper_case; //if set, values should be returbed in upper case 118*16467b97STreehugger Robot 119*16467b97STreehugger Robot /// Indicates whether we should implement endian-specific logic 120*16467b97STreehugger Robot /// 0 - Undefined 1 - Default(machine and input are both same), 2 - Little Endian, 3 - Big Endian 121*16467b97STreehugger Robot ANTLR_UINT8 m_endian_spec; 122*16467b97STreehugger Robot 123*16467b97STreehugger Robot public: 124*16467b97STreehugger Robot IntStream(); 125*16467b97STreehugger Robot 126*16467b97STreehugger Robot // Return a string that identifies the input source 127*16467b97STreehugger Robot // 128*16467b97STreehugger Robot StringType getSourceName(); 129*16467b97STreehugger Robot StringType& get_streamName(); 130*16467b97STreehugger Robot const StringType& get_streamName() const; 131*16467b97STreehugger Robot ANTLR_MARKER get_lastMarker() const; 132*16467b97STreehugger Robot 133*16467b97STreehugger Robot SuperType* get_super(); 134*16467b97STreehugger Robot /** 135*16467b97STreehugger Robot * Function that installs a version of LA that always 136*16467b97STreehugger Robot * returns upper case. Only valid for character streams and creates a case 137*16467b97STreehugger Robot * insensitive lexer if the lexer tokens are described in upper case. The 138*16467b97STreehugger Robot * tokens will preserve case in the token text. 139*16467b97STreehugger Robot */ 140*16467b97STreehugger Robot void setUcaseLA(bool flag); 141*16467b97STreehugger Robot 142*16467b97STreehugger Robot /** Consume the next 'ANTR3_UINT32' in the stream 143*16467b97STreehugger Robot */ 144*16467b97STreehugger Robot void consume(); 145*16467b97STreehugger Robot 146*16467b97STreehugger Robot /** Get ANTLR3_UINT32 at current input pointer + i ahead where i=1 is next ANTLR3_UINT32 147*16467b97STreehugger Robot */ 148*16467b97STreehugger Robot ANTLR_UINT32 _LA( ANTLR_INT32 i); 149*16467b97STreehugger Robot 150*16467b97STreehugger Robot /** Tell the stream to start buffering if it hasn't already. Return 151*16467b97STreehugger Robot * current input position, index(), or some other marker so that 152*16467b97STreehugger Robot * when passed to rewind() you get back to the same spot. 153*16467b97STreehugger Robot * rewind(mark()) should not affect the input cursor. 154*16467b97STreehugger Robot */ 155*16467b97STreehugger Robot ANTLR_MARKER mark(); 156*16467b97STreehugger Robot 157*16467b97STreehugger Robot /** Return the current input symbol index 0..n where n indicates the 158*16467b97STreehugger Robot * last symbol has been read. 159*16467b97STreehugger Robot */ 160*16467b97STreehugger Robot ANTLR_MARKER index(); 161*16467b97STreehugger Robot 162*16467b97STreehugger Robot /** Reset the stream so that next call to index would return marker. 163*16467b97STreehugger Robot * The marker will usually be index() but it doesn't have to be. It's 164*16467b97STreehugger Robot * just a marker to indicate what state the stream was in. This is 165*16467b97STreehugger Robot * essentially calling release() and seek(). If there are markers 166*16467b97STreehugger Robot * created after this marker argument, this routine must unroll them 167*16467b97STreehugger Robot * like a stack. Assume the state the stream was in when this marker 168*16467b97STreehugger Robot * was created. 169*16467b97STreehugger Robot */ 170*16467b97STreehugger Robot void rewind(ANTLR_MARKER marker); 171*16467b97STreehugger Robot 172*16467b97STreehugger Robot /** Reset the stream to the last marker position, witouh destryoing the 173*16467b97STreehugger Robot * last marker position. 174*16467b97STreehugger Robot */ 175*16467b97STreehugger Robot void rewindLast(); 176*16467b97STreehugger Robot 177*16467b97STreehugger Robot /** You may want to commit to a backtrack but don't want to force the 178*16467b97STreehugger Robot * stream to keep bookkeeping objects around for a marker that is 179*16467b97STreehugger Robot * no longer necessary. This will have the same behavior as 180*16467b97STreehugger Robot * rewind() except it releases resources without the backward seek. 181*16467b97STreehugger Robot */ 182*16467b97STreehugger Robot void release(ANTLR_MARKER mark); 183*16467b97STreehugger Robot 184*16467b97STreehugger Robot /** Set the input cursor to the position indicated by index. This is 185*16467b97STreehugger Robot * normally used to seek ahead in the input stream. No buffering is 186*16467b97STreehugger Robot * required to do this unless you know your stream will use seek to 187*16467b97STreehugger Robot * move backwards such as when backtracking. 188*16467b97STreehugger Robot * 189*16467b97STreehugger Robot * This is different from rewind in its multi-directional 190*16467b97STreehugger Robot * requirement and in that its argument is strictly an input cursor (index). 191*16467b97STreehugger Robot * 192*16467b97STreehugger Robot * For char streams, seeking forward must update the stream state such 193*16467b97STreehugger Robot * as line number. For seeking backwards, you will be presumably 194*16467b97STreehugger Robot * backtracking using the mark/rewind mechanism that restores state and 195*16467b97STreehugger Robot * so this method does not need to update state when seeking backwards. 196*16467b97STreehugger Robot * 197*16467b97STreehugger Robot * Currently, this method is only used for efficient backtracking, but 198*16467b97STreehugger Robot * in the future it may be used for incremental parsing. 199*16467b97STreehugger Robot */ 200*16467b97STreehugger Robot void seek(ANTLR_MARKER index); 201*16467b97STreehugger Robot 202*16467b97STreehugger Robot /// Debug only method to flag consumption of initial off-channel 203*16467b97STreehugger Robot /// tokens in the input stream 204*16467b97STreehugger Robot /// 205*16467b97STreehugger Robot void consumeInitialHiddenTokens(); 206*16467b97STreehugger Robot 207*16467b97STreehugger Robot void rewindMark(ANTLR_MARKER marker); 208*16467b97STreehugger Robot ANTLR_MARKER tindex(); 209*16467b97STreehugger Robot 210*16467b97STreehugger Robot /** Frees any resources that were allocated for the implementation of this 211*16467b97STreehugger Robot * interface. Usually this is just releasing the memory allocated 212*16467b97STreehugger Robot * for the structure itself, but it may of course do anything it need to 213*16467b97STreehugger Robot * so long as it does not stamp on anything else. 214*16467b97STreehugger Robot */ 215*16467b97STreehugger Robot ~IntStream(); 216*16467b97STreehugger Robot 217*16467b97STreehugger Robot protected: 218*16467b97STreehugger Robot void setupIntStream(bool machineBigEndian, bool inputBigEndian); 219*16467b97STreehugger Robot void findout_endian_spec(bool machineBigEndian, bool inputBigEndian); 220*16467b97STreehugger Robot 221*16467b97STreehugger Robot //If the user chooses this option, then we will be resolving stuffs at run-time 222*16467b97STreehugger Robot ANTLR_UINT32 _LA( ANTLR_INT32 i, ClassForwarder<RESOLVE_ENDIAN_AT_RUNTIME> ); 223*16467b97STreehugger Robot 224*16467b97STreehugger Robot //resolve into one of the three categories below at runtime 225*16467b97STreehugger Robot void consume( ClassForwarder<RESOLVE_ENDIAN_AT_RUNTIME> ); 226*16467b97STreehugger Robot }; 227*16467b97STreehugger Robot 228*16467b97STreehugger Robot template<class ImplTraits, class SuperType> 229*16467b97STreehugger Robot class EBCDIC_IntStream : public IntStream<ImplTraits, SuperType> 230*16467b97STreehugger Robot { 231*16467b97STreehugger Robot public: 232*16467b97STreehugger Robot ANTLR_UINT32 _LA( ANTLR_INT32 i); 233*16467b97STreehugger Robot 234*16467b97STreehugger Robot protected: 235*16467b97STreehugger Robot void setupIntStream(); 236*16467b97STreehugger Robot }; 237*16467b97STreehugger Robot 238*16467b97STreehugger Robot template<class ImplTraits, class SuperType> 239*16467b97STreehugger Robot class UTF8_IntStream : public IntStream<ImplTraits, SuperType> 240*16467b97STreehugger Robot { 241*16467b97STreehugger Robot public: 242*16467b97STreehugger Robot ANTLR_UINT32 _LA( ANTLR_INT32 i); 243*16467b97STreehugger Robot void consume(); 244*16467b97STreehugger Robot 245*16467b97STreehugger Robot protected: 246*16467b97STreehugger Robot void setupIntStream(bool machineBigEndian, bool inputBigEndian); 247*16467b97STreehugger Robot 248*16467b97STreehugger Robot private: 249*16467b97STreehugger Robot static const ANTLR_UINT32* TrailingBytesForUTF8(); 250*16467b97STreehugger Robot static const UTF32* OffsetsFromUTF8(); 251*16467b97STreehugger Robot }; 252*16467b97STreehugger Robot 253*16467b97STreehugger Robot template<class ImplTraits, class SuperType> 254*16467b97STreehugger Robot class UTF16_IntStream : public IntStream<ImplTraits, SuperType> 255*16467b97STreehugger Robot { 256*16467b97STreehugger Robot public: 257*16467b97STreehugger Robot ANTLR_UINT32 _LA( ANTLR_INT32 i); 258*16467b97STreehugger Robot void consume(); 259*16467b97STreehugger Robot ANTLR_MARKER index(); 260*16467b97STreehugger Robot void seek(ANTLR_MARKER seekPoint); 261*16467b97STreehugger Robot 262*16467b97STreehugger Robot protected: 263*16467b97STreehugger Robot void setupIntStream(bool machineBigEndian, bool inputBigEndian); 264*16467b97STreehugger Robot 265*16467b97STreehugger Robot /// \brief Return the input element assuming an 8 bit ascii input 266*16467b97STreehugger Robot /// 267*16467b97STreehugger Robot /// \param[in] input Input stream context pointer 268*16467b97STreehugger Robot /// \param[in] la 1 based offset of next input stream element 269*16467b97STreehugger Robot /// 270*16467b97STreehugger Robot /// \return Next input character in internal ANTLR3 encoding (UTF32) 271*16467b97STreehugger Robot /// 272*16467b97STreehugger Robot ANTLR_UINT32 _LA( ANTLR_INT32 i, ClassForwarder<BYTE_AGNOSTIC> ); 273*16467b97STreehugger Robot 274*16467b97STreehugger Robot /// \brief Return the input element assuming a UTF16 input when the input is Little Endian and the machine is not 275*16467b97STreehugger Robot /// 276*16467b97STreehugger Robot /// \param[in] input Input stream context pointer 277*16467b97STreehugger Robot /// \param[in] la 1 based offset of next input stream element 278*16467b97STreehugger Robot /// 279*16467b97STreehugger Robot /// \return Next input character in internal ANTLR3 encoding (UTF32) 280*16467b97STreehugger Robot /// 281*16467b97STreehugger Robot ANTLR_UINT32 _LA( ANTLR_INT32 i, ClassForwarder<ANTLR_LITTLE_ENDIAN> ); 282*16467b97STreehugger Robot 283*16467b97STreehugger Robot /// \brief Return the input element assuming a UTF16 input when the input is Little Endian and the machine is not 284*16467b97STreehugger Robot /// 285*16467b97STreehugger Robot /// \param[in] input Input stream context pointer 286*16467b97STreehugger Robot /// \param[in] la 1 based offset of next input stream element 287*16467b97STreehugger Robot /// 288*16467b97STreehugger Robot /// \return Next input character in internal ANTLR3 encoding (UTF32) 289*16467b97STreehugger Robot /// 290*16467b97STreehugger Robot ANTLR_UINT32 _LA( ANTLR_INT32 i, ClassForwarder<ANTLR_BIG_ENDIAN> ); 291*16467b97STreehugger Robot 292*16467b97STreehugger Robot /// \brief Consume the next character in a UTF16 input stream 293*16467b97STreehugger Robot /// 294*16467b97STreehugger Robot /// \param input Input stream context pointer 295*16467b97STreehugger Robot /// 296*16467b97STreehugger Robot void consume( ClassForwarder<BYTE_AGNOSTIC> ); 297*16467b97STreehugger Robot 298*16467b97STreehugger Robot /// \brief Consume the next character in a UTF16 input stream when the input is Little Endian and the machine is not 299*16467b97STreehugger Robot /// Note that the UTF16 routines do not do any substantial verification of the input stream as for performance 300*16467b97STreehugger Robot /// sake, we assume it is validly encoded. So if a low surrogate is found at the curent input position then we 301*16467b97STreehugger Robot /// just consume it. Surrogate pairs should be seen as Hi, Lo. So if we have a Lo first, then the input stream 302*16467b97STreehugger Robot /// is fubar but we just ignore that. 303*16467b97STreehugger Robot /// 304*16467b97STreehugger Robot /// \param input Input stream context pointer 305*16467b97STreehugger Robot /// 306*16467b97STreehugger Robot void consume( ClassForwarder<ANTLR_LITTLE_ENDIAN> ); 307*16467b97STreehugger Robot 308*16467b97STreehugger Robot /// \brief Consume the next character in a UTF16 input stream when the input is Big Endian and the machine is not 309*16467b97STreehugger Robot /// 310*16467b97STreehugger Robot /// \param input Input stream context pointer 311*16467b97STreehugger Robot /// 312*16467b97STreehugger Robot void consume( ClassForwarder<ANTLR_BIG_ENDIAN> ); 313*16467b97STreehugger Robot }; 314*16467b97STreehugger Robot 315*16467b97STreehugger Robot 316*16467b97STreehugger Robot 317*16467b97STreehugger Robot template<class ImplTraits, class SuperType> 318*16467b97STreehugger Robot class UTF32_IntStream : public IntStream<ImplTraits, SuperType> 319*16467b97STreehugger Robot { 320*16467b97STreehugger Robot public: 321*16467b97STreehugger Robot ANTLR_UINT32 _LA( ANTLR_INT32 i); 322*16467b97STreehugger Robot void consume(); 323*16467b97STreehugger Robot 324*16467b97STreehugger Robot /// \brief Calculate the current index in the output stream. 325*16467b97STreehugger Robot /// \param[in] input Input stream context pointer 326*16467b97STreehugger Robot /// 327*16467b97STreehugger Robot ANTLR_MARKER index(); 328*16467b97STreehugger Robot void seek(ANTLR_MARKER seekPoint); 329*16467b97STreehugger Robot 330*16467b97STreehugger Robot protected: 331*16467b97STreehugger Robot void setupIntStream(bool machineBigEndian, bool inputBigEndian); 332*16467b97STreehugger Robot ANTLR_UINT32 _LA( ANTLR_INT32 i, ClassForwarder<RESOLVE_ENDIAN_AT_RUNTIME> ); 333*16467b97STreehugger Robot ANTLR_UINT32 _LA( ANTLR_INT32 i, ClassForwarder<BYTE_AGNOSTIC> ); 334*16467b97STreehugger Robot ANTLR_UINT32 _LA( ANTLR_INT32 i, ClassForwarder<ANTLR_LITTLE_ENDIAN> ); 335*16467b97STreehugger Robot ANTLR_UINT32 _LA( ANTLR_INT32 i, ClassForwarder<ANTLR_BIG_ENDIAN> ); 336*16467b97STreehugger Robot 337*16467b97STreehugger Robot void consume( ClassForwarder<RESOLVE_ENDIAN_AT_RUNTIME> ); 338*16467b97STreehugger Robot void consume( ClassForwarder<BYTE_AGNOSTIC> ); 339*16467b97STreehugger Robot void consume( ClassForwarder<ANTLR_LITTLE_ENDIAN> ); 340*16467b97STreehugger Robot void consume( ClassForwarder<ANTLR_BIG_ENDIAN> ); 341*16467b97STreehugger Robot }; 342*16467b97STreehugger Robot 343*16467b97STreehugger Robot template<class ImplTraits> 344*16467b97STreehugger Robot class TokenIntStream : public IntStream<ImplTraits, typename ImplTraits::TokenStreamType > 345*16467b97STreehugger Robot { 346*16467b97STreehugger Robot public: 347*16467b97STreehugger Robot typedef typename ImplTraits::CommonTokenType CommonTokenType; 348*16467b97STreehugger Robot typedef typename ImplTraits::StringType StringType; 349*16467b97STreehugger Robot typedef typename ImplTraits::TokenStreamType TokenStreamType; 350*16467b97STreehugger Robot typedef IntStream<ImplTraits, TokenStreamType > BaseType; 351*16467b97STreehugger Robot 352*16467b97STreehugger Robot private: 353*16467b97STreehugger Robot /** Because the indirect call, though small in individual cases can 354*16467b97STreehugger Robot * mount up if there are thousands of tokens (very large input streams), callers 355*16467b97STreehugger Robot * of size can optionally use this cached size field. 356*16467b97STreehugger Robot */ 357*16467b97STreehugger Robot ANTLR_UINT32 m_cachedSize; 358*16467b97STreehugger Robot 359*16467b97STreehugger Robot public: 360*16467b97STreehugger Robot TokenIntStream(); 361*16467b97STreehugger Robot ANTLR_UINT32 get_cachedSize() const; 362*16467b97STreehugger Robot void set_cachedSize( ANTLR_UINT32 cachedSize ); 363*16467b97STreehugger Robot 364*16467b97STreehugger Robot void consume(); 365*16467b97STreehugger Robot void consumeInitialHiddenTokens(); 366*16467b97STreehugger Robot ANTLR_UINT32 _LA( ANTLR_INT32 i ); 367*16467b97STreehugger Robot ANTLR_MARKER mark(); 368*16467b97STreehugger Robot ANTLR_UINT32 size(); 369*16467b97STreehugger Robot void release(); 370*16467b97STreehugger Robot ANTLR_MARKER tindex(); 371*16467b97STreehugger Robot void rewindLast(); 372*16467b97STreehugger Robot void rewind(ANTLR_MARKER marker); 373*16467b97STreehugger Robot void seek(ANTLR_MARKER index); 374*16467b97STreehugger Robot StringType getSourceName(); 375*16467b97STreehugger Robot 376*16467b97STreehugger Robot }; 377*16467b97STreehugger Robot 378*16467b97STreehugger Robot template<class ImplTraits> 379*16467b97STreehugger Robot class TreeNodeIntStream : public IntStream<ImplTraits, typename ImplTraits::CommonTreeNodeStreamType> 380*16467b97STreehugger Robot { 381*16467b97STreehugger Robot public: 382*16467b97STreehugger Robot typedef typename ImplTraits::CommonTreeNodeStreamType CommonTreeNodeStreamType; 383*16467b97STreehugger Robot typedef IntStream<ImplTraits, CommonTreeNodeStreamType > BaseType; 384*16467b97STreehugger Robot typedef typename ImplTraits::TreeType TreeType; 385*16467b97STreehugger Robot typedef typename ImplTraits::CommonTokenType CommonTokenType; 386*16467b97STreehugger Robot 387*16467b97STreehugger Robot public: 388*16467b97STreehugger Robot void consume(); 389*16467b97STreehugger Robot ANTLR_MARKER tindex(); 390*16467b97STreehugger Robot ANTLR_UINT32 _LA(ANTLR_INT32 i); 391*16467b97STreehugger Robot ANTLR_MARKER mark(); 392*16467b97STreehugger Robot void release(ANTLR_MARKER marker); 393*16467b97STreehugger Robot void rewindMark(ANTLR_MARKER marker); 394*16467b97STreehugger Robot void rewindLast(); 395*16467b97STreehugger Robot void seek(ANTLR_MARKER index); 396*16467b97STreehugger Robot ANTLR_UINT32 size(); 397*16467b97STreehugger Robot }; 398*16467b97STreehugger Robot 399*16467b97STreehugger Robot ANTLR_END_NAMESPACE() 400*16467b97STreehugger Robot 401*16467b97STreehugger Robot #include "antlr3intstream.inl" 402*16467b97STreehugger Robot 403*16467b97STreehugger Robot #endif 404*16467b97STreehugger Robot 405