65 return token ==
"auto" || token ==
"extern" || token ==
"static" ||
66 token ==
"register" || token ==
"_Thread_local";
71 return token ==
"const" || token ==
"volatile" || token ==
"restrict" ||
100 out <<
"DECLARATOR: ";
142 std::size_t bracket_count = 0;
149 dest.push_back(token);
152 else if(token ==
close)
155 if(bracket_count == 0)
176 auto &token =
peek();
180 token ==
"int" || token ==
"signed" || token.text ==
"unsigned" ||
181 token ==
"char" || token ==
"short" || token ==
"long" ||
182 token ==
"float" || token ==
"double" || token ==
"inline" ||
187 else if(token ==
"enum" || token ==
"struct" || token ==
"union")
202 else if(token ==
"__attribute__")
213 std::size_t index = 1;
216 const auto &next_token =
peek(index);
225 auto &next_token =
peek(index);
234 else if(token ==
';')
236 else if(token ==
'(')
243 "expected a declaration but got '" + token.text +
"'", loc);
285 std::size_t open_parentheses = 0;
298 else if(open_parentheses > 0)
317 else if(
peek() ==
'=')
325 result.push_back(token);
330 else if(
peek() ==
';')
335 else if(
peek() ==
'{')
339 std::size_t bracket_count = 0;
345 result.push_back(token);
348 else if(token ==
'}')
351 if(bracket_count == 0)
bool return_WS_and_comments
std::vector< ctokent > get_tokens()
Thrown when we can't handle something in an input source file.
tokenst parse_declarator()
void parse_brackets(char open, char close, tokenst &dest)
c_translation_unitt parse(std::istream &)
static bool is_storage_class(const ctokent &token)
tokenst parse_post_declarator()
tokenst parse_pre_declarator()
const ctokent & peek(std::size_t how_many) const
std::vector< ctokent > tokenst
const ctokent & peek() const
c_declarationt parse_declaration()
tokenst parse_initializer()
const ctokent & consume_token()
static bool is_type_qualifier(const ctokent &token)
void set_line(const irep_idt &line)
static bool is_comment(const ctokent &t)
static bool is_preprocessor_directive(const ctokent &t)
static bool is_ws(const ctokent &t)
static bool is_eof(const ctokent &t)
int open(const char *pathname, int flags,...)
std::ostream & operator<<(std::ostream &out, const c_declarationt &declaration)
c_translation_unitt parse_c(std::istream &in)
std::vector< c_declarationt > c_translation_unitt
static bool is_identifier(int token)
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
#define PRECONDITION(CONDITION)
std::optional< ctokent > declared_identifier() const
void print(std::ostream &) const