InputBuffer Class Reference

#include <InputBuffer.hpp>

Inheritance diagram for InputBuffer:

Inheritance graph
Collaboration diagram for InputBuffer:

Collaboration graph

Public Member Functions

 InputBuffer ()
virtual ~InputBuffer ()
virtual void reset (void)
 Reset the input buffer to empty state.
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.
virtual void rewind (unsigned int mark)
virtual unsigned int entries () const
 ANTLR_USE_NAMESPACE (std) string getLAChars() const
 ANTLR_USE_NAMESPACE (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:

Definition at line 31 of file InputBuffer.hpp.

Constructor & Destructor Documentation

InputBuffer::InputBuffer (  )  [inline]

Create a character buffer

Definition at line 34 of file InputBuffer.hpp.

virtual InputBuffer::~InputBuffer (  )  [inline, virtual]

Definition at line 41 of file InputBuffer.hpp.

InputBuffer::InputBuffer ( const InputBuffer other  )  [private]

Member Function Documentation

virtual void InputBuffer::reset ( void   )  [inline, virtual]

Reset the input buffer to empty state.

Reimplemented in CharInputBuffer.

Definition at line 46 of file InputBuffer.hpp.

Referenced by CharInputBuffer::reset().

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.

Definition at line 60 of file InputBuffer.hpp.

virtual void InputBuffer::consume (  )  [inline, virtual]

Mark another character for deferred consumption

Definition at line 66 of file InputBuffer.hpp.

virtual void InputBuffer::fill ( unsigned int  amount  )  [virtual]

Ensure that the character buffer is sufficiently full

virtual int InputBuffer::getChar (  )  [pure virtual]

Override this in subclasses to get the next character

Implemented in CharBuffer, and CharInputBuffer.

virtual int InputBuffer::LA ( unsigned int  i  )  [inline, virtual]

Get a lookahead character

Definition at line 78 of file InputBuffer.hpp.

virtual unsigned int InputBuffer::mark (  )  [virtual]

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

virtual bool InputBuffer::isMarked (  )  const [inline, virtual]

Are there any marks active in the InputBuffer.

Definition at line 89 of file InputBuffer.hpp.

virtual void InputBuffer::rewind ( unsigned int  mark  )  [virtual]

Rewind the character buffer to a marker.

mark Marker returned previously from mark()

virtual unsigned int InputBuffer::entries (  )  const [virtual]

Get the number of non-consumed characters

InputBuffer::ANTLR_USE_NAMESPACE ( std   )  const

InputBuffer::ANTLR_USE_NAMESPACE ( std   )  const

void InputBuffer::syncConsume (  )  [inline, protected]

Sync up deferred consumption

Definition at line 131 of file InputBuffer.hpp.

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

Field Documentation

unsigned int InputBuffer::nMarkers [protected]

Definition at line 111 of file InputBuffer.hpp.

unsigned int InputBuffer::markerOffset [protected]

Definition at line 114 of file InputBuffer.hpp.

unsigned int InputBuffer::numToConsume [protected]

Definition at line 117 of file InputBuffer.hpp.

Definition at line 120 of file InputBuffer.hpp.

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

Generated on Tue Mar 31 20:19:28 2009 for ctrump by  doxygen 1.5.6