PUMA Library Reference Manual
Loading...
Searching...
No Matches
Puma::TokenStream Class Reference

#include <Puma/TokenStream.h>

+ Inheritance diagram for Puma::TokenStream:

Description

Continuous token stream from a stack of token units, such as include files and files included by these files (nested includes).

Public Member Functions

 TokenStream ()
 Constructor.
 
 ~TokenStream ()
 Destructor.
 
void push (Unit *unit, Token *curr=0)
 Push a token unit on the token unit stack.
 
Unittop () const
 Get the top token unit on token unit stack.
 
Tokennext ()
 Get the next token from the top token unit.
 
Tokencurrent () const
 Get the current token of the top token unit.
 
bool topHasMore () const
 Check if there are tokens after the current token in the top unit.
 
- Public Member Functions inherited from Puma::TokenSource
virtual ~TokenSource ()
 Destructor.
 
- Public Member Functions inherited from Puma::Array< UnitTokenSrc * >
 Array (long is=default_init_size, long incr=default_increment)
 Constructor.
 
 Array (const Array< UnitTokenSrc * > &array)
 Copy-constructor.
 
Array< UnitTokenSrc * > & operator= (const Array< UnitTokenSrc * > &copy)
 Assignment operator.
 
 ~Array ()
 Destructor.
 
void append (const UnitTokenSrc * &item)
 Append an item to the array.
 
void insert (long index, const UnitTokenSrc * &item)
 Insert an item at the given array index.
 
void prepend (const UnitTokenSrc * &item)
 Prepend an item.
 
void remove (long index)
 Remove the array item at the given array index.
 
void reset ()
 Reset the array.
 
void reset ()
 
UnitTokenSrc * & get (long index)
 Get a reference to the array item at the given array index.
 
UnitTokenSrc * & operator[] (long index)
 Get a reference to the array item at the given array index.
 
UnitTokenSrcfetch (long index) const
 Get the array item at the given array index.
 
UnitTokenSrc * & lookup (long index) const
 Get a reference to the array item at the given array index.
 
long length () const
 Get the number of items in the array.
 

Additional Inherited Members

- Static Protected Attributes inherited from Puma::Array< UnitTokenSrc * >
static const long default_init_size
 Default array size.
 
static const long default_increment
 Default array size increment.
 

Constructor & Destructor Documentation

◆ TokenStream()

Puma::TokenStream::TokenStream ( )
inline

Constructor.

◆ ~TokenStream()

Puma::TokenStream::~TokenStream ( )
inline

Destructor.

Member Function Documentation

◆ current()

Token * Puma::TokenStream::current ( ) const

Get the current token of the top token unit.

Returns
A pointer to the token, or NULL if stack is empty.

◆ next()

Token * Puma::TokenStream::next ( )
virtual

Get the next token from the top token unit.

If the end of the top token unit is reached, that token unit is removed from the stack and the next token in the new top token unit is returned.

Returns
A pointer to the token, or NULL if stack is empty.

Implements Puma::TokenSource.

◆ push()

void Puma::TokenStream::push ( Unit * unit,
Token * curr = 0 )

Push a token unit on the token unit stack.

Parameters
unitThe token unit.
currOptional current token in the token unit, defaults to the first token in the unit.

◆ top()

Unit * Puma::TokenStream::top ( ) const

Get the top token unit on token unit stack.

Returns
The unit on top of the stack, or NULL if stack is empty.

◆ topHasMore()

bool Puma::TokenStream::topHasMore ( ) const

Check if there are tokens after the current token in the top unit.

Returns
True, if the end of the top unit isn't reached yet.