PUMA Library Reference Manual
Puma::TokenProvider Class Reference

#include <Puma/TokenProvider.h>

+ Inheritance diagram for Puma::TokenProvider:

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.

Public Types

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

Public Member Functions

 TokenProvider (TokenSource &s)
 Constructor. More...
 
virtual ~TokenProvider ()
 Destructor. More...
 
void init ()
 Initialize the token provider by reading the first token. More...
 
TokenSourcesource () const
 Get the token source. More...
 
Tokennext ()
 Read the next token from the token source. More...
 
Tokencurrent () const
 Get the last token read from the token source. More...
 
void * current_context () const
 Get the context information for the current token. 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< TokenInfo, 8192 > TokenStore
 

Protected Member Functions

virtual TokenInfo read ()
 Read next token. More...
 
Tokentoken () const
 Get the current token. More...
 

Protected Attributes

TokenSource_source
 
TokenStore _tokens
 
TokenStore::Iterator _read_pos
 

Member Typedef Documentation

◆ State

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

Read position.

◆ TokenStore

Constructor & Destructor Documentation

◆ TokenProvider()

Puma::TokenProvider::TokenProvider ( TokenSource s)
inline

Constructor.

Parameters
sThe token source from which to read the tokens.

◆ ~TokenProvider()

virtual Puma::TokenProvider::~TokenProvider ( )
inlinevirtual

Destructor.

The compiler complains if we done define a virtual destrcutor.

Member Function Documentation

◆ current()

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

Get the last token read from the token source.

◆ current_context()

void* Puma::TokenProvider::current_context ( ) const
inline

Get the context information for the current token.

◆ get_state()

State Puma::TokenProvider::get_state ( )
inline

Get the current read position.

◆ init()

void Puma::TokenProvider::init ( )
inline

Initialize the token provider by reading the first token.

◆ next()

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

Read the next token from the token source.

◆ read()

virtual TokenInfo Puma::TokenProvider::read ( )
inlineprotectedvirtual

Read next token.

Reimplemented in Puma::InstantiationTokenProvider.

◆ set_state()

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

Restore the read position.

Parameters
restored_posThe new read position.

◆ source()

TokenSource& Puma::TokenProvider::source ( ) const
inline

Get the token source.

◆ token()

Token* Puma::TokenProvider::token ( ) const
inlineprotected

Get the current token.

Member Data Documentation

◆ _read_pos

TokenStore::Iterator Puma::TokenProvider::_read_pos
protected

◆ _source

TokenSource& Puma::TokenProvider::_source
protected

◆ _tokens

TokenStore Puma::TokenProvider::_tokens
protected