OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
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.
71  TokenStream();
72  TokenStream(const TokenStream &);
73  void operator=(const TokenStream &);
74 };
75 
76 #endif // CLASSIC_TokenStream_HH
int getLine() const
Return line number.
Definition: TokenStream.cpp:49
bool put_back_flag
Definition: TokenStream.h:65
Token put_back
Definition: TokenStream.h:66
virtual ~TokenStream()
Definition: TokenStream.cpp:34
Abstract interface for a stream of input tokens.
Definition: TokenStream.h:33
virtual Token readToken()=0
Read single token from stream.
std::string stream_name
Definition: TokenStream.h:59
Representation of a single input token.
Definition: Token.h:33
Abstract base class for reference counted objects.
Definition: RCObject.h:42
void operator=(const TokenStream &)
void putBack(const Token &token)
Put token back to stream.
Definition: TokenStream.cpp:38
const std::string & getName() const
Return stream name.
Definition: TokenStream.cpp:54
const std::string name