CBMC
cscanner.cpp
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: C Scanner
4 
5 Author: Daniel Kroening, dkr@amazon.com
6 
7 \*******************************************************************/
8 
9 #include "cscanner.h"
10 
12 
13 int yyclex();
16 
17 cscannert::cscannert(std::istream &_in) : in(_in)
18 {
20 }
21 
23 {
25 }
26 
28 {
29  cscanner_ptr = this;
30 
31  if(yyclex() == 0) // EOF
32  {
33  token.kind = ctokent::END_OF_FILE;
34  token.text.clear();
36  }
37 
38  return std::move(token);
39 }
40 
41 std::vector<ctokent> cscannert::get_tokens()
42 {
43  std::vector<ctokent> result;
44 
45  do
46  {
47  result.push_back(this->operator()());
48  } while(!is_eof(result.back()));
49 
50  return result;
51 }
std::size_t line_number
Definition: cscanner.h:29
~cscannert()
Definition: cscanner.cpp:22
std::vector< ctokent > get_tokens()
Definition: cscanner.cpp:41
cscannert(std::istream &)
Definition: cscanner.cpp:17
ctokent operator()()
Definition: cscanner.cpp:27
ctokent token
Definition: cscanner.h:43
Definition: ctoken.h:19
std::size_t line_number
Definition: ctoken.h:42
kindt kind
Definition: ctoken.h:37
std::string text
Definition: ctoken.h:40
int yyclex_destroy()
int yyclex()
cscannert * cscanner_ptr
Definition: cscanner.cpp:11
void initialize_yyc_scanner()
cscanner
static bool is_eof(const ctokent &t)
Definition: ctoken.h:88