OpenMD 3.0
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
TokenStreamBasicFilter.cpp
1/* ANTLR Translator Generator
2 * Project led by Terence Parr at http://www.jGuru.com
3 * Software rights: http://www.antlr.org/license.html
4 *
5 * $Id$
6 */
7#include "antlr/TokenStreamBasicFilter.hpp"
8
9#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
10namespace antlr {
11#endif
12
13/** This object is a TokenStream that passes through all
14 * tokens except for those that you tell it to discard.
15 * There is no buffering of the tokens.
16 */
21
22void TokenStreamBasicFilter::discard(int ttype)
23{
24 discardMask.add(ttype);
25}
26
27void TokenStreamBasicFilter::discard(const BitSet& mask)
28{
29 discardMask = mask;
30}
31
32RefToken TokenStreamBasicFilter::nextToken()
33{
34 RefToken tok = input->nextToken();
35 while ( tok && discardMask.member(tok->getType()) ) {
36 tok = input->nextToken();
37 }
38 return tok;
39}
40
41#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
42}
43#endif
44
TokenStreamBasicFilter(TokenStream &input_)
This object is a TokenStream that passes through all tokens except for those that you tell it to disc...
BitSet discardMask
The set of token types to discard.
TokenStream * input
The input stream.
This interface allows any object to pretend it is a stream of tokens.