The CharStream
Class Reference
This class describes a character stream that maintains line and column number positions of the characters. More...
Declaration
Included Headers
Public Constructors Index
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) | |
Public Destructor Index
~CharStream () | |
Public Member Functions Index
void | setTabSize (int i) |
int | getTabSize (int i) |
int | getColumn () |
int | getLine () |
int | getEndColumn () |
int | getEndLine () |
int | getBeginColumn () |
int | getBeginLine () |
bool | getTrackLineColumn () |
void | setTrackLineColumn (bool val) |
void | backup (int amount) |
Backs up the input stream by amount steps. More... | |
JJChar | BeginToken () |
Returns the next character that marks the beginning of the next token. More... | |
JJChar | readChar () |
Returns the next character from the selected input. More... | |
void | ExpandBuff (bool wrapAround) |
void | FillBuff () |
JJString | GetImage () |
Returns a string made up of characters from the marked token beginning to the current buffer position. More... | |
JJString | GetSuffix (int len) |
Returns an array of characters that make up the suffix of length 'len' for the currently matched token. More... | |
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. More... | |
bool | endOfInput () |
void | ReInit (ReaderStream *input_stream, int startline, int startcolumn, int buffersize) |
void | ReInit (ReaderStream *input_stream, int startline, int startcolumn) |
void | ReInit (ReaderStream *input_stream) |
void | ReInit (const JJString &str, int startline, int startcolumn, int buffersize) |
void | ReInit (const JJString &str, int startline, int startcolumn) |
void | adjustBeginLineColumn (int newLine, int newCol) |
Protected Member Functions Index
void | UpdateLineColumn (JJChar c) |
Private Member Functions Index
int | getBufcolumn (int pos) |
int | getBufline (int pos) |
Protected Member Attributes Index
int * | bufline |
int * | bufcolumn |
JJChar * | buffer |
int | bufpos |
int | bufsize |
int | tokenBegin |
int | column |
int | line |
bool | prevCharIsCR |
bool | prevCharIsLF |
int | available |
int | maxNextCharInd |
int | inBuf |
int | tabSize |
bool | trackLineColumn |
ReaderStream * | inputStream |
bool | deleteStream |
Description
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.
Definition at line 31 of file CharStream.h.
Public Constructors
CharStream()
| inline |
Definition at line 166 of file CharStream.h.
References available, bufcolumn, buffer, bufline, bufpos, bufsize, column, deleteStream, inBuf, inputStream, line, maxNextCharInd, prevCharIsCR, prevCharIsLF, ReInit, tabSize, tokenBegin and trackLineColumn.
CharStream()
| inline |
Definition at line 175 of file CharStream.h.
References available, bufcolumn, buffer, bufline, bufpos, bufsize, column, deleteStream, inBuf, INITIAL_BUFFER_SIZE, inputStream, line, maxNextCharInd, prevCharIsCR, prevCharIsLF, ReInit, tabSize, tokenBegin and trackLineColumn.
CharStream()
| inline |
Definition at line 183 of file CharStream.h.
References available, bufcolumn, buffer, bufline, bufpos, bufsize, column, deleteStream, inBuf, inputStream, line, maxNextCharInd, prevCharIsCR, prevCharIsLF, ReInit, tabSize, tokenBegin and trackLineColumn.
CharStream()
| inline |
Definition at line 192 of file CharStream.h.
References available, bufcolumn, buffer, bufline, bufpos, bufsize, column, deleteStream, inBuf, INITIAL_BUFFER_SIZE, inputStream, line, maxNextCharInd, prevCharIsCR, prevCharIsLF, ReInit, tabSize, tokenBegin and trackLineColumn.
CharStream()
| inline |
Definition at line 200 of file CharStream.h.
References available, bufcolumn, buffer, bufline, bufpos, bufsize, column, deleteStream, inBuf, inputStream, line, maxNextCharInd, prevCharIsCR, prevCharIsLF, ReInit, tabSize, tokenBegin and trackLineColumn.
CharStream()
| inline |
Definition at line 209 of file CharStream.h.
References available, bufcolumn, buffer, bufline, bufpos, bufsize, column, deleteStream, inBuf, INITIAL_BUFFER_SIZE, inputStream, line, maxNextCharInd, prevCharIsCR, prevCharIsLF, ReInit, tabSize, tokenBegin and trackLineColumn.
CharStream()
| inline |
Definition at line 217 of file CharStream.h.
References available, bufcolumn, buffer, bufline, bufpos, bufsize, column, deleteStream, inBuf, INITIAL_BUFFER_SIZE, inputStream, line, maxNextCharInd, prevCharIsCR, prevCharIsLF, ReInit, tabSize, tokenBegin and trackLineColumn.
Public Destructor
~CharStream()
| inline virtual |
Definition at line 155 of file CharStream.h.
References DeleteBuffers, deleteStream and inputStream.
Public Member Functions
adjustBeginLineColumn()
| virtual |
Definition at line 243 of file CharStream.h.
Reference newLine.
backup()
| inline virtual |
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 implementation's responsibility to do this right.
Definition at line 69 of file CharStream.h.
BeginToken()
| inline virtual |
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.
Definition at line 82 of file CharStream.h.
References bufpos, readChar and tokenBegin.
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.
Definition at line 153 of file CharStream.h.
Referenced by ~CharStream.
endOfInput()
| inline |
Definition at line 162 of file CharStream.h.
References bufpos, inBuf, inputStream and maxNextCharInd.
ExpandBuff()
| virtual |
Definition at line 120 of file CharStream.h.
FillBuff()
| virtual |
Definition at line 121 of file CharStream.h.
Referenced by readChar.
getBeginColumn()
| inline virtual |
Definition at line 57 of file CharStream.h.
References getBufcolumn and tokenBegin.
getBeginLine()
| inline virtual |
Definition at line 58 of file CharStream.h.
References getBufline and tokenBegin.
getColumn()
| inline virtual |
Definition at line 53 of file CharStream.h.
References bufpos and getBufcolumn.
getEndColumn()
| inline virtual |
Definition at line 55 of file CharStream.h.
References bufpos and getBufcolumn.
getEndLine()
| inline virtual |
Definition at line 56 of file CharStream.h.
References bufpos and getBufline.
GetImage()
| inline virtual |
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.
Definition at line 129 of file CharStream.h.
References buffer, bufpos, bufsize and tokenBegin.
getLine()
| inline virtual |
Definition at line 54 of file CharStream.h.
References bufpos and getBufline.
GetSuffix()
| inline virtual |
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 :
Definition at line 142 of file CharStream.h.
getTabSize()
| inline |
Definition at line 34 of file CharStream.h.
Reference tabSize.
getTrackLineColumn()
| inline virtual |
Definition at line 60 of file CharStream.h.
Reference trackLineColumn.
readChar()
| inline virtual |
Returns the next character from the selected input.
The method of selecting the input is the responsibility of the class implementing this class.
Definition at line 95 of file CharStream.h.
References buffer, bufpos, bufsize, FillBuff, inBuf, maxNextCharInd, trackLineColumn and UpdateLineColumn.
Referenced by BeginToken.
ReInit()
| virtual |
Definition at line 225 of file CharStream.h.
Referenced by CharStream, CharStream, CharStream, CharStream, CharStream, CharStream, CharStream, ReInit, ReInit and ReInit.
ReInit()
| inline virtual |
Definition at line 227 of file CharStream.h.
References INITIAL_BUFFER_SIZE and ReInit.
ReInit()
| inline virtual |
Definition at line 231 of file CharStream.h.
References INITIAL_BUFFER_SIZE and ReInit.
ReInit()
| virtual |
Definition at line 235 of file CharStream.h.
ReInit()
| inline virtual |
Definition at line 238 of file CharStream.h.
References INITIAL_BUFFER_SIZE and ReInit.
setTabSize()
| inline |
Definition at line 33 of file CharStream.h.
Reference tabSize.
setTrackLineColumn()
| inline virtual |
Definition at line 61 of file CharStream.h.
Reference trackLineColumn.
Protected Member Functions
UpdateLineColumn()
| protected virtual |
Definition at line 246 of file CharStream.h.
Referenced by readChar.
Private Member Functions
getBufcolumn()
| inline |
Definition at line 37 of file CharStream.h.
References bufcolumn and trackLineColumn.
Referenced by getBeginColumn, getColumn and getEndColumn.
getBufline()
| inline |
Definition at line 44 of file CharStream.h.
References bufline and trackLineColumn.
Referenced by getBeginLine, getEndLine and getLine.
Protected Member Attributes
available
| protected |
Definition at line 258 of file CharStream.h.
Referenced by CharStream, CharStream, CharStream, CharStream, CharStream, CharStream and CharStream.
bufcolumn
| protected |
Definition at line 249 of file CharStream.h.
Referenced by CharStream, CharStream, CharStream, CharStream, CharStream, CharStream, CharStream and getBufcolumn.
buffer
| protected |
Definition at line 250 of file CharStream.h.
Referenced by CharStream, CharStream, CharStream, CharStream, CharStream, CharStream, CharStream, GetImage, GetSuffix and readChar.
bufline
| protected |
Definition at line 248 of file CharStream.h.
Referenced by CharStream, CharStream, CharStream, CharStream, CharStream, CharStream, CharStream and getBufline.
bufpos
| protected |
Definition at line 251 of file CharStream.h.
Referenced by backup, BeginToken, CharStream, CharStream, CharStream, CharStream, CharStream, CharStream, CharStream, endOfInput, getColumn, getEndColumn, getEndLine, GetImage, getLine, GetSuffix and readChar.
bufsize
| protected |
Definition at line 252 of file CharStream.h.
Referenced by backup, CharStream, CharStream, CharStream, CharStream, CharStream, CharStream, CharStream, GetImage, GetSuffix and readChar.
column
| protected |
Definition at line 254 of file CharStream.h.
Referenced by CharStream, CharStream, CharStream, CharStream, CharStream, CharStream and CharStream.
deleteStream
| protected |
Definition at line 264 of file CharStream.h.
Referenced by CharStream, CharStream, CharStream, CharStream, CharStream, CharStream, CharStream and ~CharStream.
inBuf
| protected |
Definition at line 260 of file CharStream.h.
Referenced by backup, CharStream, CharStream, CharStream, CharStream, CharStream, CharStream, CharStream, endOfInput and readChar.
inputStream
| protected |
Definition at line 263 of file CharStream.h.
Referenced by CharStream, CharStream, CharStream, CharStream, CharStream, CharStream, CharStream, endOfInput and ~CharStream.
line
| protected |
Definition at line 255 of file CharStream.h.
Referenced by CharStream, CharStream, CharStream, CharStream, CharStream, CharStream and CharStream.
maxNextCharInd
| protected |
Definition at line 259 of file CharStream.h.
Referenced by CharStream, CharStream, CharStream, CharStream, CharStream, CharStream, CharStream, endOfInput and readChar.
prevCharIsCR
| protected |
Definition at line 256 of file CharStream.h.
Referenced by CharStream, CharStream, CharStream, CharStream, CharStream, CharStream and CharStream.
prevCharIsLF
| protected |
Definition at line 257 of file CharStream.h.
Referenced by CharStream, CharStream, CharStream, CharStream, CharStream, CharStream and CharStream.
tabSize
| protected |
Definition at line 261 of file CharStream.h.
Referenced by CharStream, CharStream, CharStream, CharStream, CharStream, CharStream, CharStream, getTabSize and setTabSize.
tokenBegin
| protected |
Definition at line 253 of file CharStream.h.
Referenced by BeginToken, CharStream, CharStream, CharStream, CharStream, CharStream, CharStream, CharStream, getBeginColumn, getBeginLine and GetImage.
trackLineColumn
| protected |
Definition at line 262 of file CharStream.h.
Referenced by CharStream, CharStream, CharStream, CharStream, CharStream, CharStream, CharStream, getBufcolumn, getBufline, getTrackLineColumn, readChar and setTrackLineColumn.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus by Doxygen 1.14.0.