You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tdevelop/lib/antlr/antlr/TokenWithIndex.h

85 lines
1.6 KiB

#ifndef INC_TokenWithIndex_h__
#define INC_TokenWithIndex_h__
/* ANTLR Translator Generator
* Project led by Terence Parr at http://www.jGuru.com
* Software rights: http://www.antlr.org/license.html
*
* $Id:$
*/
#include <antlr/config.h>
#include <antlr/CommonToken.h>
#include <antlr/String.h>
#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
namespace antlr {
#endif
class ANTLR_API TokenWithIndex : public ANTLR_USE_NAMESPACE(antlr)CommonToken {
public:
// static size_t count;
TokenWithIndex() : CommonToken(), index(0)
{
// std::cout << __PRETTY_FUNCTION__ << std::endl;
// count++;
}
TokenWithIndex(int t, const ANTLR_USE_NAMESPACE(std)string& txt)
: CommonToken(t,txt)
, index(0)
{
// std::cout << __PRETTY_FUNCTION__ << std::endl;
// count++;
}
TokenWithIndex(const ANTLR_USE_NAMESPACE(std)string& s)
: CommonToken(s)
, index(0)
{
// std::cout << __PRETTY_FUNCTION__ << std::endl;
// count++;
}
~TokenWithIndex()
{
// count--;
}
void setIndex( size_t idx )
{
index = idx;
}
size_t getIndex( void ) const
{
return index;
}
ANTLR_USE_NAMESPACE(std)string toString() const
{
return ANTLR_USE_NAMESPACE(std)string("[")+
index+
":\""+
getText()+"\",<"+
getType()+">,line="+
getLine()+",column="+
getColumn()+"]";
}
static RefToken factory()
{
return RefToken(new TokenWithIndex());
}
protected:
size_t index;
private:
TokenWithIndex(const TokenWithIndex&);
const TokenWithIndex& operator=(const TokenWithIndex&);
};
typedef TokenRefCount<TokenWithIndex> RefTokenWithIndex;
#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
}
#endif
#endif //INC_CommonToken_h__