OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
TokenStream.h
Go to the documentation of this file.
1 #ifndef CLASSIC_TokenStream_HH
2 #define CLASSIC_TokenStream_HH
3 
4 // ------------------------------------------------------------------------
5 // $RCSfile: TokenStream.h,v $
6 // ------------------------------------------------------------------------
7 // $Revision: 1.1.1.1 $
8 // ------------------------------------------------------------------------
9 // Copyright: see Copyright.readme
10 // ------------------------------------------------------------------------
11 //
12 // Class: TokenStream
13 //
14 // ------------------------------------------------------------------------
15 // Class category: Parser
16 // ------------------------------------------------------------------------
17 //
18 // $Date: 2000/03/27 09:32:37 $
19 // $Author: fci $
20 //
21 // ------------------------------------------------------------------------
22 
23 
25 #include "Parser/Token.h"
26 #include <string>
27 
28 // Class TokenStream
29 // ------------------------------------------------------------------------
31 
32 
33 class TokenStream: public RCObject {
34 
35 public:
36 
38  // Store the stream name.
39  TokenStream(const std::string &name);
40 
41  virtual ~TokenStream();
42 
44  // This allows to reparse the token.
45  void putBack(const Token &token);
46 
48  virtual Token readToken() = 0;
49 
51  const std::string &getName() const;
52 
54  int getLine() const;
55 
56 protected:
57 
58  // Current stream name.
59  std::string stream_name;
60 
61  // Current input line number.
62  int curr_line;
63 
64  // Last token put back, if any.
67 
68 private:
69 
70  // Not implemented.
73  void operator=(const TokenStream &);
74 };
75 
76 #endif // CLASSIC_TokenStream_HH
const std::string name
Abstract base class for reference counted objects.
Definition: RCObject.h:40
Representation of a single input token.
Definition: Token.h:33
Abstract interface for a stream of input tokens.
Definition: TokenStream.h:33
bool put_back_flag
Definition: TokenStream.h:65
virtual ~TokenStream()
Definition: TokenStream.cpp:34
TokenStream(const TokenStream &)
std::string stream_name
Definition: TokenStream.h:59
Token put_back
Definition: TokenStream.h:66
int getLine() const
Return line number.
Definition: TokenStream.cpp:49
const std::string & getName() const
Return stream name.
Definition: TokenStream.cpp:54
void putBack(const Token &token)
Put token back to stream.
Definition: TokenStream.cpp:38
virtual Token readToken()=0
Read single token from stream.
void operator=(const TokenStream &)