7#include "antlr/TokenStreamSelector.hpp"
8#include "antlr/TokenStreamRetryException.hpp"
10#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
27TokenStreamSelector::~TokenStreamSelector()
31void TokenStreamSelector::addInputStream(TokenStream* stream,
const ANTLR_USE_NAMESPACE(std)
string& key)
33 inputStreamNames[key] = stream;
41TokenStream* TokenStreamSelector::getStream(
const ANTLR_USE_NAMESPACE(std)
string& sname)
const
43 inputStreamNames_coll::const_iterator i = inputStreamNames.find(sname);
44 if (i == inputStreamNames.end()) {
45 throw ANTLR_USE_NAMESPACE(std)string(
"TokenStream ")+sname+
" not found";
50RefToken TokenStreamSelector::nextToken()
56 return input->nextToken();
58 catch (TokenStreamRetryException&) {
64TokenStream* TokenStreamSelector::pop()
66 TokenStream* stream = streamStack.top();
72void TokenStreamSelector::push(TokenStream* stream)
74 streamStack.push(
input);
78void TokenStreamSelector::push(
const ANTLR_USE_NAMESPACE(std)
string& sname)
80 streamStack.push(
input);
97 inputStreamNames_coll::const_iterator i = inputStreamNames.find(sname);
98 if (i == inputStreamNames.end()) {
99 throw ANTLR_USE_NAMESPACE(std)string(
"TokenStream ")+sname+
" not found";
104#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
This interface allows any object to pretend it is a stream of tokens.
void select(TokenStream *stream)
Set the stream without pushing old stream.
TokenStream * getCurrentStream() const
Return the stream from which tokens are being pulled at the moment.
TokenStream * input
The currently-selected token stream input.
TokenStreamSelector()
A token stream MUX (multiplexor) knows about n token streams and can multiplex them onto the same cha...
void retry()
Abort recognition of current Token and try again.