OpenMD
3.1
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
Token.hpp
1
#ifndef INC_Token_hpp__
2
#define INC_Token_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/TokenRefCount.hpp>
13
#include <string>
14
15
#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
16
namespace
antlr {
17
#endif
18
19
struct
TokenRef;
20
21
/** A token is minimally a token type. Subclasses can add the text matched
22
* for the token and line info.
23
*/
24
class
ANTLR_API
Token
25
{
26
public
:
27
// constants
28
#ifndef NO_STATIC_CONSTS
29
static
const
int
MIN_USER_TYPE = 4;
30
static
const
int
NULL_TREE_LOOKAHEAD = 3;
31
static
const
int
INVALID_TYPE = 0;
32
static
const
int
EOF_TYPE = 1;
33
static
const
int
SKIP = -1;
34
#else
35
enum
{
36
MIN_USER_TYPE = 4,
37
NULL_TREE_LOOKAHEAD = 3,
38
INVALID_TYPE = 0,
39
EOF_TYPE = 1,
40
SKIP = -1
41
};
42
#endif
43
44
Token
()
45
: ref(0)
46
, type(INVALID_TYPE)
47
{
48
}
49
Token
(
int
t)
50
: ref(0)
51
, type(t)
52
{
53
}
54
Token
(
int
t,
const
ANTLR_USE_NAMESPACE(std)
string
& txt)
55
: ref(0)
56
, type(t)
57
{
58
setText(txt);
59
}
60
virtual
~Token
()
61
{
62
}
63
64
virtual
int
getColumn()
const
;
65
virtual
int
getLine()
const
;
66
virtual
ANTLR_USE_NAMESPACE(std)
string
getText()
const
;
67
virtual
const
ANTLR_USE_NAMESPACE(std)
string
& getFilename()
const
;
68
virtual
int
getType()
const
;
69
70
virtual
void
setColumn(
int
c);
71
72
virtual
void
setLine(
int
l);
73
virtual
void
setText(
const
ANTLR_USE_NAMESPACE(std)
string
& t);
74
virtual
void
setType(
int
t);
75
76
virtual
void
setFilename(
const
std::string& file );
77
78
virtual
ANTLR_USE_NAMESPACE(std)
string
toString()
const
;
79
80
private
:
81
friend
struct
TokenRef
;
82
TokenRef
* ref;
83
84
int
type;
///< the type of the token
85
86
Token
(
RefToken
other);
87
Token
& operator=(
const
Token
& other);
88
Token
& operator=(
RefToken
other);
89
90
Token
(
const
Token
&);
91
};
92
93
extern
ANTLR_API
RefToken
nullToken;
94
95
#ifdef NEEDS_OPERATOR_LESS_THAN
96
// RK: Added after 2.7.2 previously it was undefined.
97
// AL: what to return if l and/or r point to nullToken???
98
inline
bool
operator<(
RefToken
l,
RefToken
r )
99
{
100
return
nullToken == l ? ( nullToken == r ? false : true ) : l->getType() < r->getType();
101
}
102
#endif
103
104
#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
105
}
106
#endif
107
108
#endif
//INC_Token_hpp__
antlr::Token
A token is minimally a token type.
Definition
Token.hpp:25
antlr::TokenRefCount< Token >
antlr::TokenRef
Definition
TokenRefCount.hpp:20
antlr
Token.hpp
Generated on Wed Jun 26 2024 13:56:38 for OpenMD by
1.11.0