OpenMD 3.1
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
antlr::TokenStreamSelector Class Reference

A token stream MUX (multiplexor) knows about n token streams and can multiplex them onto the same channel for use by token stream consumer like a parser. More...

#include <TokenStreamSelector.hpp>

+ Inheritance diagram for antlr::TokenStreamSelector:

Public Member Functions

 TokenStreamSelector ()
 A token stream MUX (multiplexor) knows about n token streams and can multiplex them onto the same channel for use by token stream consumer like a parser.
 
void addInputStream (TokenStream *stream, const std ::string &key)
 
TokenStreamgetCurrentStream () const
 Return the stream from which tokens are being pulled at the moment.
 
TokenStreamgetStream (const std ::string &sname) const
 
RefToken nextToken ()
 
TokenStreampop ()
 
void push (TokenStream *stream)
 
void push (const std ::string &sname)
 
void retry ()
 Abort recognition of current Token and try again.
 
void select (TokenStream *stream)
 Set the stream without pushing old stream.
 
void select (const std ::string &sname)
 

Protected Types

typedef std ::map< std ::string, TokenStream * > inputStreamNames_coll
 The set of inputs to the MUX.
 
typedef std ::stack< TokenStream * > streamStack_coll
 Used to track stack of input streams.
 

Protected Attributes

inputStreamNames_coll inputStreamNames
 
TokenStreaminput
 The currently-selected token stream input.
 
streamStack_coll streamStack
 

Detailed Description

A token stream MUX (multiplexor) knows about n token streams and can multiplex them onto the same channel for use by token stream consumer like a parser.

This is a way to have multiple lexers break up the same input stream for a single parser. Or, you can have multiple instances of the same lexer handle multiple input streams; this works great for includes.

Definition at line 27 of file TokenStreamSelector.hpp.

Member Typedef Documentation

◆ inputStreamNames_coll

typedef std :: map< std :: string,TokenStream*> antlr::TokenStreamSelector::inputStreamNames_coll
protected

The set of inputs to the MUX.

Definition at line 34 of file TokenStreamSelector.hpp.

◆ streamStack_coll

Used to track stack of input streams.

Definition at line 45 of file TokenStreamSelector.hpp.

Constructor & Destructor Documentation

◆ TokenStreamSelector()

antlr::TokenStreamSelector::TokenStreamSelector ( )

A token stream MUX (multiplexor) knows about n token streams and can multiplex them onto the same channel for use by token stream consumer like a parser.

This is a way to have multiple lexers break up the same input stream for a single parser. Or, you can have multiple instances of the same lexer handle multiple input streams; this works great for includes.

Definition at line 22 of file TokenStreamSelector.cpp.

◆ ~TokenStreamSelector()

antlr::TokenStreamSelector::~TokenStreamSelector ( )

Definition at line 27 of file TokenStreamSelector.cpp.

Member Function Documentation

◆ addInputStream()

void antlr::TokenStreamSelector::addInputStream ( TokenStream * stream,
const std ::string & key )

Definition at line 31 of file TokenStreamSelector.cpp.

◆ getCurrentStream()

TokenStream * antlr::TokenStreamSelector::getCurrentStream ( ) const

Return the stream from which tokens are being pulled at the moment.

Definition at line 36 of file TokenStreamSelector.cpp.

References input.

◆ getStream()

TokenStream * antlr::TokenStreamSelector::getStream ( const std ::string & sname) const

Definition at line 41 of file TokenStreamSelector.cpp.

◆ nextToken()

RefToken antlr::TokenStreamSelector::nextToken ( void )
virtual

Implements antlr::TokenStream.

Definition at line 50 of file TokenStreamSelector.cpp.

◆ pop()

TokenStream * antlr::TokenStreamSelector::pop ( )

Definition at line 64 of file TokenStreamSelector.cpp.

◆ push() [1/2]

void antlr::TokenStreamSelector::push ( const std ::string & sname)

Definition at line 78 of file TokenStreamSelector.cpp.

◆ push() [2/2]

void antlr::TokenStreamSelector::push ( TokenStream * stream)

Definition at line 72 of file TokenStreamSelector.cpp.

◆ retry()

void antlr::TokenStreamSelector::retry ( )

Abort recognition of current Token and try again.

A stream can push a new stream (for include files for example, and then retry(), which will cause the current stream to abort back to this.nextToken(). this.nextToken() then asks for a token from the current stream, which is the new "substream."

Definition at line 84 of file TokenStreamSelector.cpp.

◆ select() [1/2]

void antlr::TokenStreamSelector::select ( const std ::string & sname)

Definition at line 95 of file TokenStreamSelector.cpp.

◆ select() [2/2]

void antlr::TokenStreamSelector::select ( TokenStream * stream)

Set the stream without pushing old stream.

Definition at line 90 of file TokenStreamSelector.cpp.

References input.

Member Data Documentation

◆ input

TokenStream* antlr::TokenStreamSelector::input
protected

The currently-selected token stream input.

Definition at line 39 of file TokenStreamSelector.hpp.

Referenced by getCurrentStream(), and select().

◆ inputStreamNames

inputStreamNames_coll antlr::TokenStreamSelector::inputStreamNames
protected

Definition at line 36 of file TokenStreamSelector.hpp.

◆ streamStack

streamStack_coll antlr::TokenStreamSelector::streamStack
protected

Definition at line 47 of file TokenStreamSelector.hpp.


The documentation for this class was generated from the following files: