cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
ctoken.h
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module: C Token
4
5
Author: Daniel Kroening, dkr@amazon.com
6
7
\*******************************************************************/
8
11
12
#ifndef CPROVER_CRANGLER_CTOKEN_H
13
#define CPROVER_CRANGLER_CTOKEN_H
14
15
#include <iosfwd>
16
#include <string>
17
18
class
ctokent
19
{
20
public
:
21
using
kindt
=
enum
{
22
END_OF_FILE,
23
INT_LIT,
24
CHAR_LIT,
25
FLOAT_LIT,
26
STRING_LIT,
27
C_COMMENT,
28
CPP_COMMENT,
29
IDENTIFIER,
30
OPERATOR,
31
WS,
32
SEPARATOR,
33
PREPROCESSOR_DIRECTIVE,
34
UNKNOWN
35
};
36
37
kindt
kind
;
38
39
// could be string_view, after C++17
40
std::string
text
;
41
42
std::size_t
line_number
= 0;
43
44
ctokent
() =
default
;
45
46
ctokent
(
kindt
_kind, std::string _text) :
kind
(_kind),
text
(
std
::move(_text))
47
{
48
}
49
50
void
output
(std::ostream &)
const
;
51
52
bool
operator==
(
const
char
*other_text)
const
53
{
54
return
text
== other_text;
55
}
56
57
bool
operator==
(
char
some_char)
const
58
{
59
return
text
== std::string(1, some_char);
60
}
61
62
bool
operator!=
(
char
some_char)
const
63
{
64
return
text
!= std::string(1, some_char);
65
}
66
};
67
68
static
inline
bool
is_identifier
(
const
ctokent
&t)
69
{
70
return
t.
kind
== ctokent::IDENTIFIER;
71
}
72
73
static
inline
bool
is_separator
(
const
ctokent
&t)
74
{
75
return
t.
kind
== ctokent::SEPARATOR;
76
}
77
78
static
inline
bool
is_operator
(
const
ctokent
&t)
79
{
80
return
t.
kind
== ctokent::OPERATOR;
81
}
82
83
static
inline
bool
is_ws
(
const
ctokent
&t)
84
{
85
return
t.
kind
== ctokent::WS;
86
}
87
88
static
inline
bool
is_eof
(
const
ctokent
&t)
89
{
90
return
t.
kind
== ctokent::END_OF_FILE;
91
}
92
93
static
inline
bool
is_comment
(
const
ctokent
&t)
94
{
95
return
t.
kind
== ctokent::C_COMMENT || t.
kind
== ctokent::CPP_COMMENT;
96
}
97
98
static
inline
bool
is_preprocessor_directive
(
const
ctokent
&t)
99
{
100
return
t.
kind
== ctokent::PREPROCESSOR_DIRECTIVE;
101
}
102
103
std::ostream &
operator<<
(std::ostream &,
const
ctokent
&);
104
105
#endif
// CPROVER_CRANGLER_CTOKEN_H
ctokent
Definition
ctoken.h:19
ctokent::line_number
std::size_t line_number
Definition
ctoken.h:42
ctokent::operator==
bool operator==(char some_char) const
Definition
ctoken.h:57
ctokent::output
void output(std::ostream &) const
Definition
ctoken.cpp:16
ctokent::operator!=
bool operator!=(char some_char) const
Definition
ctoken.h:62
ctokent::ctokent
ctokent()=default
ctokent::operator==
bool operator==(const char *other_text) const
Definition
ctoken.h:52
ctokent::ctokent
ctokent(kindt _kind, std::string _text)
Definition
ctoken.h:46
ctokent::kind
kindt kind
Definition
ctoken.h:37
ctokent::text
std::string text
Definition
ctoken.h:40
ctokent::kindt
enum { END_OF_FILE, INT_LIT, CHAR_LIT, FLOAT_LIT, STRING_LIT, C_COMMENT, CPP_COMMENT, IDENTIFIER, OPERATOR, WS, SEPARATOR, PREPROCESSOR_DIRECTIVE, UNKNOWN } kindt
Definition
ctoken.h:21
is_identifier
static bool is_identifier(const ctokent &t)
Definition
ctoken.h:68
is_operator
static bool is_operator(const ctokent &t)
Definition
ctoken.h:78
operator<<
std::ostream & operator<<(std::ostream &, const ctokent &)
Definition
ctoken.cpp:64
is_separator
static bool is_separator(const ctokent &t)
Definition
ctoken.h:73
is_comment
static bool is_comment(const ctokent &t)
Definition
ctoken.h:93
is_preprocessor_directive
static bool is_preprocessor_directive(const ctokent &t)
Definition
ctoken.h:98
is_ws
static bool is_ws(const ctokent &t)
Definition
ctoken.h:83
is_eof
static bool is_eof(const ctokent &t)
Definition
ctoken.h:88
std
STL namespace.
ai_verifier_statust::UNKNOWN
@ UNKNOWN
Definition
static_verifier.h:56
crangler
ctoken.h
Generated by
1.17.0