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

Additional Inherited Members

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

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.