OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
MacroStream.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: MacroStream.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.1.1.1 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: MacroStream
10 // Implements an input buffer for reading tokens from a token list.
11 // This string is intended for storing OPAL-9 macros.
12 //
13 // ------------------------------------------------------------------------
14 //
15 // $Date: 2000/03/27 09:33:43 $
16 // $Author: Andreas Adelmann $
17 //
18 // ------------------------------------------------------------------------
19 
20 #include "OpalParser/MacroStream.h"
21 #include "Parser/Token.h"
22 
23 
24 // Class MacroStream
25 // ------------------------------------------------------------------------
26 
27 MacroStream::MacroStream(const std::string &macName):
28  TokenStream(macName), body(), curr(body.begin())
29 {}
30 
31 
33 {}
34 
35 
36 void MacroStream::append(Token &token) {
37  body.push_back(token);
38 }
39 
40 
42  if(put_back_flag) {
43  put_back_flag = false;
44  return put_back;
45  } else if(curr == body.end()) {
46  return Token(stream_name, 1, Token::IS_EOF, "End of macro");
47  } else {
48  return *curr++;
49  }
50 }
51 
52 
54  curr = body.begin();
55  put_back_flag = false;
56 }
PartBunchBase< T, Dim >::ConstIterator begin(PartBunchBase< T, Dim > const &bunch)
Representation of a single input token.
Definition: Token.h:33
@ IS_EOF
Definition: Token.h:40
Abstract interface for a stream of input tokens.
Definition: TokenStream.h:33
bool put_back_flag
Definition: TokenStream.h:65
std::string stream_name
Definition: TokenStream.h:59
Token put_back
Definition: TokenStream.h:66
TokenList::iterator curr
Definition: MacroStream.h:60
virtual ~MacroStream()
Definition: MacroStream.cpp:32
void append(Token &)
Append a token to the stream.
Definition: MacroStream.cpp:36
void start()
Reset stream to start.
Definition: MacroStream.cpp:53
TokenList body
Definition: MacroStream.h:59
virtual Token readToken()
Read a token from the stream.
Definition: MacroStream.cpp:41