cprover
cpp_token_buffer.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: C++ Parser: Token Buffer
4 
5 Author: Daniel Kroening, kroening@cs.cmu.edu
6 
7 \*******************************************************************/
8 
11 
12 #ifndef CPROVER_CPP_CPP_TOKEN_BUFFER_H
13 #define CPROVER_CPP_CPP_TOKEN_BUFFER_H
14 
15 #include "cpp_token.h"
16 
17 #include <list>
18 
19 #include <util/invariant.h>
20 
22 {
23 public:
25  {
26  }
27 
28  typedef unsigned int post;
29 
30  int LookAhead(unsigned offset);
31  int get_token(cpp_tokent &token);
32  int get_token();
33  int LookAhead(unsigned offset, cpp_tokent &token);
34 
35  post Save();
36  void Restore(post pos);
37  void Replace(const cpp_tokent &token);
38  void Insert(const cpp_tokent &token);
39 
40  void clear()
41  {
42  tokens.clear();
43  token_vector.clear();
44  current_pos=0;
45  }
46 
47  // the token that is currently being read from the file
49  {
50  PRECONDITION(!tokens.empty());
51  return tokens.back();
52  }
53 
54 protected:
55  typedef std::list<cpp_tokent> tokenst;
57 
58  std::vector<tokenst::iterator> token_vector;
59 
61 
62  // get another token from lexer
63  void read_token();
64 };
65 
66 #endif // CPROVER_CPP_CPP_TOKEN_BUFFER_H
int LookAhead(unsigned offset)
cpp_tokent & current_token()
std::list< cpp_tokent > tokenst
void Replace(const cpp_tokent &token)
std::vector< tokenst::iterator > token_vector
void Restore(post pos)
void Insert(const cpp_tokent &token)
C++ Parser: Token.
literalt pos(literalt a)
Definition: literal.h:194
#define PRECONDITION(CONDITION)
Definition: invariant.h:464