CBMC
format_strings.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Format String Parser
4 
5 Author: CM Wintersteiger
6 
7 \*******************************************************************/
8 
11 
12 #ifndef CPROVER_GOTO_PROGRAMS_FORMAT_STRINGS_H
13 #define CPROVER_GOTO_PROGRAMS_FORMAT_STRINGS_H
14 
15 #include <util/irep.h>
16 #include <util/mp_arith.h>
17 
18 #include <list>
19 #include <optional>
20 #include <string>
21 
22 class typet;
23 
25 {
26 public:
27  enum class token_typet
28  {
29  UNKNOWN,
30  TEXT,
31  INT, // d, i, o, u, x
32  FLOAT, // a, e, f, g
33  CHAR, // c
34  STRING, // s
35  POINTER // p
36  };
37 
38  enum class flag_typet
39  {
40  ALTERNATE,
41  ZERO_PAD,
44  SIGN,
45  ASTERISK
46  };
47 
48  enum class length_modifierst
49  {
50  LEN_undef,
51  LEN_h,
52  LEN_hh,
53  LEN_l,
54  LEN_ll,
55  LEN_L,
56  LEN_j,
57  LEN_t
58  };
59 
60  enum class representationt
61  {
63  SIGNED_DEC,
67  };
68 
69  explicit format_tokent(token_typet _type)
70  : type(_type),
72  representation(representationt::SIGNED_undef)
73  {
74  }
78  representation(representationt::SIGNED_undef)
79  {
80  }
81 
83  std::list<flag_typet> flags;
88  irep_idt value; // for text and pattern matching
89 };
90 
91 typedef std::list<format_tokent> format_token_listt;
92 
93 format_token_listt parse_format_string(const std::string &);
94 
95 std::optional<typet> get_type(const format_tokent &);
96 
97 #endif // CPROVER_GOTO_PROGRAMS_FORMAT_STRINGS_H
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:38
mp_integer precision
token_typet type
mp_integer field_width
representationt representation
length_modifierst length_modifier
format_tokent(token_typet _type)
std::list< flag_typet > flags
irep_idt value
The type of an expression, extends irept.
Definition: type.h:29
format_token_listt parse_format_string(const std::string &)
std::list< format_tokent > format_token_listt
std::optional< typet > get_type(const format_tokent &)
BigInt mp_integer
Definition: smt_terms.h:17