CBMC
ctokenit.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: C Token Iterator
4 
5 Author: Daniel Kroening, dkr@amazon.com
6 
7 \*******************************************************************/
8 
11 
12 #ifndef CPROVER_CRANGLER_CTOKENIT_H
13 #define CPROVER_CRANGLER_CTOKENIT_H
14 
15 #include "ctoken.h"
16 
17 #include <vector>
18 
19 class ctokenitt
20 {
21 public:
22  using tokenst = std::vector<ctokent>;
23 
24  explicit ctokenitt(const tokenst &__tokens) : tokens(__tokens)
25  {
26  }
27 
28  explicit operator bool() const
29  {
30  return !eof();
31  }
32 
33  bool eof() const
34  {
35  return pos >= tokens.size();
36  }
37 
38  ctokenitt &operator+=(std::size_t offset)
39  {
40  pos += offset;
41  return *this;
42  }
43 
44  ctokenitt operator++(int); // postfix ++
45 
46  const ctokent &operator*() const;
47 
48  const ctokent *operator->() const
49  {
50  return &**this;
51  }
52 
53  tokenst::const_iterator cit() const
54  {
55  return tokens.begin() + pos;
56  }
57 
58  bool operator!=(const ctokenitt &other) const
59  {
60  return pos != other.pos;
61  }
62 
63 protected:
64  const tokenst &tokens;
65  std::size_t pos = 0;
66 };
67 
71 
72 #endif // CPROVER_CRANGLER_CTOKENIT_H
tokenst::const_iterator cit() const
Definition: ctokenit.h:53
const ctokent * operator->() const
Definition: ctokenit.h:48
std::size_t pos
Definition: ctokenit.h:65
ctokenitt & operator+=(std::size_t offset)
Definition: ctokenit.h:38
bool eof() const
Definition: ctokenit.h:33
ctokenitt operator++(int)
Definition: ctokenit.cpp:25
const ctokent & operator*() const
Definition: ctokenit.cpp:19
std::vector< ctokent > tokenst
Definition: ctokenit.h:22
bool operator!=(const ctokenitt &other) const
Definition: ctokenit.h:58
const tokenst & tokens
Definition: ctokenit.h:64
ctokenitt(const tokenst &__tokens)
Definition: ctokenit.h:24
Definition: ctoken.h:19
ctoken
ctokenitt match_bracket(ctokenitt, char open, char close)
Definition: ctokenit.cpp:33
int open(const char *pathname, int flags,...)
Definition: fcntl.c:89
int close(int fildes)
Definition: unistd.c:139