ANTLR Support Libraries 2.7.1+
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Friends
Macros
Pages
antlr
LexerSharedInputState.hpp
Go to the documentation of this file.
1
#ifndef INC_LexerSharedInputState_hpp__
2
#define INC_LexerSharedInputState_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: //depot/code/org.antlr/release/antlr-2.7.7/lib/cpp/antlr/LexerSharedInputState.hpp#2 $
9
*/
10
11
#include <
antlr/config.hpp
>
12
#include <
antlr/InputBuffer.hpp
>
13
#include <
antlr/RefCount.hpp
>
14
#include <
antlr/CharBuffer.hpp
>
15
#include <string>
16
17
#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
18
namespace
antlr {
19
#endif
20
26
class
ANTLR_API
LexerInputState
{
27
public
:
32
LexerInputState
(
InputBuffer
* inbuf)
33
: column(1)
34
, line(1)
35
, tokenStartColumn(1)
36
, tokenStartLine(1)
37
, guessing(0)
38
, filename(
""
)
39
, input(inbuf)
40
, inputResponsible(true)
41
{
42
}
43
47
LexerInputState
(
InputBuffer
& inbuf)
48
: column(1)
49
, line(1)
50
, tokenStartColumn(1)
51
, tokenStartLine(1)
52
, guessing(0)
53
, filename(
""
)
54
, input(&inbuf)
55
, inputResponsible(false)
56
{
57
}
58
63
LexerInputState
(
ANTLR_USE_NAMESPACE
(std)istream& in)
64
: column(1)
65
, line(1)
66
, tokenStartColumn(1)
67
, tokenStartLine(1)
68
, guessing(0)
69
, filename(
""
)
70
, input(new
CharBuffer
(in))
71
, inputResponsible(true)
72
{
73
}
74
80
virtual
void
initialize(
ANTLR_USE_NAMESPACE
(std)istream& in,
const
char
* file =
""
)
81
{
82
column = 1;
83
line = 1;
84
tokenStartColumn = 1;
85
tokenStartLine = 1;
86
guessing = 0;
87
filename = file;
88
89
if
( input && inputResponsible )
90
delete
input;
91
92
input =
new
CharBuffer
(in);
93
inputResponsible =
true
;
94
}
95
99
virtual
void
reset(
void
)
100
{
101
column = 1;
102
line = 1;
103
tokenStartColumn = 1;
104
tokenStartLine = 1;
105
guessing = 0;
106
input->reset();
107
}
108
113
void
setPosition(
int
line_,
int
column_ )
114
{
115
line = line_;
116
column = column_;
117
}
118
119
virtual
~
LexerInputState
()
120
{
121
if
(inputResponsible)
122
delete
input;
123
}
124
125
int
column
;
126
int
line
;
127
int
tokenStartColumn
;
128
int
tokenStartLine
;
129
int
guessing
;
131
ANTLR_USE_NAMESPACE
(std)string filename;
132
InputBuffer
& getInput();
133
private:
135
InputBuffer
* input;
137
bool
inputResponsible;
138
139
// we don't want these:
140
LexerInputState
(const
LexerInputState
&);
141
LexerInputState& operator=(const LexerInputState&);
142
};
143
144
inline
InputBuffer
& LexerInputState::getInput()
145
{
146
return
*input;
147
}
148
150
typedef
RefCount<LexerInputState>
LexerSharedInputState
;
151
152
#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
153
}
154
#endif
155
156
#endif //INC_LexerSharedInputState_hpp__
Generated by
1.8.1.1