cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
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
24
class
cpp_token_buffert
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
;
32
ansi_c_parser
.cpp11 =
33
config
.cpp.cpp_standard ==
configt::cppt::cpp_standardt::CPP11
||
34
config
.cpp.cpp_standard ==
configt::cppt::cpp_standardt::CPP14
||
35
config
.cpp.cpp_standard ==
configt::cppt::cpp_standardt::CPP17
;
36
ansi_c_parser
.ts_18661_3_Floatn_types =
false
;
37
ansi_c_parser
.mode =
config
.ansi_c.mode;
38
ansi_c_scanner_init
(
ansi_c_parser
);
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
61
cpp_tokent
&
current_token
()
62
{
63
PRECONDITION
(!
tokens
.empty());
64
return
tokens
.back();
65
}
66
67
ansi_c_parsert
ansi_c_parser
;
68
69
protected
:
70
typedef
std::list<cpp_tokent>
tokenst
;
71
tokenst
tokens
;
72
73
std::vector<tokenst::iterator>
token_vector
;
74
75
post
current_pos
;
76
77
void
*
ansi_c_scanner_state
;
78
79
// get another token from lexer
80
void
read_token
();
81
};
82
83
#endif
// CPROVER_CPP_CPP_TOKEN_BUFFER_H
ansi_c_parser.h
ansi_c_scanner_init
void ansi_c_scanner_init(ansi_c_parsert &)
config
configt config
Definition
config.cpp:25
ansi_c_parsert
Definition
ansi_c_parser.h:25
cpp_token_buffert::LookAhead
int LookAhead(unsigned offset)
Definition
cpp_token_buffer.cpp:14
cpp_token_buffert::ansi_c_scanner_state
void * ansi_c_scanner_state
Definition
cpp_token_buffer.h:77
cpp_token_buffert::ansi_c_parser
ansi_c_parsert ansi_c_parser
Definition
cpp_token_buffer.h:67
cpp_token_buffert::clear
void clear()
Definition
cpp_token_buffer.h:53
cpp_token_buffert::cpp_token_buffert
cpp_token_buffert(message_handlert &message_handler)
Definition
cpp_token_buffer.h:27
cpp_token_buffert::tokenst
std::list< cpp_tokent > tokenst
Definition
cpp_token_buffer.h:70
cpp_token_buffert::post
unsigned int post
Definition
cpp_token_buffer.h:41
cpp_token_buffert::Save
post Save()
Definition
cpp_token_buffer.cpp:96
cpp_token_buffert::read_token
void read_token()
Definition
cpp_token_buffer.cpp:71
cpp_token_buffert::Replace
void Replace(const cpp_tokent &token)
Definition
cpp_token_buffer.cpp:106
cpp_token_buffert::token_vector
std::vector< tokenst::iterator > token_vector
Definition
cpp_token_buffer.h:73
cpp_token_buffert::get_token
int get_token()
Definition
cpp_token_buffer.cpp:40
cpp_token_buffert::Restore
void Restore(post pos)
Definition
cpp_token_buffer.cpp:101
cpp_token_buffert::tokens
tokenst tokens
Definition
cpp_token_buffer.h:71
cpp_token_buffert::current_token
cpp_tokent & current_token()
Definition
cpp_token_buffer.h:61
cpp_token_buffert::current_pos
post current_pos
Definition
cpp_token_buffer.h:75
cpp_token_buffert::Insert
void Insert(const cpp_tokent &token)
Definition
cpp_token_buffer.cpp:116
cpp_tokent
Definition
cpp_token.h:20
message_handlert
Definition
message.h:27
config.h
cpp_token.h
C++ Parser: Token.
pos
literalt pos(literalt a)
Definition
literal.h:194
invariant.h
PRECONDITION
#define PRECONDITION(CONDITION)
Definition
invariant.h:463
configt::cppt::cpp_standardt::CPP11
@ CPP11
Definition
config.h:338
configt::cppt::cpp_standardt::CPP17
@ CPP17
Definition
config.h:340
configt::cppt::cpp_standardt::CPP14
@ CPP14
Definition
config.h:339
cpp
cpp_token_buffer.h
Generated by
1.17.0