OpenMD  2.5
Molecular Dynamics in the Open
antlr::InputBuffer Class Referenceabstract

#include <InputBuffer.hpp>

Inheritance diagram for antlr::InputBuffer:
antlr::CharBuffer antlr::CharInputBuffer

Public Member Functions

 InputBuffer ()
 
virtual ~InputBuffer ()
 
virtual void reset (void)
 Reset the input buffer to empty state. More...
 
void commit (void)
 
virtual void consume ()
 
virtual void fill (unsigned int amount)
 
virtual int getChar ()=0
 
virtual int LA (unsigned int i)
 
virtual unsigned int mark ()
 
virtual bool isMarked () const
 Are there any marks active in the InputBuffer. More...
 
virtual void rewind (unsigned int mark)
 
virtual unsigned int entries () const
 
std ::string getLAChars () const
 
std ::string getMarkedChars () const
 

Protected Member Functions

void syncConsume ()
 

Protected Attributes

unsigned int nMarkers
 
unsigned int markerOffset
 
unsigned int numToConsume
 
CircularQueue< int > queue
 

Private Member Functions

 InputBuffer (const InputBuffer &other)
 
InputBufferoperator= (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

◆ InputBuffer() [1/2]

antlr::InputBuffer::InputBuffer ( )
inline

Create a character buffer

Definition at line 34 of file InputBuffer.hpp.

◆ ~InputBuffer()

virtual antlr::InputBuffer::~InputBuffer ( )
inlinevirtual

Definition at line 41 of file InputBuffer.hpp.

◆ InputBuffer() [2/2]

antlr::InputBuffer::InputBuffer ( const InputBuffer other)
private

Member Function Documentation

◆ commit()

void antlr::InputBuffer::commit ( void  )
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.

◆ consume()

virtual void antlr::InputBuffer::consume ( )
inlinevirtual

Mark another character for deferred consumption

Definition at line 66 of file InputBuffer.hpp.

◆ entries()

unsigned int antlr::InputBuffer::entries ( ) const
virtual

Get the number of non-consumed characters

Definition at line 79 of file InputBuffer.cpp.

References antlr::CircularQueue< T >::entries(), markerOffset, and queue.

◆ fill()

void antlr::InputBuffer::fill ( unsigned int  amount)
virtual

Ensure that the character buffer is sufficiently full

Definition at line 21 of file InputBuffer.cpp.

References antlr::CircularQueue< T >::append(), antlr::CircularQueue< T >::entries(), getChar(), markerOffset, queue, and syncConsume().

◆ getChar()

virtual int antlr::InputBuffer::getChar ( )
pure virtual

Override this in subclasses to get the next character

Implemented in antlr::CharInputBuffer, and antlr::CharBuffer.

Referenced by fill().

◆ getLAChars()

std::string antlr::InputBuffer::getLAChars ( void  ) const

get the current lookahead characters as a string

Warning
it may treat 0 and EOF values wrong

Definition at line 36 of file InputBuffer.cpp.

References ANTLR_USE_NAMESPACE, antlr::CircularQueue< T >::elementAt(), antlr::CircularQueue< T >::entries(), markerOffset, and queue.

◆ getMarkedChars()

std::string antlr::InputBuffer::getMarkedChars ( void  ) const

get the current marked characters as a string

Warning
it may treat 0 and EOF values wrong

Definition at line 49 of file InputBuffer.cpp.

References ANTLR_USE_NAMESPACE, antlr::CircularQueue< T >::elementAt(), markerOffset, and queue.

◆ isMarked()

virtual bool antlr::InputBuffer::isMarked ( ) const
inlinevirtual

Are there any marks active in the InputBuffer.

Definition at line 89 of file InputBuffer.hpp.

References ANTLR_USE_NAMESPACE.

◆ LA()

virtual int antlr::InputBuffer::LA ( unsigned int  i)
inlinevirtual

Get a lookahead character

Definition at line 78 of file InputBuffer.hpp.

◆ mark()

unsigned int antlr::InputBuffer::mark ( )
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 markerOffset, nMarkers, and syncConsume().

Referenced by rewind().

◆ operator=()

InputBuffer& antlr::InputBuffer::operator= ( const InputBuffer other)
private

◆ reset()

virtual void antlr::InputBuffer::reset ( void  )
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().

◆ rewind()

void antlr::InputBuffer::rewind ( unsigned int  mark)
virtual

Rewind the character buffer to a marker.

Parameters
markMarker returned previously from mark()

Definition at line 72 of file InputBuffer.cpp.

References mark(), markerOffset, nMarkers, and syncConsume().

◆ syncConsume()

void antlr::InputBuffer::syncConsume ( )
inlineprotected

Sync up deferred consumption

Definition at line 131 of file InputBuffer.hpp.

Referenced by fill(), mark(), and rewind().

Member Data Documentation

◆ markerOffset

unsigned int antlr::InputBuffer::markerOffset
protected

Definition at line 114 of file InputBuffer.hpp.

Referenced by entries(), fill(), getLAChars(), getMarkedChars(), mark(), and rewind().

◆ nMarkers

unsigned int antlr::InputBuffer::nMarkers
protected

Definition at line 111 of file InputBuffer.hpp.

Referenced by mark(), and rewind().

◆ numToConsume

unsigned int antlr::InputBuffer::numToConsume
protected

Definition at line 117 of file InputBuffer.hpp.

◆ queue

CircularQueue<int> antlr::InputBuffer::queue
protected

Definition at line 120 of file InputBuffer.hpp.

Referenced by entries(), fill(), getLAChars(), and getMarkedChars().


The documentation for this class was generated from the following files: