KDevelop API Documentation

InputBuffer Class Reference

A Stream of characters fed to the lexer from a InputStream that can be rewound via mark()/rewind() methods. More...

#include <InputBuffer.hpp>

Inheritance diagram for InputBuffer:

Inheritance graph
[legend]
Collaboration diagram for InputBuffer:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 InputBuffer ()
 Create a character buffer.
virtual ~InputBuffer ()
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 (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 (int i)
 Get a lookahead character.
virtual 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 (int mark)
 Rewind the character buffer to a marker.
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

int nMarkers
int markerOffset
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::InputBuffer  )  [inline]
 

Create a character buffer.

Definition at line 34 of file InputBuffer.hpp.

References markerOffset, nMarkers, and numToConsume.

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

Definition at line 39 of file InputBuffer.hpp.

InputBuffer::InputBuffer const InputBuffer other  )  [private]
 


Member Function Documentation

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 58 of file InputBuffer.hpp.

References nMarkers.

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

Mark another character for deferred consumption.

Definition at line 64 of file InputBuffer.hpp.

References numToConsume.

void InputBuffer::fill int  amount  )  [virtual]
 

Ensure that the character buffer is sufficiently full.

Definition at line 16 of file InputBuffer.cpp.

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

Referenced by LA().

virtual int InputBuffer::getChar  )  [pure virtual]
 

Override this in subclasses to get the next character.

Implemented in CharBuffer, and CharInputBuffer.

Referenced by fill().

std::string InputBuffer::getLAChars void   )  const
 

get the current lookahead characters as a string

Warning:
it may treat 0 and EOF values wrong

Definition at line 30 of file InputBuffer.cpp.

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

std::string InputBuffer::getMarkedChars void   )  const
 

get the current marked characters as a string

Warning:
it may treat 0 and EOF values wrong

Definition at line 43 of file InputBuffer.cpp.

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

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

Are there any marks active in the InputBuffer.

Definition at line 87 of file InputBuffer.hpp.

References nMarkers.

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

Get a lookahead character.

Definition at line 76 of file InputBuffer.hpp.

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

int InputBuffer::mark  )  [virtual]
 

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

Definition at line 56 of file InputBuffer.cpp.

References nMarkers, and syncConsume().

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

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

Reset the input buffer to empty state.

Reimplemented in CharInputBuffer.

Definition at line 44 of file InputBuffer.hpp.

References CircularQueue< T >::clear(), markerOffset, nMarkers, numToConsume, and queue.

Referenced by LexerInputState::reset(), and CharInputBuffer::reset().

void InputBuffer::rewind int  mark  )  [virtual]
 

Rewind the character buffer to a marker.

Parameters:
mark Marker returned previously from mark()

Definition at line 66 of file InputBuffer.cpp.

References markerOffset, nMarkers, and syncConsume().

void InputBuffer::syncConsume  )  [inline, protected]
 

Sync up deferred consumption.

Definition at line 125 of file InputBuffer.hpp.

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


Member Data Documentation

int InputBuffer::markerOffset [protected]
 

Definition at line 108 of file InputBuffer.hpp.

Referenced by InputBuffer(), LA(), reset(), and rewind().

int InputBuffer::nMarkers [protected]
 

Definition at line 105 of file InputBuffer.hpp.

Referenced by commit(), InputBuffer(), isMarked(), mark(), reset(), and rewind().

int InputBuffer::numToConsume [protected]
 

Definition at line 111 of file InputBuffer.hpp.

Referenced by consume(), InputBuffer(), and reset().

CircularQueue<int> InputBuffer::queue [protected]
 

Definition at line 114 of file InputBuffer.hpp.

Referenced by fill(), LA(), and reset().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Feb 22 09:43:40 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003