ANTLR Support Libraries 2.7.1+
Loading...
Searching...
No Matches
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
18namespace antlr {
19#endif
20
27public:
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
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
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
120 {
121 if (inputResponsible)
122 delete input;
123 }
124
126 int line;
132 InputBuffer& getInput();
133private:
138
139 // we don't want these:
142};
143
145{
146 return *input;
147}
148
151
152#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
153}
154#endif
155
156#endif //INC_LexerSharedInputState_hpp__
RefCount< LexerInputState > LexerSharedInputState
A reference counted LexerInputState object.
Definition LexerSharedInputState.hpp:150
Definition CharBuffer.hpp:35
Definition InputBuffer.hpp:31
Definition LexerSharedInputState.hpp:26
int tokenStartLine
Definition LexerSharedInputState.hpp:128
LexerInputState(std ::istream &in)
Definition LexerSharedInputState.hpp:63
virtual ~LexerInputState()
Definition LexerSharedInputState.hpp:119
InputBuffer & getInput()
Definition LexerSharedInputState.hpp:144
int tokenStartColumn
Definition LexerSharedInputState.hpp:127
std::string filename
Definition LexerSharedInputState.hpp:131
LexerInputState(InputBuffer *inbuf)
Definition LexerSharedInputState.hpp:32
virtual void initialize(std ::istream &in, const char *file="")
Definition LexerSharedInputState.hpp:80
void setPosition(int line_, int column_)
Definition LexerSharedInputState.hpp:113
virtual void reset(void)
Definition LexerSharedInputState.hpp:99
int column
Definition LexerSharedInputState.hpp:125
int guessing
Definition LexerSharedInputState.hpp:129
bool inputResponsible
Who is responsible for cleaning up the InputBuffer?
Definition LexerSharedInputState.hpp:137
InputBuffer * input
Input buffer we use.
Definition LexerSharedInputState.hpp:135
LexerInputState(InputBuffer &inbuf)
Definition LexerSharedInputState.hpp:47
LexerInputState & operator=(const LexerInputState &)
LexerInputState(const LexerInputState &)
int line
Definition LexerSharedInputState.hpp:126
Definition RefCount.hpp:17
#define ANTLR_USE_NAMESPACE(_x_)
Definition config.hpp:18
#define ANTLR_API
Definition config.hpp:22
Definition ANTLRException.hpp:15