summaryrefslogtreecommitdiffstats
path: root/lib/antlr/antlr/TokenWithIndex.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/antlr/antlr/TokenWithIndex.h')
-rw-r--r--lib/antlr/antlr/TokenWithIndex.h84
1 files changed, 84 insertions, 0 deletions
diff --git a/lib/antlr/antlr/TokenWithIndex.h b/lib/antlr/antlr/TokenWithIndex.h
new file mode 100644
index 00000000..d7511996
--- /dev/null
+++ b/lib/antlr/antlr/TokenWithIndex.h
@@ -0,0 +1,84 @@
+#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__