CBMC
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 <util/config.h>
16 #include <util/invariant.h>
17 
18 #include <ansi-c/ansi_c_parser.h>
19 
20 #include "cpp_token.h"
21 
22 #include <list>
23 
25 {
26 public:
27  explicit cpp_token_buffert(message_handlert &message_handler)
28  : ansi_c_parser(message_handler), current_pos(0)
29  {
30  // We use the ANSI-C scanner
31  ansi_c_parser.cpp98 = true;
39  }
40 
41  typedef unsigned int post;
42 
43  int LookAhead(unsigned offset);
44  int get_token(cpp_tokent &token);
45  int get_token();
46  int LookAhead(unsigned offset, cpp_tokent &token);
47 
48  post Save();
49  void Restore(post pos);
50  void Replace(const cpp_tokent &token);
51  void Insert(const cpp_tokent &token);
52 
53  void clear()
54  {
55  tokens.clear();
56  token_vector.clear();
57  current_pos=0;
58  }
59 
60  // the token that is currently being read from the file
62  {
63  PRECONDITION(!tokens.empty());
64  return tokens.back();
65  }
66 
68 
69 protected:
70  typedef std::list<cpp_tokent> tokenst;
72 
73  std::vector<tokenst::iterator> token_vector;
74 
76 
78 
79  // get another token from lexer
80  void read_token();
81 };
82 
83 #endif // CPROVER_CPP_CPP_TOKEN_BUFFER_H
void ansi_c_scanner_init(ansi_c_parsert &)
configt config
Definition: config.cpp:25
bool ts_18661_3_Floatn_types
Definition: ansi_c_parser.h:71
struct configt::cppt cpp
struct configt::ansi_ct ansi_c
int LookAhead(unsigned offset)
ansi_c_parsert ansi_c_parser
cpp_token_buffert(message_handlert &message_handler)
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:463
flavourt mode
Definition: config.h:256
enum configt::cppt::cpp_standardt cpp_standard