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:

CharBuffer CharInputBuffer 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.

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.

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

Mark another character for deferred consumption.

Definition at line 64 of file InputBuffer.hpp.

void InputBuffer::fill int  amount  )  [virtual]
 

Ensure that the character buffer is sufficiently full.

Definition at line 16 of file InputBuffer.cpp.

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

Referenced by fill().

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.

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.

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

Are there any marks active in the InputBuffer.

Definition at line 87 of file InputBuffer.hpp.

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

Get a lookahead character.

Definition at line 76 of file InputBuffer.hpp.

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 markerOffset, 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.

Referenced by 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, rewind(), and syncConsume().

Referenced by rewind().

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 fill(), mark(), and rewind().

int InputBuffer::nMarkers [protected]
 

Definition at line 105 of file InputBuffer.hpp.

Referenced by mark(), and rewind().

int InputBuffer::numToConsume [protected]
 

Definition at line 111 of file InputBuffer.hpp.

CircularQueue<int> InputBuffer::queue [protected]
 

Definition at line 114 of file InputBuffer.hpp.

Referenced by fill().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for KDevelop Version 3.0.4.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Oct 6 17:39:25 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003