Puma Reference Manual Puma::TokenProvider Class Reference



Puma::TokenProvider Class Reference

Reads tokens from a token source. More...

#include <Puma/TokenProvider.h>

Inheritance diagram for Puma::TokenProvider:
Inheritance graph

Public Types

typedef TokenStore::Iterator State
 Read position. More...
 

Public Member Functions

 TokenProvider (PumaTokenSource &s)
 Constructor. More...
 
virtual ~TokenProvider ()
 Destructor. More...
 
void init ()
 Initialize the token provider by reading the first token. More...
 
PumaTokenSource & source () const
 Get the token source. More...
 
Token * next ()
 Read the next token from the token source. More...
 
Token * current () const
 Get the last token read from the token source. More...
 
State get_state ()
 Get the current read position. More...
 
void set_state (State restored_pos)
 Restore the read position. More...
 

Protected Types

typedef BCList< void *, 8192 > TokenStore
 

Protected Member Functions

virtual void * read ()
 Read next token. More...
 
virtual Token * token () const
 Get the current token. More...
 

Protected Attributes

PumaTokenSource & _source
 
TokenStore _tokens
 
TokenStore::Iterator _read_pos
 

Detailed Description

Reads tokens from a token source.

Supports unlimited look ahead. A token source can be a file, a string, a token preprocessor, and so on.

Member Typedef Documentation

typedef TokenStore::Iterator Puma::TokenProvider::State

Read position.

typedef BCList<void*, 8192> Puma::TokenProvider::TokenStore
protected

Constructor & Destructor Documentation

Puma::TokenProvider::TokenProvider ( PumaTokenSource &  s)
inline

Constructor.

Parameters
sThe token source from which to read the tokens.
virtual Puma::TokenProvider::~TokenProvider ( )
inlinevirtual

Destructor.

The compiler complains if we done define a virtual destrcutor.

Member Function Documentation

Token* Puma::TokenProvider::current ( ) const
inline

Get the last token read from the token source.

State Puma::TokenProvider::get_state ( )
inline

Get the current read position.

void Puma::TokenProvider::init ( )
inline

Initialize the token provider by reading the first token.

Token* Puma::TokenProvider::next ( )
inline

Read the next token from the token source.

virtual void* Puma::TokenProvider::read ( )
inlineprotectedvirtual

Read next token.

Reimplemented in Puma::InstantiationTokenProvider.

void Puma::TokenProvider::set_state ( State  restored_pos)
inline

Restore the read position.

Parameters
restored_posThe new read position.
PumaTokenSource& Puma::TokenProvider::source ( ) const
inline

Get the token source.

virtual Token* Puma::TokenProvider::token ( ) const
inlineprotectedvirtual

Get the current token.

Reimplemented in Puma::InstantiationTokenProvider.

Member Data Documentation

TokenStore::Iterator Puma::TokenProvider::_read_pos
protected
PumaTokenSource& Puma::TokenProvider::_source
protected
TokenStore Puma::TokenProvider::_tokens
protected



Puma Reference Manual. Created on Fri Aug 28 2015.