InputBuffer Class Reference
A Stream of characters fed to the lexer from a InputStream that can be rewound via mark()/rewind() methods. More...
#include <InputBuffer.hpp>
Inheritance diagram for InputBuffer:


Public Member Functions | |
InputBuffer () | |
Create a character buffer. | |
virtual | ~InputBuffer () |
virtual void | reset (void) |
Reset the input buffer to empty state. | |
void | commit (void) |
This method updates the state of the input buffer so that the text matched since the most recent mark() is no longer held by the buffer. | |
virtual void | consume () |
Mark another character for deferred consumption. | |
virtual void | fill (int amount) |
Ensure that the character buffer is sufficiently full. | |
virtual int | getChar ()=0 |
Override this in subclasses to get the next character. | |
virtual int | LA (int i) |
Get a lookahead character. | |
virtual int | mark () |
Return an integer marker that can be used to rewind the buffer to its current state. | |
virtual bool | isMarked () const |
Are there any marks active in the InputBuffer. | |
virtual void | rewind (int mark) |
Rewind the character buffer to a marker. | |
std::string | getLAChars () const |
get the current lookahead characters as a string | |
std::string | getMarkedChars () const |
get the current marked characters as a string | |
Protected Member Functions | |
void | syncConsume () |
Sync up deferred consumption. | |
Protected Attributes | |
int | nMarkers |
int | markerOffset |
int | numToConsume |
CircularQueue< int > | queue |
Private Member Functions | |
InputBuffer (const InputBuffer &other) | |
InputBuffer & | operator= (const InputBuffer &other) |
Detailed Description
A Stream of characters fed to the lexer from a InputStream that can be rewound via mark()/rewind() methods.A dynamic array is used to buffer up all the input characters. Normally, "k" characters are stored in the buffer. More characters may be stored during guess mode (testing syntactic predicate), or when LT(i>k) is referenced. Consumption of characters is deferred. In other words, reading the next character is not done by conume(), but deferred until needed by LA or LT.
- See also:
- antlr.CharQueue
Definition at line 31 of file InputBuffer.hpp.
Constructor & Destructor Documentation
|
Create a character buffer.
Definition at line 34 of file InputBuffer.hpp. References markerOffset, nMarkers, and numToConsume. |
|
Definition at line 39 of file InputBuffer.hpp. |
|
|
Member Function Documentation
|
This method updates the state of the input buffer so that the text matched since the most recent mark() is no longer held by the buffer. So, you either do a mark/rewind for failed predicate or mark/commit to keep on parsing without rewinding the input. Definition at line 58 of file InputBuffer.hpp. References nMarkers. |
|
Mark another character for deferred consumption.
Definition at line 64 of file InputBuffer.hpp. References numToConsume. |
|
Ensure that the character buffer is sufficiently full.
Definition at line 16 of file InputBuffer.cpp. References CircularQueue< T >::append(), CircularQueue< T >::entries(), getChar(), queue, and syncConsume(). Referenced by LA(). |
|
Override this in subclasses to get the next character.
Implemented in CharBuffer, and CharInputBuffer. Referenced by fill(). |
|
get the current lookahead characters as a string
Definition at line 30 of file InputBuffer.cpp. References ANTLR_USE_NAMESPACE, and CircularQueue< T >::elementAt(). |
|
get the current marked characters as a string
Definition at line 43 of file InputBuffer.cpp. References ANTLR_USE_NAMESPACE, and CircularQueue< T >::elementAt(). |
|
Are there any marks active in the InputBuffer.
Definition at line 87 of file InputBuffer.hpp. References nMarkers. |
|
Get a lookahead character.
Definition at line 76 of file InputBuffer.hpp. References CircularQueue< T >::elementAt(), fill(), markerOffset, and queue. |
|
Return an integer marker that can be used to rewind the buffer to its current state.
Definition at line 56 of file InputBuffer.cpp. References nMarkers, and syncConsume(). |
|
|
|
Reset the input buffer to empty state.
Reimplemented in CharInputBuffer. Definition at line 44 of file InputBuffer.hpp. References CircularQueue< T >::clear(), markerOffset, nMarkers, numToConsume, and queue. Referenced by LexerInputState::reset(), and CharInputBuffer::reset(). |
|
Rewind the character buffer to a marker.
Definition at line 66 of file InputBuffer.cpp. References markerOffset, nMarkers, and syncConsume(). |
|
Sync up deferred consumption.
Definition at line 125 of file InputBuffer.hpp. |
Member Data Documentation
|
Definition at line 108 of file InputBuffer.hpp. Referenced by InputBuffer(), LA(), reset(), and rewind(). |
|
Definition at line 105 of file InputBuffer.hpp. Referenced by commit(), InputBuffer(), isMarked(), mark(), reset(), and rewind(). |
|
Definition at line 111 of file InputBuffer.hpp. Referenced by consume(), InputBuffer(), and reset(). |
|
Definition at line 114 of file InputBuffer.hpp. |
The documentation for this class was generated from the following files:
- lib/antlr/antlr/InputBuffer.hpp
- lib/antlr/src/InputBuffer.cpp