ANTLR Support Libraries 2.7.1+
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
InputBuffer Class Referenceabstract

#include <InputBuffer.hpp>

Inheritance diagram for InputBuffer:
Inheritance graph
[legend]
Collaboration diagram for InputBuffer:
Collaboration graph
[legend]

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

Constructor & Destructor Documentation

◆ InputBuffer() [1/2]

InputBuffer::InputBuffer ( )
inline

Create a character buffer

◆ ~InputBuffer()

virtual InputBuffer::~InputBuffer ( )
inlinevirtual

◆ InputBuffer() [2/2]

InputBuffer::InputBuffer ( const InputBuffer other)
private

Member Function Documentation

◆ commit()

void 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.

◆ consume()

virtual void InputBuffer::consume ( )
inlinevirtual

Mark another character for deferred consumption

◆ entries()

unsigned int InputBuffer::entries ( ) const
virtual

Get the number of non-consumed characters

◆ fill()

void InputBuffer::fill ( unsigned int  amount)
virtual

Ensure that the character buffer is sufficiently full

◆ getChar()

virtual int InputBuffer::getChar ( )
pure virtual

Override this in subclasses to get the next character

Implemented in CharInputBuffer, and CharBuffer.

◆ getLAChars()

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

get the current lookahead characters as a string

Warning
it may treat 0 and EOF values wrong

◆ getMarkedChars()

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

get the current marked characters as a string

Warning
it may treat 0 and EOF values wrong

◆ isMarked()

virtual bool InputBuffer::isMarked ( ) const
inlinevirtual

Are there any marks active in the InputBuffer.

◆ LA()

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

Get a lookahead character

◆ mark()

unsigned int InputBuffer::mark ( )
virtual

Return an integer marker that can be used to rewind the buffer to its current state.

◆ operator=()

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

◆ reset()

virtual void InputBuffer::reset ( void  )
inlinevirtual

Reset the input buffer to empty state.

Reimplemented in CharInputBuffer.

◆ rewind()

void InputBuffer::rewind ( unsigned int  mark)
virtual

Rewind the character buffer to a marker.

Parameters
markMarker returned previously from mark()

◆ syncConsume()

void InputBuffer::syncConsume ( )
inlineprotected

Sync up deferred consumption

Member Data Documentation

◆ markerOffset

unsigned int InputBuffer::markerOffset
protected

◆ nMarkers

unsigned int InputBuffer::nMarkers
protected

◆ numToConsume

unsigned int InputBuffer::numToConsume
protected

◆ queue

CircularQueue<int> InputBuffer::queue
protected

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