Doxygen
vhdl::parser::CharStream类 参考

This class describes a character stream that maintains line and column number positions of the characters. 更多...

#include <CharStream.h>

+ vhdl::parser::CharStream 的协作图:

Public 成员函数

void setTabSize (int i)
 
int getTabSize (int i)
 
virtual int getColumn ()
 
virtual int getLine ()
 
virtual int getEndColumn ()
 
virtual int getEndLine ()
 
virtual int getBeginColumn ()
 
virtual int getBeginLine ()
 
virtual bool getTrackLineColumn ()
 
virtual void setTrackLineColumn (bool val)
 
virtual void backup (int amount)
 Backs up the input stream by amount steps. 更多...
 
virtual JJChar BeginToken ()
 Returns the next character that marks the beginning of the next token. 更多...
 
virtual JJChar readChar ()
 Returns the next character from the selected input. 更多...
 
virtual void ExpandBuff (bool wrapAround)
 
virtual void FillBuff ()
 
virtual JJString GetImage ()
 Returns a string made up of characters from the marked token beginning to the current buffer position. 更多...
 
virtual JJString GetSuffix (int len)
 Returns an array of characters that make up the suffix of length 'len' for the currently matched token. 更多...
 
virtual void DeleteBuffers ()
 The lexer calls this function to indicate that it is done with the stream and hence implementations can free any resources held by this class. 更多...
 
virtual ~CharStream ()
 
bool endOfInput ()
 
 CharStream (const JJChar *buf, int sz, int startline, int startcolumn, int buffersize)
 
 CharStream (const JJChar *buf, int sz, int startline, int startcolumn)
 
 CharStream (const JJString &str, int startline, int startcolumn, int buffersize)
 
 CharStream (const JJString &str, int startline, int startcolumn)
 
 CharStream (ReaderStream *input_stream, int startline, int startcolumn, int buffersize)
 
 CharStream (ReaderStream *input_stream, int startline, int startcolumn)
 
 CharStream (ReaderStream *input_stream)
 
virtual void ReInit (ReaderStream *input_stream, int startline, int startcolumn, int buffersize)
 
virtual void ReInit (ReaderStream *input_stream, int startline, int startcolumn)
 
virtual void ReInit (ReaderStream *input_stream)
 
virtual void ReInit (const JJString &str, int startline, int startcolumn, int buffersize)
 
virtual void ReInit (const JJString &str, int startline, int startcolumn)
 
virtual void adjustBeginLineColumn (int newLine, int newCol)
 

Protected 成员函数

virtual void UpdateLineColumn (JJChar c)
 

Protected 属性

int * bufline
 
int * bufcolumn
 
JJCharbuffer
 
int bufpos
 
int bufsize
 
int tokenBegin
 
int column
 
int line
 
bool prevCharIsCR
 
bool prevCharIsLF
 
int available
 
int maxNextCharInd
 
int inBuf
 
int tabSize
 
bool trackLineColumn
 
ReaderStreaminputStream
 
bool deleteStream
 

Private 成员函数

int getBufcolumn (int pos)
 
int getBufline (int pos)
 

详细描述

This class describes a character stream that maintains line and column number positions of the characters.

It also has the capability to backup the stream to some extent. An implementation of this class is used in the TokenManager implementation generated by JavaCCParser.

All the methods except backup can be implemented in any fashion. backup needs to be implemented correctly for the correct operation of the lexer. Rest of the methods are all used to get information like line number, column number and the string that constitutes a token and are not used by the lexer. Hence their implementation won't affect the generated lexer's operation.

在文件 CharStream.h31 行定义.

构造及析构函数说明

◆ ~CharStream()

virtual vhdl::parser::CharStream::~CharStream ( )
inlinevirtual

在文件 CharStream.h155 行定义.

155  {
156  if (deleteStream) {
157  delete inputStream;
158  }
159  DeleteBuffers();
160  }

引用了 DeleteBuffers(), deleteStream , 以及 inputStream.

◆ CharStream() [1/7]

vhdl::parser::CharStream::CharStream ( const JJChar buf,
int  sz,
int  startline,
int  startcolumn,
int  buffersize 
)
inline

在文件 CharStream.h166 行定义.

167  :
168  bufline(nullptr), bufcolumn(nullptr), buffer(nullptr), bufpos(0), bufsize(0),
169  tokenBegin(0), column(0), line(0), prevCharIsCR(false), prevCharIsLF(false),
170  available(0), maxNextCharInd(0), inBuf(0), tabSize(1), trackLineColumn(true),
171  inputStream(nullptr), deleteStream(false) {
172  ReInit(JJString(buf, sz), startline, startcolumn, buffersize);
173  }

引用了 ReInit().

◆ CharStream() [2/7]

vhdl::parser::CharStream::CharStream ( const JJChar buf,
int  sz,
int  startline,
int  startcolumn 
)
inline

在文件 CharStream.h175 行定义.

175  :
176  bufline(nullptr), bufcolumn(nullptr), buffer(nullptr), bufpos(0), bufsize(0),
177  tokenBegin(0), column(0), line(0), prevCharIsCR(false), prevCharIsLF(false),
178  available(0), maxNextCharInd(0), inBuf(0), tabSize(1), trackLineColumn(true),
179  inputStream(nullptr), deleteStream(false) {
180  ReInit(JJString(buf, sz), startline, startcolumn, INITIAL_BUFFER_SIZE);
181  }

引用了 INITIAL_BUFFER_SIZE , 以及 ReInit().

◆ CharStream() [3/7]

vhdl::parser::CharStream::CharStream ( const JJString str,
int  startline,
int  startcolumn,
int  buffersize 
)
inline

在文件 CharStream.h183 行定义.

184  :
185  bufline(nullptr), bufcolumn(nullptr), buffer(nullptr), bufpos(0), bufsize(0),
186  tokenBegin(0), column(0), line(0), prevCharIsCR(false), prevCharIsLF(false),
187  available(0), maxNextCharInd(0), inBuf(0), tabSize(1), trackLineColumn(true),
188  inputStream(nullptr), deleteStream(false) {
189  ReInit(str, startline, startcolumn, buffersize);
190  }

引用了 ReInit().

◆ CharStream() [4/7]

vhdl::parser::CharStream::CharStream ( const JJString str,
int  startline,
int  startcolumn 
)
inline

在文件 CharStream.h192 行定义.

192  :
193  bufline(nullptr), bufcolumn(nullptr), buffer(nullptr), bufpos(0), bufsize(0),
194  tokenBegin(0), column(0), line(0), prevCharIsCR(false), prevCharIsLF(false),
195  available(0), maxNextCharInd(0), inBuf(0), tabSize(1), trackLineColumn(true),
196  inputStream(nullptr), deleteStream(false) {
197  ReInit(str, startline, startcolumn, INITIAL_BUFFER_SIZE);
198  }

引用了 INITIAL_BUFFER_SIZE , 以及 ReInit().

◆ CharStream() [5/7]

vhdl::parser::CharStream::CharStream ( ReaderStream input_stream,
int  startline,
int  startcolumn,
int  buffersize 
)
inline

在文件 CharStream.h200 行定义.

201  :
202  bufline(nullptr), bufcolumn(nullptr), buffer(nullptr), bufpos(0), bufsize(0),
203  tokenBegin(0), column(0), line(0), prevCharIsCR(false), prevCharIsLF(false),
204  available(0), maxNextCharInd(0), inBuf(0), tabSize(1), trackLineColumn(true),
205  inputStream(nullptr), deleteStream(false) {
206  ReInit(input_stream, startline, startcolumn, buffersize);
207  }

引用了 ReInit().

◆ CharStream() [6/7]

vhdl::parser::CharStream::CharStream ( ReaderStream input_stream,
int  startline,
int  startcolumn 
)
inline

在文件 CharStream.h209 行定义.

209  :
210  bufline(nullptr), bufcolumn(nullptr), buffer(nullptr), bufpos(0), bufsize(0),
211  tokenBegin(0), column(0), line(0), prevCharIsCR(false), prevCharIsLF(false),
212  available(0), maxNextCharInd(0), inBuf(0), tabSize(1), trackLineColumn(true),
213  inputStream(nullptr), deleteStream(false) {
214  ReInit(input_stream, startline, startcolumn, INITIAL_BUFFER_SIZE);
215  }

引用了 INITIAL_BUFFER_SIZE , 以及 ReInit().

◆ CharStream() [7/7]

vhdl::parser::CharStream::CharStream ( ReaderStream input_stream)
inline

在文件 CharStream.h217 行定义.

217  :
218  bufline(nullptr), bufcolumn(nullptr), buffer(nullptr), bufpos(0), bufsize(0),
219  tokenBegin(0), column(0), line(0), prevCharIsCR(false), prevCharIsLF(false),
220  available(0), maxNextCharInd(0), inBuf(0), tabSize(1), trackLineColumn(true),
221  inputStream(nullptr), deleteStream(false) {
222  ReInit(input_stream, 1, 1, INITIAL_BUFFER_SIZE);
223  }

引用了 INITIAL_BUFFER_SIZE , 以及 ReInit().

成员函数说明

◆ adjustBeginLineColumn()

virtual void vhdl::parser::CharStream::adjustBeginLineColumn ( int  newLine,
int  newCol 
)
virtual

◆ backup()

virtual void vhdl::parser::CharStream::backup ( int  amount)
inlinevirtual

Backs up the input stream by amount steps.

Lexer calls this method if it had already read some characters, but could not use them to match a (longer) token. So, they will be used again as the prefix of the next token and it is the implemetation's responsibility to do this right.

在文件 CharStream.h69 行定义.

69  {
70  inBuf += amount;
71  bufpos -= amount;
72  if (bufpos < 0) {
73  bufpos += bufsize;
74  }
75  }

引用了 bufpos, bufsize , 以及 inBuf.

◆ BeginToken()

virtual JJChar vhdl::parser::CharStream::BeginToken ( )
inlinevirtual

Returns the next character that marks the beginning of the next token.

All characters must remain in the buffer between two successive calls to this method to implement backup correctly.

在文件 CharStream.h82 行定义.

82  {
83  tokenBegin = -1;
84  JJChar c = readChar();
86  return c;
87  }

引用了 bufpos, readChar() , 以及 tokenBegin.

◆ DeleteBuffers()

virtual void vhdl::parser::CharStream::DeleteBuffers ( )
virtual

The lexer calls this function to indicate that it is done with the stream and hence implementations can free any resources held by this class.

被这些函数引用 ~CharStream().

◆ endOfInput()

bool vhdl::parser::CharStream::endOfInput ( )
inline

在文件 CharStream.h162 行定义.

162  {
163  return inBuf == 0 && bufpos + 1 >= maxNextCharInd && inputStream->endOfInput();
164  }

引用了 bufpos, ReaderStream::endOfInput(), inBuf, inputStream , 以及 maxNextCharInd.

◆ ExpandBuff()

virtual void vhdl::parser::CharStream::ExpandBuff ( bool  wrapAround)
virtual

◆ FillBuff()

virtual void vhdl::parser::CharStream::FillBuff ( )
virtual

被这些函数引用 readChar().

◆ getBeginColumn()

virtual int vhdl::parser::CharStream::getBeginColumn ( )
inlinevirtual

在文件 CharStream.h57 行定义.

57 { return getBufcolumn(tokenBegin); }

引用了 getBufcolumn() , 以及 tokenBegin.

◆ getBeginLine()

virtual int vhdl::parser::CharStream::getBeginLine ( )
inlinevirtual

在文件 CharStream.h58 行定义.

58 { return getBufline(tokenBegin); }

引用了 getBufline() , 以及 tokenBegin.

◆ getBufcolumn()

int vhdl::parser::CharStream::getBufcolumn ( int  pos)
inlineprivate

在文件 CharStream.h37 行定义.

37  {
38  if (trackLineColumn && pos>=0) {
39  return bufcolumn[pos];
40  } else {
41  return -1;
42  }
43  }

引用了 bufcolumn , 以及 trackLineColumn.

被这些函数引用 getBeginColumn(), getColumn() , 以及 getEndColumn().

◆ getBufline()

int vhdl::parser::CharStream::getBufline ( int  pos)
inlineprivate

在文件 CharStream.h44 行定义.

44  {
45  if (trackLineColumn && pos>=0) {
46  return bufline[pos];
47  } else {
48  return -1;
49  }
50  }

引用了 bufline , 以及 trackLineColumn.

被这些函数引用 getBeginLine(), getEndLine() , 以及 getLine().

◆ getColumn()

virtual int vhdl::parser::CharStream::getColumn ( )
inlinevirtual

在文件 CharStream.h53 行定义.

53 { return getBufcolumn(bufpos); }

引用了 bufpos , 以及 getBufcolumn().

◆ getEndColumn()

virtual int vhdl::parser::CharStream::getEndColumn ( )
inlinevirtual

在文件 CharStream.h55 行定义.

55 { return getBufcolumn(bufpos); }

引用了 bufpos , 以及 getBufcolumn().

◆ getEndLine()

virtual int vhdl::parser::CharStream::getEndLine ( )
inlinevirtual

在文件 CharStream.h56 行定义.

56 { return getBufline(bufpos); }

引用了 bufpos , 以及 getBufline().

◆ GetImage()

virtual JJString vhdl::parser::CharStream::GetImage ( )
inlinevirtual

Returns a string made up of characters from the marked token beginning to the current buffer position.

Implementations can return anything that they want to. For example, for efficiency, one might decide to just return NULL, which is a valid implementation.

在文件 CharStream.h129 行定义.

129  {
130  if (bufpos >= tokenBegin)
131  return JJString(buffer + tokenBegin, bufpos - tokenBegin + 1);
132  else
133  return JJString(buffer + tokenBegin, bufsize - tokenBegin).append(buffer, bufpos + 1);
134  }

引用了 buffer, bufpos, bufsize , 以及 tokenBegin.

◆ getLine()

virtual int vhdl::parser::CharStream::getLine ( )
inlinevirtual

在文件 CharStream.h54 行定义.

54 { return getBufline(bufpos); }

引用了 bufpos , 以及 getBufline().

◆ GetSuffix()

virtual JJString vhdl::parser::CharStream::GetSuffix ( int  len)
inlinevirtual

Returns an array of characters that make up the suffix of length 'len' for the currently matched token.

This is used to build up the matched string for use in actions in the case of MORE. A simple and inefficient implementation of this is as follows :

在文件 CharStream.h142 行定义.

142  {
143  if ((bufpos + 1) >= len) {
144  return JJString(buffer + bufpos - len + 1, len);
145  }
146  return JJString(buffer + bufsize - (len - bufpos - 1), len - bufpos - 1).append(buffer, bufpos + 1);
147  }

引用了 buffer, bufpos , 以及 bufsize.

◆ getTabSize()

int vhdl::parser::CharStream::getTabSize ( int  i)
inline

在文件 CharStream.h34 行定义.

34 { return tabSize; }

引用了 tabSize.

◆ getTrackLineColumn()

virtual bool vhdl::parser::CharStream::getTrackLineColumn ( )
inlinevirtual

在文件 CharStream.h60 行定义.

60 { return trackLineColumn; }

引用了 trackLineColumn.

◆ readChar()

virtual JJChar vhdl::parser::CharStream::readChar ( )
inlinevirtual

Returns the next character from the selected input.

The method of selecting the input is the responsibility of the class implementing this class.

在文件 CharStream.h95 行定义.

95  {
96  if (inBuf > 0) {
97  --inBuf;
98  ++bufpos;
99  if (bufpos == bufsize) {
100  bufpos = 0;
101  }
102  return buffer[bufpos];
103  }
104 
105  ++bufpos;
106  if (bufpos >= maxNextCharInd) {
107  FillBuff();
108  }
109 
110  JJChar c = buffer[bufpos];
111 
112  if (trackLineColumn) {
113  UpdateLineColumn(c);
114  }
115 
116  return c;
117  }

引用了 buffer, bufpos, bufsize, FillBuff(), inBuf, maxNextCharInd, trackLineColumn , 以及 UpdateLineColumn().

被这些函数引用 BeginToken().

◆ ReInit() [1/5]

virtual void vhdl::parser::CharStream::ReInit ( const JJString str,
int  startline,
int  startcolumn 
)
inlinevirtual

在文件 CharStream.h238 行定义.

239  {
240  ReInit(str, startline, startcolumn, INITIAL_BUFFER_SIZE);
241  }

引用了 INITIAL_BUFFER_SIZE , 以及 ReInit().

◆ ReInit() [2/5]

virtual void vhdl::parser::CharStream::ReInit ( const JJString str,
int  startline,
int  startcolumn,
int  buffersize 
)
virtual

◆ ReInit() [3/5]

virtual void vhdl::parser::CharStream::ReInit ( ReaderStream input_stream)
inlinevirtual

在文件 CharStream.h231 行定义.

231  {
232  ReInit(input_stream, 1, 1, INITIAL_BUFFER_SIZE);
233  }

引用了 INITIAL_BUFFER_SIZE , 以及 ReInit().

◆ ReInit() [4/5]

virtual void vhdl::parser::CharStream::ReInit ( ReaderStream input_stream,
int  startline,
int  startcolumn 
)
inlinevirtual

在文件 CharStream.h227 行定义.

227  {
228  ReInit(input_stream, startline, startcolumn, INITIAL_BUFFER_SIZE);
229  }

引用了 INITIAL_BUFFER_SIZE , 以及 ReInit().

◆ ReInit() [5/5]

virtual void vhdl::parser::CharStream::ReInit ( ReaderStream input_stream,
int  startline,
int  startcolumn,
int  buffersize 
)
virtual

被这些函数引用 CharStream() , 以及 ReInit().

◆ setTabSize()

void vhdl::parser::CharStream::setTabSize ( int  i)
inline

在文件 CharStream.h33 行定义.

33 { tabSize = i; }

引用了 tabSize.

◆ setTrackLineColumn()

virtual void vhdl::parser::CharStream::setTrackLineColumn ( bool  val)
inlinevirtual

在文件 CharStream.h61 行定义.

61 { trackLineColumn = val; }

引用了 trackLineColumn.

◆ UpdateLineColumn()

virtual void vhdl::parser::CharStream::UpdateLineColumn ( JJChar  c)
protectedvirtual

被这些函数引用 readChar().

类成员变量说明

◆ available

int vhdl::parser::CharStream::available
protected

在文件 CharStream.h258 行定义.

◆ bufcolumn

int* vhdl::parser::CharStream::bufcolumn
protected

在文件 CharStream.h249 行定义.

被这些函数引用 getBufcolumn().

◆ buffer

JJChar* vhdl::parser::CharStream::buffer
protected

在文件 CharStream.h250 行定义.

被这些函数引用 GetImage(), GetSuffix() , 以及 readChar().

◆ bufline

int* vhdl::parser::CharStream::bufline
protected

在文件 CharStream.h248 行定义.

被这些函数引用 getBufline().

◆ bufpos

int vhdl::parser::CharStream::bufpos
protected

◆ bufsize

int vhdl::parser::CharStream::bufsize
protected

在文件 CharStream.h252 行定义.

被这些函数引用 backup(), GetImage(), GetSuffix() , 以及 readChar().

◆ column

int vhdl::parser::CharStream::column
protected

在文件 CharStream.h254 行定义.

◆ deleteStream

bool vhdl::parser::CharStream::deleteStream
protected

在文件 CharStream.h264 行定义.

被这些函数引用 ~CharStream().

◆ inBuf

int vhdl::parser::CharStream::inBuf
protected

在文件 CharStream.h260 行定义.

被这些函数引用 backup(), endOfInput() , 以及 readChar().

◆ inputStream

ReaderStream* vhdl::parser::CharStream::inputStream
protected

在文件 CharStream.h263 行定义.

被这些函数引用 endOfInput() , 以及 ~CharStream().

◆ line

int vhdl::parser::CharStream::line
protected

在文件 CharStream.h255 行定义.

◆ maxNextCharInd

int vhdl::parser::CharStream::maxNextCharInd
protected

在文件 CharStream.h259 行定义.

被这些函数引用 endOfInput() , 以及 readChar().

◆ prevCharIsCR

bool vhdl::parser::CharStream::prevCharIsCR
protected

在文件 CharStream.h256 行定义.

◆ prevCharIsLF

bool vhdl::parser::CharStream::prevCharIsLF
protected

在文件 CharStream.h257 行定义.

◆ tabSize

int vhdl::parser::CharStream::tabSize
protected

在文件 CharStream.h261 行定义.

被这些函数引用 getTabSize() , 以及 setTabSize().

◆ tokenBegin

int vhdl::parser::CharStream::tokenBegin
protected

在文件 CharStream.h253 行定义.

被这些函数引用 BeginToken(), getBeginColumn(), getBeginLine() , 以及 GetImage().

◆ trackLineColumn

bool vhdl::parser::CharStream::trackLineColumn
protected

在文件 CharStream.h262 行定义.

被这些函数引用 getBufcolumn(), getBufline(), getTrackLineColumn(), readChar() , 以及 setTrackLineColumn().


该类的文档由以下文件生成:
vhdl::parser::CharStream::line
int line
Definition: CharStream.h:255
INITIAL_BUFFER_SIZE
#define INITIAL_BUFFER_SIZE
Definition: CharStream.h:9
JJChar
JAVACC_CHAR_TYPE JJChar
Definition: JavaCC.h:21
vhdl::parser::CharStream::UpdateLineColumn
virtual void UpdateLineColumn(JJChar c)
vhdl::parser::CharStream::available
int available
Definition: CharStream.h:258
vhdl::parser::CharStream::column
int column
Definition: CharStream.h:254
vhdl::parser::CharStream::trackLineColumn
bool trackLineColumn
Definition: CharStream.h:262
vhdl::parser::CharStream::bufpos
int bufpos
Definition: CharStream.h:251
vhdl::parser::CharStream::FillBuff
virtual void FillBuff()
vhdl::parser::CharStream::ReInit
virtual void ReInit(ReaderStream *input_stream, int startline, int startcolumn, int buffersize)
vhdl::parser::CharStream::prevCharIsCR
bool prevCharIsCR
Definition: CharStream.h:256
ReaderStream::endOfInput
virtual bool endOfInput()
Definition: JavaCC.h:31
vhdl::parser::CharStream::getBufcolumn
int getBufcolumn(int pos)
Definition: CharStream.h:37
vhdl::parser::CharStream::getBufline
int getBufline(int pos)
Definition: CharStream.h:44
vhdl::parser::CharStream::bufline
int * bufline
Definition: CharStream.h:248
vhdl::parser::CharStream::buffer
JJChar * buffer
Definition: CharStream.h:250
vhdl::parser::CharStream::inBuf
int inBuf
Definition: CharStream.h:260
vhdl::parser::CharStream::tabSize
int tabSize
Definition: CharStream.h:261
JJString
JAVACC_STRING_TYPE JJString
Definition: JavaCC.h:22
vhdl::parser::CharStream::bufsize
int bufsize
Definition: CharStream.h:252
vhdl::parser::CharStream::prevCharIsLF
bool prevCharIsLF
Definition: CharStream.h:257
vhdl::parser::CharStream::readChar
virtual JJChar readChar()
Returns the next character from the selected input.
Definition: CharStream.h:95
vhdl::parser::CharStream::maxNextCharInd
int maxNextCharInd
Definition: CharStream.h:259
vhdl::parser::CharStream::deleteStream
bool deleteStream
Definition: CharStream.h:264
vhdl::parser::CharStream::DeleteBuffers
virtual void DeleteBuffers()
The lexer calls this function to indicate that it is done with the stream and hence implementations c...
vhdl::parser::CharStream::bufcolumn
int * bufcolumn
Definition: CharStream.h:249
vhdl::parser::CharStream::tokenBegin
int tokenBegin
Definition: CharStream.h:253
vhdl::parser::CharStream::inputStream
ReaderStream * inputStream
Definition: CharStream.h:263