PUMA Library Reference Manual
Loading...
Searching...
No Matches
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.

Public Member Functions

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

Protected Types

typedef BCList< TokenInfo, 8192 > TokenStore

Protected Member Functions

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

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