ANTLR Support Libraries 2.7.1+
TokenWithIndex.hpp
Go to the documentation of this file.
1 #ifndef INC_TokenWithIndex_hpp__
2 #define INC_TokenWithIndex_hpp__
3 
4 /* ANTLR Translator Generator
5  * Project led by Terence Parr at http://www.jGuru.com
6  * Software rights: http://www.antlr.org/license.html
7  *
8  * $Id:$
9  */
10 
11 #include <antlr/config.hpp>
12 #include <antlr/CommonToken.hpp>
13 #include <antlr/String.hpp>
14 
15 #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
16 namespace antlr {
17 #endif
18 
20 public:
21  // static size_t count;
22  TokenWithIndex() : CommonToken(), index(0)
23  {
24  // std::cout << __PRETTY_FUNCTION__ << std::endl;
25  // count++;
26  }
27  TokenWithIndex(int t, const ANTLR_USE_NAMESPACE(std)string& txt)
28  : CommonToken(t,txt)
29  , index(0)
30  {
31  // std::cout << __PRETTY_FUNCTION__ << std::endl;
32  // count++;
33  }
35  : CommonToken(s)
36  , index(0)
37  {
38  // std::cout << __PRETTY_FUNCTION__ << std::endl;
39  // count++;
40  }
42  {
43  // count--;
44  }
45  void setIndex( size_t idx )
46  {
47  index = idx;
48  }
49  size_t getIndex( void ) const
50  {
51  return index;
52  }
53 
55  {
56  return ANTLR_USE_NAMESPACE(std)string("[")+
57  index+
58  ":\""+
59  getText()+"\",<"+
60  getType()+">,line="+
61  getLine()+",column="+
62  getColumn()+"]";
63  }
64 
65  static RefToken factory()
66  {
67  return RefToken(new TokenWithIndex());
68  }
69 
70 protected:
71  size_t index;
72 
73 private:
75  const TokenWithIndex& operator=(const TokenWithIndex&);
76 };
77 
79 
80 #ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
81 }
82 #endif
83 
84 #endif //INC_CommonToken_hpp__
TokenWithIndex()
Definition: TokenWithIndex.hpp:22
Definition: ANTLRException.hpp:15
std ::string toString() const
Definition: TokenWithIndex.hpp:54
TokenRefCount< TokenWithIndex > RefTokenWithIndex
Definition: TokenWithIndex.hpp:78
Definition: CommonToken.hpp:19
Definition: TokenWithIndex.hpp:19
#define ANTLR_API
Definition: config.hpp:22
void setIndex(size_t idx)
Definition: TokenWithIndex.hpp:45
TokenRefCount< Token > RefToken
Definition: TokenRefCount.hpp:92
size_t getIndex(void) const
Definition: TokenWithIndex.hpp:49
TokenWithIndex(int t, const std ::string &txt)
Definition: TokenWithIndex.hpp:27
#define ANTLR_USE_NAMESPACE(_x_)
Definition: config.hpp:18
TokenWithIndex(const std ::string &s)
Definition: TokenWithIndex.hpp:34
~TokenWithIndex()
Definition: TokenWithIndex.hpp:41
static RefToken factory()
Definition: TokenWithIndex.hpp:65
size_t index
Definition: TokenWithIndex.hpp:71