OpenMD 3.1
Molecular Dynamics in the Open
|
A Stream of characters fed to the lexer from a InputStream that can be rewound via mark()/rewind() methods. More...
#include <InputBuffer.hpp>
Public Member Functions | |
InputBuffer () | |
Create a character buffer. | |
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 (unsigned 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 (unsigned int i) |
Get a lookahead character. | |
virtual unsigned 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 (unsigned int mark) |
Rewind the character buffer to a marker. | |
virtual unsigned int | entries () const |
Get the number of non-consumed characters. | |
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 | |
unsigned int | nMarkers |
unsigned int | markerOffset |
unsigned int | numToConsume |
CircularQueue< int > | queue |
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.
Definition at line 31 of file InputBuffer.hpp.
|
inline |
Create a character buffer.
Definition at line 34 of file InputBuffer.hpp.
|
inlinevirtual |
Definition at line 41 of file InputBuffer.hpp.
|
inline |
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 60 of file InputBuffer.hpp.
|
inlinevirtual |
Mark another character for deferred consumption.
Definition at line 66 of file InputBuffer.hpp.
|
virtual |
Get the number of non-consumed characters.
Definition at line 79 of file InputBuffer.cpp.
|
virtual |
Ensure that the character buffer is sufficiently full.
Definition at line 21 of file InputBuffer.cpp.
References getChar(), and syncConsume().
|
pure virtual |
Override this in subclasses to get the next character.
Implemented in antlr::CharBuffer, and antlr::CharInputBuffer.
Referenced by fill().
std::string antlr::InputBuffer::getLAChars | ( | void | ) | const |
get the current lookahead characters as a string
Definition at line 36 of file InputBuffer.cpp.
std::string antlr::InputBuffer::getMarkedChars | ( | void | ) | const |
get the current marked characters as a string
Definition at line 49 of file InputBuffer.cpp.
|
inlinevirtual |
Are there any marks active in the InputBuffer.
Definition at line 89 of file InputBuffer.hpp.
|
inlinevirtual |
Get a lookahead character.
Definition at line 78 of file InputBuffer.hpp.
|
virtual |
Return an integer marker that can be used to rewind the buffer to its current state.
Definition at line 62 of file InputBuffer.cpp.
References syncConsume().
Referenced by rewind().
|
inlinevirtual |
Reset the input buffer to empty state.
Reimplemented in antlr::CharInputBuffer.
Definition at line 46 of file InputBuffer.hpp.
Referenced by antlr::CharInputBuffer::reset().
|
virtual |
Rewind the character buffer to a marker.
mark | Marker returned previously from mark() |
Definition at line 72 of file InputBuffer.cpp.
References mark(), and syncConsume().
|
inlineprotected |
Sync up deferred consumption.
Definition at line 131 of file InputBuffer.hpp.
|
protected |
Definition at line 114 of file InputBuffer.hpp.
|
protected |
Definition at line 111 of file InputBuffer.hpp.
|
protected |
Definition at line 117 of file InputBuffer.hpp.
|
protected |
Definition at line 120 of file InputBuffer.hpp.