OpenMD 3.1
Molecular Dynamics in the Open
|
A Stream of Token objects fed to the parser from a TokenStream that can be rewound via mark()/rewind() methods. More...
#include <TokenBuffer.hpp>
Public Member Functions | |
TokenBuffer (TokenStream &input_) | |
Create a token buffer. | |
void | reset (void) |
Reset the input buffer to empty state. | |
int | LA (unsigned int i) |
Get a lookahead token value. | |
RefToken | LT (unsigned int i) |
Get a lookahead token. | |
unsigned int | mark () |
Return an integer marker that can be used to rewind the buffer to its current state. | |
void | rewind (unsigned int mark) |
Rewind the token buffer to a marker. | |
void | consume () |
Mark another token for deferred consumption. | |
virtual unsigned int | entries () const |
Return the number of entries in the TokenBuffer. | |
Protected Attributes | |
TokenStream & | input |
Token source. | |
unsigned int | nMarkers |
Number of active markers. | |
unsigned int | markerOffset |
Additional offset used when markers are active. | |
unsigned int | numToConsume |
Number of calls to consume() since last LA() or LT() call. | |
CircularQueue< RefToken > | queue |
Circular queue with Tokens. | |
A Stream of Token objects fed to the parser from a TokenStream that can be rewound via mark()/rewind() methods.
A dynamic array is used to buffer up all the input tokens. Normally, "k" tokens are stored in the buffer. More tokens may be stored during guess mode (testing syntactic predicate), or when LT(i>k) is referenced. Consumption of tokens is deferred. In other words, reading the next token is not done by conume(), but deferred until needed by LA or LT.
Definition at line 36 of file TokenBuffer.hpp.
antlr::TokenBuffer::TokenBuffer | ( | TokenStream & | inp | ) |
Create a token buffer.
A Stream of Token objects fed to the parser from a TokenStream that can be rewound via mark()/rewind() methods.
A dynamic array is used to buffer up all the input tokens. Normally, "k" tokens are stored in the buffer. More tokens may be stored during guess mode (testing syntactic predicate), or when LT(i>k) is referenced. Consumption of tokens is deferred. In other words, reading the next token is not done by conume(), but deferred until needed by LA or LT.
Definition at line 30 of file TokenBuffer.cpp.
|
virtual |
Definition at line 38 of file TokenBuffer.cpp.
|
inline |
Mark another token for deferred consumption.
Definition at line 68 of file TokenBuffer.hpp.
|
virtual |
Return the number of entries in the TokenBuffer.
Get number of non-consumed tokens.
Definition at line 89 of file TokenBuffer.cpp.
References markerOffset.
int antlr::TokenBuffer::LA | ( | unsigned int | i | ) |
Get a lookahead token value.
Definition at line 55 of file TokenBuffer.cpp.
References markerOffset.
RefToken antlr::TokenBuffer::LT | ( | unsigned int | i | ) |
unsigned int antlr::TokenBuffer::mark | ( | ) |
Return an integer marker that can be used to rewind the buffer to its current state.
Definition at line 71 of file TokenBuffer.cpp.
References markerOffset, and nMarkers.
Referenced by rewind().
|
inline |
Reset the input buffer to empty state.
Definition at line 43 of file TokenBuffer.hpp.
void antlr::TokenBuffer::rewind | ( | unsigned int | mark | ) |
Rewind the token buffer to a marker.
mark | Marker returned previously from mark() |
Definition at line 81 of file TokenBuffer.cpp.
References mark(), markerOffset, and nMarkers.
|
protected |
Token source.
Definition at line 84 of file TokenBuffer.hpp.
|
protected |
|
protected |
Number of active markers.
Definition at line 87 of file TokenBuffer.hpp.
|
protected |
Number of calls to consume() since last LA() or LT() call.
Definition at line 93 of file TokenBuffer.hpp.
|
protected |
Circular queue with Tokens.
Definition at line 96 of file TokenBuffer.hpp.