19#include <ansi-c/ansi_c_y.tab.h>
29static unsigned __indent;
33 indenter() { __indent+=2; }
34 ~indenter() { __indent-=2; }
40 lex.LookAhead(0, _tk); \
41 std::cout << std::string(__indent, ' ') << "Text [" << _tk.line_no << "]: " \
42 << _tk.text << '\n'; \
118 return "CLASS_TEMPLATE";
120 return "MEMBER_TEMPLATE";
122 return "FUNCTION_TEMPLATE";
126 return "NON_TYPE_TEMPLATE_PARAMETER";
128 return "TYPE_TEMPLATE_PARAMETER";
130 return "TEMPLATE_TEMPLATE_PARAMETER";
136 typedef std::map<irep_idt, new_scopet>
id_mapt;
143 inline void print(std::ostream &out)
const
161 void print_rec(std::ostream &,
unsigned indent)
const;
184 for(id_mapt::const_iterator
189 out << std::string(indent,
' ') << it->first <<
": "
191 it->second.print_rec(out, indent+2);
199 lex(_cpp_parser.token_buffer),
276 typet &trailing_return_type);
398 if(p->
id()==ID_merged_type)
401 p = &merged_type.last_type();
415 return token == TOK_GCC_IDENTIFIER || token == TOK_MSC_IDENTIFIER;
422 if(cpp_name.
get_sub().size()==1 &&
423 cpp_name.
get_sub().front().id()==ID_name)
424 id=cpp_name.
get_sub().front().get(ID_identifier);
471 if(dest.
id()!=ID_merged_type)
484 sub.emplace(sub.begin(), src);
490#define ERROR_TOKENS 4
500 source_location.
set_file(t[0].filename);
501 source_location.
set_line(std::to_string(t[0].line_no));
503 std::string message =
"parse error before '";
558 std::cout << std::string(__indent,
' ') <<
"Parser::rDefinition 1 " << t
564 else if(t==TOK_TYPEDEF)
566 else if(t==TOK_TEMPLATE)
570 else if(t==TOK_EXTERN &&
lex.
LookAhead(1)==TOK_TEMPLATE)
572 else if(t==TOK_NAMESPACE)
574 else if(t==TOK_INLINE &&
lex.
LookAhead(1)==TOK_NAMESPACE)
582 else if(t==TOK_USING)
584 else if(t==TOK_STATIC_ASSERT)
615 std::cout << std::string(__indent,
' ') <<
"Parser::rTypedef 1\n";
644 std::cout << std::string(__indent,
' ') <<
"Parser::rTypedefUsing 1\n";
660 std::cout << std::string(__indent,
' ') <<
"Parser::rTypedefUsing 2\n";
677 std::cout << std::string(__indent,
' ') <<
"Parser::rTypedefUsing 3\n";
701 std::cout << std::string(__indent,
' ') <<
"Parser::rTypeSpecifier 0\n";
712 std::cout << std::string(__indent,
' ') <<
"Parser::rTypeSpecifier 0.1\n";
724 std::cout << std::string(__indent,
' ') <<
"Parser::rTypeSpecifier 1\n";
732 std::cout << std::string(__indent,
' ') <<
"Parser::rTypeSpecifier 2\n";
740 std::cout << std::string(__indent,
' ') <<
"Parser::rTypeSpecifier 3\n";
749 std::cout << std::string(__indent,
' ') <<
"Parser::rTypeSpecifier 4\n";
761 return is_identifier(t) || t == TOK_SCOPE || t == TOK_CONSTEXPR ||
762 t == TOK_CONST || t == TOK_VOLATILE || t == TOK_RESTRICT ||
763 t == TOK_CHAR || t == TOK_INT || t == TOK_SHORT || t == TOK_LONG ||
764 t == TOK_CHAR16_T || t == TOK_CHAR32_T || t == TOK_WCHAR_T ||
766 || t == TOK_SIGNED || t == TOK_UNSIGNED || t == TOK_FLOAT ||
767 t == TOK_DOUBLE || t == TOK_INT8 || t == TOK_INT16 || t == TOK_INT32 ||
768 t == TOK_INT64 || t == TOK_GCC_INT128 || t == TOK_PTR32 ||
769 t == TOK_PTR64 || t == TOK_GCC_FLOAT80 || t == TOK_GCC_FLOAT128 ||
770 t == TOK_VOID || t == TOK_BOOL || t == TOK_CPROVER_BOOL ||
771 t == TOK_CLASS || t == TOK_STRUCT || t == TOK_UNION || t == TOK_ENUM ||
772 t == TOK_INTERFACE || t == TOK_TYPENAME || t == TOK_TYPEOF ||
773 t == TOK_DECLTYPE || t == TOK_UNDERLYING_TYPE;
808 linkage_spec.
items().push_back(item);
824 bool is_inline=
false;
841 name=tk2.
data.
get(ID_C_base_name);
965 items.push_back(item);
969 items.push_back(item);
1001 typet template_type;
1020 std::cout << std::string(__indent,
' ') <<
"BODY: "
1021 << body.
pretty() <<
'\n';
1022 std::cout << std::string(__indent,
' ') <<
"TEMPLATE_TYPE: "
1023 << template_type.
pretty() <<
'\n';
1025 body.
add(ID_template_type).
swap(template_type);
1026 body.
set(ID_is_template,
true);
1036 body.
add(ID_template_type).
swap(template_type);
1037 body.
set(ID_is_template,
true);
1057 decl=
typet(ID_template);
1070 irept &template_parameters=decl.
add(ID_template_parameters);
1094 if(template_parameters.
get_sub().empty())
1119 args.
get_sub().back().swap(a);
1130 args.
get_sub().back().swap(a);
1147 std::cout << std::string(__indent,
' ') <<
"Parser::rTempArgDeclaration 0\n";
1152 if((t0==TOK_CLASS || t0==TOK_TYPENAME))
1162 declaration.
set(ID_is_type,
true);
1163 declaration.
type()=
typet(
"cpp-template-type");
1173 bool has_ellipsis=
false;
1222 std::cout << std::string(__indent,
' ') <<
"Parser::rTempArgDeclaration 1\n";
1225 if(t0==TOK_TEMPLATE)
1229 typet template_type;
1259 std::cout << std::string(__indent,
' ')
1260 <<
"Parser::rTempArgDeclaration 2\n";
1264 declaration.
set(ID_is_type,
false);
1270 std::cout << std::string(__indent,
' ')
1271 <<
"Parser::rTempArgDeclaration 3\n";
1274 bool has_ellipsis=
false;
1291 std::cout << std::string(__indent,
' ')
1292 <<
"Parser::rTempArgDeclaration 4\n";
1378 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclaration 0.1 token: "
1390 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclaration 0.2\n";
1398 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclaration 1\n";
1406 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclaration 3\n";
1409 typet cv_q, integral;
1427 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclaration 4\n";
1441 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclaration 5\n";
1445 declaration, storage_spec, member_spec, integral, cv_q);
1452 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclaration 6 " << t
1471 typet cv_q, integral;
1497 integral.
swap(cv_q);
1536 std::cout << std::string(__indent,
' ')
1537 <<
"Parser::rIntegralDeclaration 1 token: "
1545 std::cout << std::string(__indent,
' ') <<
"Parser::rIntegralDeclaration 2\n";
1551 std::cout << std::string(__indent,
' ') <<
"Parser::rIntegralDeclaration 3\n";
1564 std::cout << std::string(__indent,
' ')
1565 <<
"Parser::rIntegralDeclaration 4\n";
1573 std::cout << std::string(__indent,
' ')
1574 <<
"Parser::rIntegralDeclaration 5\n";
1594 std::cout << std::string(__indent,
' ') <<
"Parser::rIntegralDeclaration 6 "
1603 declaration.
type().
id() == ID_auto &&
1605 declaration.
declarators().front().type().id() == ID_function_type &&
1606 declaration.
declarators().front().type().add_subtype().is_not_nil())
1608 declaration.
type() =
1611 declaration.
declarators().front().type().add_subtype().make_nil();
1615 std::cout << std::string(__indent,
' ')
1616 <<
"Parser::rIntegralDeclaration 7\n";
1622 std::cout << std::string(__indent,
' ')
1623 <<
"Parser::rIntegralDeclaration 8 "
1624 << declaration.
pretty() <<
'\n';
1632 std::cout << std::string(__indent,
' ')
1633 <<
"Parser::rIntegralDeclaration 9\n";
1643 std::cout << std::string(__indent,
' ')
1644 <<
"Parser::rIntegralDeclaration 10\n";
1656 std::cout << std::string(__indent,
' ') <<
"Parser::rConstDeclaration\n";
1681 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 1\n";
1684 if(!
rName(type_name))
1690 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 2\n";
1704 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 3\n";
1713 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 4\n";
1718 for(std::size_t i=0; i < type_name.
get_sub().size(); i++)
1720 if(type_name.
get_sub()[i].id() == ID_operator)
1731 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 5\n";
1735 typet type = type_name;
1739 typet trailing_return_type;
1741 conv_operator_declarator, type_name, trailing_return_type))
1744 type_name=
typet(
"cpp-cast-operator");
1746 declaration.
declarators().push_back(conv_operator_declarator);
1751 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 6\n";
1756 bool is_destructor=
false;
1757 for(
const auto &irep : type_name.
get_sub())
1759 if(irep.id() ==
"~")
1767 typet trailing_return_type;
1769 constructor_declarator, type_name, trailing_return_type))
1773 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 7\n";
1778 type_name=trailing_return_type;
1780 type_name=
typet(is_destructor?ID_destructor:ID_constructor);
1782 declaration.
declarators().push_back(constructor_declarator);
1787 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 8\n";
1805 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 9\n";
1817 declaration.
type().
swap(type_name);
1822 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 10\n";
1828 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 11\n";
1837 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 12\n";
1861 std::cout << std::string(__indent,
' ') <<
"Parser::isConstructorDecl "
1870 if(t==
'*' || t==
'&' || t==
'(')
1872 else if(t==TOK_STDCALL || t==TOK_FASTCALL || t==TOK_CLRCALL || t==TOK_CDECL)
1923 else if(v==
'\0' || v==
';' || v==
'}')
1927 else if(u==
'\0' || u==
';' || u==
'}')
1952 member_spec.
clear();
1957 t == TOK_FRIEND || t == TOK_INLINE || t == TOK_VIRTUAL ||
1958 t == TOK_EXPLICIT || t == TOK_MSC_FORCEINLINE)
1966 case TOK_MSC_FORCEINLINE:
1969 case TOK_VIRTUAL: member_spec.
set_virtual(
true);
break;
1970 case TOK_FRIEND: member_spec.
set_friend(
true);
break;
1971 case TOK_EXPLICIT: member_spec.
set_explicit(
true);
break;
1995 t==TOK_THREAD_LOCAL)
2002 case TOK_STATIC: storage_spec.
set_static();
break;
2003 case TOK_EXTERN: storage_spec.
set_extern();
break;
2004 case TOK_AUTO: storage_spec.
set_auto();
break;
2006 case TOK_MUTABLE: storage_spec.
set_mutable();
break;
2007 case TOK_GCC_ASM: storage_spec.
set_asm();
break;
2026 if(t==TOK_CONSTEXPR ||
2027 t==TOK_CONST || t==TOK_VOLATILE || t==TOK_RESTRICT ||
2028 t==TOK_PTR32 || t==TOK_PTR64 ||
2029 t==TOK_GCC_ATTRIBUTE || t==TOK_GCC_ASM)
2038 p=
typet(ID_constexpr);
2050 p=
typet(ID_volatile);
2056 p=
typet(ID_restrict);
2073 case TOK_GCC_ATTRIBUTE:
2128 exprt exp(ID_alignof);
2129 exp.
add(ID_type_arg).
swap(tname);
2132 typet attr(ID_aligned);
2134 attr.
add(ID_size, exp);
2151 typet attr(ID_aligned);
2153 attr.
add(ID_size, exp);
2167 std::cout << std::string(__indent,
' ') <<
"Parser::rGCCAttribute "
2184 case TOK_GCC_ATTRIBUTE_PACKED:
2186 typet attr(ID_packed);
2192 case TOK_GCC_ATTRIBUTE_TRANSPARENT_UNION:
2194 typet attr(ID_transparent_union);
2200 case TOK_GCC_ATTRIBUTE_VECTOR_SIZE:
2215 attr.
set(ID_size, exp);
2221 case TOK_GCC_ATTRIBUTE_ALIGNED:
2223 typet attr(ID_aligned);
2240 attr.
add(ID_size, exp);
2247 case TOK_GCC_ATTRIBUTE_MODE:
2261 typet attr(ID_gcc_attribute_mode);
2268 case TOK_GCC_ATTRIBUTE_GNU_INLINE:
2270 typet attr(ID_static);
2276 case TOK_GCC_ATTRIBUTE_WEAK:
2278 typet attr(ID_weak);
2284 case TOK_GCC_ATTRIBUTE_ALIAS:
2297 typet attr(ID_alias);
2304 case TOK_GCC_ATTRIBUTE_SECTION:
2317 typet attr(ID_section);
2324 case TOK_GCC_ATTRIBUTE_NORETURN:
2326 typet attr(ID_noreturn);
2332 case TOK_GCC_ATTRIBUTE_CONSTRUCTOR:
2334 typet attr(ID_constructor);
2340 case TOK_GCC_ATTRIBUTE_DESTRUCTOR:
2342 typet attr(ID_destructor);
2394 typet attr(ID_noreturn);
2421 std::cout << std::string(__indent,
' ')
2422 <<
"Parser::optIntegralTypeOrClassSpec 0\n";
2432 bool is_integral=
false;
2442 std::cout << std::string(__indent,
' ')
2443 <<
"Parser::optIntegralTypeOrClassSpec 1\n";
2450 case TOK_CHAR: type_id=ID_char;
break;
2451 case TOK_CHAR16_T: type_id=ID_char16_t;
break;
2452 case TOK_CHAR32_T: type_id=ID_char32_t;
break;
2453 case TOK_INT: type_id=ID_int;
break;
2454 case TOK_SHORT: type_id=ID_short;
break;
2455 case TOK_LONG: type_id=ID_long;
break;
2456 case TOK_SIGNED: type_id=ID_signed;
break;
2457 case TOK_WCHAR_T: type_id=ID_wchar_t;
break;
2458 case TOK_COMPLEX: type_id=ID_complex;
break;
2459 case TOK_UNSIGNED: type_id=ID_unsigned;
break;
2460 case TOK_FLOAT: type_id=ID_float;
break;
2461 case TOK_DOUBLE: type_id=ID_double;
break;
2462 case TOK_VOID: type_id=ID_void;
break;
2463 case TOK_INT8: type_id=ID_int8;
break;
2464 case TOK_INT16: type_id=ID_int16;
break;
2465 case TOK_INT32: type_id=ID_int32;
break;
2466 case TOK_INT64: type_id=ID_int64;
break;
2467 case TOK_GCC_INT128: type_id=ID_gcc_int128;
break;
2468 case TOK_GCC_FLOAT80: type_id=ID_gcc_float80;
break;
2469 case TOK_GCC_FLOAT128: type_id=ID_gcc_float128;
break;
2471 type_id = ID_c_bool;
2473 case TOK_CPROVER_BOOL: type_id=ID_proper_bool;
break;
2474 case TOK_AUTO: type_id = ID_auto;
break;
2478 if(!type_id.
empty())
2495 std::cout << std::string(__indent,
' ')
2496 <<
"Parser::optIntegralTypeOrClassSpec 2\n";
2503 std::cout << std::string(__indent,
' ')
2504 <<
"Parser::optIntegralTypeOrClassSpec 3\n";
2507 if(t==TOK_CLASS || t==TOK_STRUCT || t==TOK_UNION || t==TOK_INTERFACE)
2509 else if(t==TOK_ENUM)
2511 else if(t==TOK_TYPEOF)
2514 std::cout << std::string(__indent,
' ')
2515 <<
"Parser::optIntegralTypeOrClassSpec 4\n";
2522 std::cout << std::string(__indent,
' ')
2523 <<
"Parser::optIntegralTypeOrClassSpec 5\n";
2543 p.
add(ID_type_arg).
swap(tname);
2552 std::cout << std::string(__indent,
' ')
2553 <<
"Parser::optIntegralTypeOrClassSpec 6\n";
2561 std::cout << std::string(__indent,
' ')
2562 <<
"Parser::optIntegralTypeOrClassSpec 7\n";
2569 std::cout << std::string(__indent,
' ')
2570 <<
"Parser::optIntegralTypeOrClassSpec 8\n";
2573 p.
add(ID_expr_arg).
swap(expr);
2577 else if(t==TOK_DECLTYPE)
2582 p=
typet(ID_decltype);
2598 p.
add(ID_expr_arg).
swap(expr);
2602 else if(t==TOK_UNDERLYING_TYPE)
2609 p=
typet(ID_msc_underlying_type);
2626 p.
add(ID_type_arg).
swap(tname);
2645 typet &trailing_return_type)
2649 std::cout << std::string(__indent,
' ') <<
"Parser::rConstructorDecl 0\n";
2656 constructor.
name().
swap(type_name);
2663 std::cout << std::string(__indent,
' ') <<
"Parser::rConstructorDecl 1\n";
2666 irept ¶meters=constructor.
type().
add(ID_parameters);
2676 std::cout << std::string(__indent,
' ') <<
"Parser::rConstructorDecl 2\n";
2679 typet &cv=
static_cast<typet &
>(constructor.
add(ID_method_qualifier));
2688 std::cout << std::string(__indent,
' ') <<
"Parser::rConstructorDecl 3\n";
2700 std::cout << std::string(__indent,
' ') <<
"Parser::rConstructorDecl 4\n";
2714 std::cout << std::string(__indent,
' ') <<
"Parser::rConstructorDecl 5\n";
2726 constructor.
value()=
codet(
"cpp-pure-virtual");
2796 else if(t==TOK_ELLIPSIS)
2842 bool should_be_declarator,
2853 declarators.push_back(declarator);
2871 bool should_be_declarator,
2884 typet bit_field_type(ID_c_bit_field);
2885 bit_field_type.
set(ID_size, e);
2889 dw.
type() = std::move(bit_field_type);
2898 declarator,
kDeclarator, should_be_declarator, is_statement))
2943 if(declarator.
type().
id()!=ID_function_type)
2959 typet bit_field_type(ID_c_bit_field);
2960 bit_field_type.
set(ID_size, e);
2967 dw.
swap(declarator);
2984 while(t==TOK_STDCALL || t==TOK_FASTCALL || t==TOK_CLRCALL || t==TOK_CDECL)
3014 bool should_be_declarator,
3021 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 1\n";
3028 typet d_outer, d_inner;
3043 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 2\n";
3051 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 3\n";
3062 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 4\n";
3070 if(!should_be_declarator)
3075 if(t!=
'[' && t!=
'(')
3081 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 5\n";
3092 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 6\n";
3101 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 7\n";
3114 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 8\n";
3134 typet function_type(ID_function_type);
3136 function_type.
add(ID_parameters).
swap(args);
3140 d_outer.
swap(d_inner);
3146 init_args.
swap(args);
3151 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 9\n";
3160 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 10\n";
3181 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 11\n";
3199 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 12\n";
3214 std::list<typet> tl;
3215 tl.push_back(d_outer);
3216 while(tl.back().id() == ID_array)
3218 tl.push_back(tl.back().add_subtype());
3223 d_outer.
swap(array_type);
3226 tl.back().add_subtype().swap(d_outer);
3227 d_outer.
swap(tl.back());
3243 d_outer.
swap(merged_type);
3247 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 13\n";
3273 std::cout << std::string(__indent,
' ') <<
"Parser::optPtrOperator 1\n";
3276 std::list<typet> t_list;
3283 std::cout << std::string(__indent,
' ') <<
"Parser::optPtrOperator 2 " << t
3289 typet op(ID_frontend_pointer);
3300 t_list.push_back(op);
3305 typet op(ID_block_pointer);
3316 t_list.push_back(op);
3330 t_list.push_back(cv);
3333 t_list.push_back(op);
3346 typet op(ID_frontend_pointer);
3347 op.
set(ID_C_reference,
true);
3349 t_list.push_front(op);
3351 else if(t==TOK_ANDAND)
3355 typet op(ID_frontend_pointer);
3356 op.
set(ID_C_rvalue_reference,
true);
3358 t_list.push_front(op);
3362 for(std::list<typet>::reverse_iterator
3367 if(it->id()==ID_merged_type)
3370 merged_type.last_type().add_subtype().swap(ptrs);
3375 it->add_subtype().swap(ptrs);
3395 init=
irept(ID_member_initializers);
3425 std::cout << std::string(__indent,
' ') <<
"Parser::rMemberInit 1\n";
3434 std::cout << std::string(__indent,
' ') <<
"Parser::rMemberInit 2\n";
3437 init=
codet(ID_member_initializer);
3438 init.
add(ID_member).
swap(name);
3448 std::cout << std::string(__indent,
' ') <<
"Parser::rMemberInit 3\n";
3467 std::cout << std::string(__indent,
' ') <<
"Parser::rMemberInit 4\n";
3507 std::cout << std::string(__indent,
' ') <<
"Parser::rName 0\n";
3517 name.
set(ID_typename,
true);
3527 std::cout << std::string(__indent,
' ') <<
"Parser::rName 1\n";
3535 std::cout << std::string(__indent,
' ') <<
"Parser::rName 2 "
3543 std::cout << std::string(__indent,
' ') <<
"Parser::rName 3\n";
3553 std::cout << std::string(__indent,
' ') <<
"Parser::rName 4\n";
3560 components.push_back(
irept(ID_template_args));
3561 components.back().
add(ID_arguments).
swap(args);
3569 case TOK_GCC_IDENTIFIER:
3570 case TOK_MSC_IDENTIFIER:
3572 std::cout << std::string(__indent,
' ') <<
"Parser::rName 5\n";
3581 if(t!=TOK_SCOPE && t!=
'<')
3588 std::cout << std::string(__indent,
' ') <<
"Parser::rName 6\n";
3591 components.push_back(
irept(
"::"));
3597 std::cout << std::string(__indent,
' ') <<
"Parser::rName 7\n";
3605 components.push_back(
irept(
"~"));
3611 std::cout << std::string(__indent,
' ') <<
"Parser::rName 8\n";
3615 components.push_back(
irept(ID_operator));
3618 components.push_back(
irept());
3671 operator_id = std::string(1,
static_cast<char>(t));
3674 case TOK_MULTASSIGN: operator_id=
"*=";
break;
3675 case TOK_DIVASSIGN: operator_id=
"/=";
break;
3676 case TOK_MODASSIGN: operator_id=
"%=";
break;
3677 case TOK_PLUSASSIGN: operator_id=
"+=";
break;
3678 case TOK_MINUSASSIGN: operator_id=
"-=";
break;
3679 case TOK_SHLASSIGN: operator_id=
"<<=";
break;
3680 case TOK_SHRASSIGN: operator_id=
">>=";
break;
3681 case TOK_ANDASSIGN: operator_id=
"&=";
break;
3682 case TOK_XORASSIGN: operator_id=
"^=";
break;
3683 case TOK_ORASSIGN: operator_id=
"|=";
break;
3684 case TOK_SHIFTLEFT: operator_id=
"<<";
break;
3685 case TOK_SHIFTRIGHT: operator_id=
">>";
break;
3686 case TOK_EQ: operator_id=
"==";
break;
3687 case TOK_NE: operator_id=
"!=";
break;
3688 case TOK_LE: operator_id=
"<=";
break;
3689 case TOK_GE: operator_id=
">=";
break;
3690 case TOK_ANDAND: operator_id=
"&&";
break;
3691 case TOK_OROR: operator_id=
"||";
break;
3692 case TOK_INCR: operator_id=
"++";
break;
3693 case TOK_DECR: operator_id=
"--";
break;
3694 case TOK_DOTPM: operator_id=
".*";
break;
3695 case TOK_ARROWPM: operator_id=
"->*";
break;
3696 case TOK_ARROW: operator_id=
"->";
break;
3705 name=
irept(t==TOK_NEW?ID_cpp_new:ID_cpp_delete);
3710 name=
irept(t==TOK_NEW?ID_cpp_new_array:ID_cpp_delete_array);
3739 name=
irept(operator_id);
3753 typet cv1, cv2, type_name, ptr;
3768 if(!
rName(type_name))
3795 std::cout << std::string(__indent,
' ') <<
"Parser::rPtrToMember 0\n";
3798 typet ptm(ID_frontend_pointer);
3799 irept &name = ptm.
add(ID_to_member);
3809 bool loop_cond =
true;
3829 components.push_back(
irept(ID_template_args));
3830 components.back().
add(ID_arguments).
swap(args);
3838 case TOK_GCC_IDENTIFIER:
3839 case TOK_MSC_IDENTIFIER:
3846 if(t != TOK_SCOPE && t !=
'<')
3854 components.push_back(
irept(
"::"));
3861 ptr_to_mem.
swap(ptm);
3864 std::cout << std::string(__indent,
' ') <<
"Parser::rPtrToMember 1\n";
3895 std::cout << std::string(__indent,
' ') <<
"Parser::rTemplateArgs 0\n";
3906 std::cout << std::string(__indent,
' ') <<
"Parser::rTemplateArgs 1\n";
3918 std::cout << std::string(__indent,
' ') <<
"Parser::rTemplateArgs 2\n";
3927 std::cout << std::string(__indent,
' ') <<
"Parser::rTemplateArgs 3\n";
3942 std::cout << std::string(__indent,
' ') <<
"Parser::rTemplateArgs 4\n";
3954 exp.
id(ID_ambiguous);
3956 std::cout << std::string(__indent,
' ') <<
"Parser::rTemplateArgs 4.1\n";
3968 std::cout << std::string(__indent,
' ') <<
"Parser::rTemplateArgs 4.2\n";
3975 std::cout << std::string(__indent,
' ') <<
"Parser::rTemplateArgs 5\n";
3993 std::cout << std::string(__indent,
' ') <<
"Parser::rTemplateArgs 6\n";
3997 template_args.
get_sub().back().swap(exp);
4009 case TOK_SHIFTRIGHT:
4090 else if(t==TOK_ELLIPSIS)
4102 list.
get_sub().back().swap(declaration);
4106 else if(t==TOK_ELLIPSIS)
4111 else if(t!=
')' && t!=TOK_ELLIPSIS)
4140 header=
typet(ID_register);
4158 declaration.
declarators().push_back(arg_declarator);
4188 expr.
id(ID_initializer_list);
4197 if(t==TOK_MSC_IF_EXISTS ||
4198 t==TOK_MSC_IF_NOT_EXISTS)
4308 std::cout << std::string(__indent,
' ') <<
"Parser::rEnumSpec 1\n";
4325 spec.
set(ID_C_class,
true);
4342 std::cout << std::string(__indent,
' ') <<
"Parser::rEnumSpec 2\n";
4354 std::cout << std::string(__indent,
' ') <<
"Parser::rEnumSpec 3\n";
4377 std::cout << std::string(__indent,
' ') <<
"Parser::rEnumSpec 4\n";
4449 std::cout << std::string(__indent,
' ') <<
"Parser::rClassSpec 1\n";
4453 if(t!=TOK_CLASS && t!=TOK_STRUCT &&
4454 t!=TOK_UNION && t!=TOK_INTERFACE)
4458 std::cout << std::string(__indent,
' ') <<
"Parser::rClassSpec 2\n";
4463 spec=
typet(ID_struct);
4464 spec.
set(ID_C_class,
true);
4466 else if(t==TOK_INTERFACE)
4468 spec=
typet(ID_struct);
4469 spec.
set(ID_C_interface,
true);
4471 else if(t==TOK_STRUCT)
4472 spec=
typet(ID_struct);
4473 else if(t==TOK_UNION)
4474 spec=
typet(ID_union);
4481 std::cout << std::string(__indent,
' ') <<
"Parser::rClassSpec 3\n";
4488 std::cout << std::string(__indent,
' ') <<
"Parser::rClassSpec 4\n";
4507 std::cout << std::string(__indent,
' ') <<
"Parser::rClassSpec 5\n";
4527 std::cout << std::string(__indent,
' ') <<
"Parser::rClassSpec 6\n";
4539 std::cout << std::string(__indent,
' ') <<
"Parser::rClassSpec 7\n";
4563 irept base(ID_base);
4568 base.
set(ID_virtual,
true);
4572 if(t==TOK_PUBLIC || t==TOK_PROTECTED || t==TOK_PRIVATE)
4577 base.
set(ID_protection, ID_public);
4581 base.
set(ID_protection, ID_protected);
4585 base.
set(ID_protection, ID_private);
4598 base.
set(ID_virtual,
true);
4612 bases.
get_sub().back().swap(base);
4630 std::cout << std::string(__indent,
' ') <<
"Parser::rClassBody 0\n";
4655 std::cout << std::string(__indent,
' ') <<
"Parser::rClassBody "
4656 << member.
pretty() <<
'\n';
4660 std::move(
static_cast<exprt &
>(
static_cast<irept &
>(member))));
4692 std::cout << std::string(__indent,
' ') <<
"Parser::rClassMember 0 " << t
4696 if(t==TOK_PUBLIC || t==TOK_PROTECTED || t==TOK_PRIVATE)
4701 member.
id(
"cpp-public");
4705 member.
id(
"cpp-protected");
4709 member.
id(
"cpp-private");
4725 else if(t==TOK_TYPEDEF)
4727 else if(t==TOK_TEMPLATE)
4735 else if(t==TOK_USING)
4737 else if(t==TOK_STATIC_ASSERT)
4766 name_decl.
name() = name;
4783 std::cout << std::string(__indent,
' ') <<
"Parser::rCommaExpression 0\n";
4790 std::cout << std::string(__indent,
' ') <<
"Parser::rCommaExpression 1\n";
4806 exp=
exprt(ID_comma);
4812 std::cout << std::string(__indent,
' ') <<
"Parser::rCommaExpression 2\n";
4828 std::cout << std::string(__indent,
' ') <<
"Parser::rExpression 0\n";
4835 std::cout << std::string(__indent,
' ') <<
"Parser::rExpression 1\n";
4841 t==TOK_MULTASSIGN || t==TOK_DIVASSIGN || t==TOK_MODASSIGN ||
4842 t==TOK_PLUSASSIGN || t==TOK_MINUSASSIGN || t==TOK_SHLASSIGN ||
4843 t==TOK_SHRASSIGN || t==TOK_ANDASSIGN ||
4844 t==TOK_XORASSIGN || t==TOK_ORASSIGN)
4849 std::cout << std::string(__indent,
' ') <<
"Parser::rExpression 2\n";
4857 std::cout << std::string(__indent,
' ') <<
"Parser::rExpression 3\n";
4863 exp=
exprt(ID_side_effect);
4866 exp.
set(ID_statement, ID_assign);
4867 else if(t==TOK_PLUSASSIGN)
4868 exp.
set(ID_statement, ID_assign_plus);
4869 else if(t==TOK_MINUSASSIGN)
4870 exp.
set(ID_statement, ID_assign_minus);
4871 else if(t==TOK_MULTASSIGN)
4872 exp.
set(ID_statement, ID_assign_mult);
4873 else if(t==TOK_DIVASSIGN)
4874 exp.
set(ID_statement, ID_assign_div);
4875 else if(t==TOK_MODASSIGN)
4876 exp.
set(ID_statement, ID_assign_mod);
4877 else if(t==TOK_SHLASSIGN)
4878 exp.
set(ID_statement, ID_assign_shl);
4879 else if(t==TOK_SHRASSIGN)
4880 exp.
set(ID_statement, ID_assign_shr);
4881 else if(t==TOK_ANDASSIGN)
4882 exp.
set(ID_statement, ID_assign_bitand);
4883 else if(t==TOK_XORASSIGN)
4884 exp.
set(ID_statement, ID_assign_bitxor);
4885 else if(t==TOK_ORASSIGN)
4886 exp.
set(ID_statement, ID_assign_bitor);
4893 std::cout << std::string(__indent,
' ') <<
"Parser::rExpression 4\n";
4907 std::cout << std::string(__indent,
' ') <<
"Parser::rConditionalExpr 0\n";
4914 std::cout << std::string(__indent,
' ') <<
"Parser::rConditionalExpr 1\n";
4920 exprt then, otherwise;
4927 std::cout << std::string(__indent,
' ') <<
"Parser::rConditionalExpr 2\n";
4940 if_exprt(std::move(cond), std::move(then), std::move(otherwise),
typet());
4956 std::cout << std::string(__indent,
' ') <<
"Parser::rLogicalOrExpr 0\n";
4963 std::cout << std::string(__indent,
' ') <<
"Parser::rLogicalOrExpr 1\n";
4995 std::cout << std::string(__indent,
' ') <<
"Parser::rLogicalAndExpr 1\n";
5002 std::cout << std::string(__indent,
' ') <<
"Parser::rLogicalAndExpr 1\n";
5034 std::cout << std::string(__indent,
' ') <<
"Parser::rInclusiveOrExpr 0\n";
5041 std::cout << std::string(__indent,
' ') <<
"Parser::rInclusiveOrExpr 1\n";
5056 exp=
exprt(ID_bitor);
5073 std::cout << std::string(__indent,
' ') <<
"Parser::rExclusiveOrExpr 0\n";
5080 std::cout << std::string(__indent,
' ') <<
"Parser::rExclusiveOrExpr 1\n";
5089 if(!
rAndExpr(right, template_args))
5095 exp=
exprt(ID_bitxor);
5112 std::cout << std::string(__indent,
' ') <<
"Parser::rAndExpr 0\n";
5119 std::cout << std::string(__indent,
' ') <<
"Parser::rAndExpr 1\n";
5134 exp=
exprt(ID_bitand);
5151 std::cout << std::string(__indent,
' ') <<
"Parser::rEqualityExpr 0\n";
5158 std::cout << std::string(__indent,
' ') <<
"Parser::rEqualityExpr 1\n";
5174 exp=
exprt(tk.
kind==TOK_EQ?ID_equal:ID_notequal);
5191 std::cout << std::string(__indent,
' ') <<
"Parser::rRelationalExpr 0\n";
5198 std::cout << std::string(__indent,
' ') <<
"Parser::rRelationalExpr 1\n";
5204 (t==TOK_LE || t==TOK_GE || t==
'<' || (t==
'>' && !template_args)))
5220 case TOK_LE:
id=ID_le;
break;
5221 case TOK_GE:
id=ID_ge;
break;
5222 case '<':
id=ID_lt;
break;
5223 case '>':
id=ID_gt;
break;
5243 std::cout << std::string(__indent,
' ') <<
"Parser::rShiftExpr 0\n";
5250 std::cout << std::string(__indent,
' ') <<
"Parser::rShiftExpr 1\n";
5266 exp=
exprt((tk.
kind==TOK_SHIFTRIGHT)?ID_shr:ID_shl);
5283 std::cout << std::string(__indent,
' ') <<
"Parser::rAdditiveExpr 0\n";
5290 std::cout << std::string(__indent,
' ') <<
"Parser::rAdditiveExpr 1\n";
5309 case '+':
id=ID_plus;
break;
5310 case '-':
id=ID_minus;
break;
5330 std::cout << std::string(__indent,
' ') <<
"Parser::rMultiplyExpr 0\n";
5337 std::cout << std::string(__indent,
' ') <<
"Parser::rMultiplyExpr 1\n";
5341 while(t=
lex.
LookAhead(0), (t==
'*' || t==
'/' || t==
'%'))
5356 case '*':
id=ID_mult;
break;
5357 case '/':
id=ID_div;
break;
5358 case '%':
id=ID_mod;
break;
5367 std::cout << std::string(__indent,
' ') <<
"Parser::rMultiplyExpr 2\n";
5383 std::cout << std::string(__indent,
' ') <<
"Parser::rPmExpr 0\n";
5390 std::cout << std::string(__indent,
' ') <<
"Parser::rPmExpr 1\n";
5406 exp =
exprt(ID_pointer_to_member);
5412 std::cout << std::string(__indent,
' ') <<
"Parser::rPmExpr 2\n";
5427 std::cout << std::string(__indent,
' ') <<
"Parser::rCastExpr 0\n";
5443 std::cout << std::string(__indent,
' ') <<
"Parser::rCastExpr 1\n";
5464 exp=
exprt(
"explicit-typecast");
5487 std::cout << std::string(__indent,
' ') <<
"Parser::rTypeName 0\n";
5496 std::cout << std::string(__indent,
' ') <<
"Parser::rTypeName 1\n";
5516 std::cout << std::string(__indent,
' ') <<
"Parser::rTypeName 2\n";
5531 std::cout << std::string(__indent,
' ')
5532 <<
"Parser::rTypeNameOrFunctionType 0\n";
5540 std::cout << std::string(__indent,
' ')
5541 <<
"Parser::rTypeNameOrFunctionType 1\n";
5553 std::cout << std::string(__indent,
' ')
5554 <<
"Parser::rTypeNameOrFunctionType 2\n";
5562 std::cout << std::string(__indent,
' ')
5563 <<
"Parser::rTypeNameOrFunctionType 3\n";
5568 tname.
swap(return_type);
5577 std::cout << std::string(__indent,
' ')
5578 <<
"Parser::rTypeNameOrFunctionType 4\n";
5604 type.set(ID_identifier, op.data.get(ID_C_base_name));
5614 type.set(ID_identifier, op.data.get(ID_C_base_name));
5624 std::cout << std::string(__indent,
' ')
5625 <<
"Parser::rTypeNameOrFunctionType 5\n";
5631 else if(t==TOK_ELLIPSIS)
5635 type.make_ellipsis();
5644 parameter.
swap(parameter_declaration);
5645 type.parameters().push_back(parameter);
5653 else if(t==TOK_ELLIPSIS)
5659 type.make_ellipsis();
5667 std::cout << std::string(__indent,
' ')
5668 <<
"Parser::rTypeNameOrFunctionType 6\n";
5679 std::cout << std::string(__indent,
' ')
5680 <<
"Parser::rTypeNameOrFunctionType 7\n";
5690 std::cout << std::string(__indent,
' ')
5691 <<
"Parser::rTypeNameOrFunctionType 8\n";
5713 std::cout << std::string(__indent,
' ') <<
"Parser::rUnaryExpr 0\n";
5716 if(t==
'*' || t==
'&' || t==
'+' ||
5717 t==
'-' || t==
'!' || t==
'~' ||
5718 t==TOK_INCR || t==TOK_DECR)
5724 std::cout << std::string(__indent,
' ') <<
"Parser::rUnaryExpr 1\n";
5732 std::cout << std::string(__indent,
' ') <<
"Parser::rUnaryExpr 2\n";
5738 exp=
exprt(ID_dereference);
5742 exp=
exprt(ID_address_of);
5746 exp=
exprt(ID_unary_plus);
5750 exp=
exprt(ID_unary_minus);
5758 exp=
exprt(ID_bitnot);
5762 exp=
exprt(ID_side_effect);
5763 exp.
set(ID_statement, ID_preincrement);
5767 exp=
exprt(ID_side_effect);
5768 exp.
set(ID_statement, ID_predecrement);
5780 else if(t==TOK_SIZEOF)
5782 else if(t==TOK_ALIGNOF)
5784 else if(t==TOK_THROW)
5786 else if(t==TOK_NOEXCEPT)
5788 else if(t==TOK_REAL || t==TOK_IMAG)
5799 exp=
exprt(t==TOK_REAL?ID_complex_real:ID_complex_imag);
5820 std::cout << std::string(__indent,
' ') <<
"Parser::rThrowExpr 0\n";
5831 if(t==
':' || t==
';')
5859 std::cout << std::string(__indent,
' ') <<
"Parser::rTypeidExpr 0\n";
5881 exp =
exprt(ID_typeid);
5900 exp =
exprt(ID_typeid);
5925 std::cout << std::string(__indent,
' ') <<
"Parser::rSizeofExpr 0\n";
5943 exp=
exprt(ID_sizeof);
5944 exp.
add(ID_type_arg).
swap(tname);
5965 exp=
exprt(ID_sizeof);
5966 exp.
add(ID_type_arg).
swap(tname);
5980 exp=
exprt(ID_sizeof);
6009 exp=
exprt(ID_alignof);
6010 exp.
add(ID_type_arg).
swap(tname);
6025 std::cout << std::string(__indent,
' ') <<
"Parser::rNoexceptExpr 0\n";
6043 exp=
exprt(ID_noexcept);
6061 return t==TOK_NEW || t==TOK_DELETE;
6076 std::cout << std::string(__indent,
' ') <<
"Parser::rAllocateExpr 0\n";
6087 std::cout << std::string(__indent,
' ') <<
"Parser::rAllocateExpr 1\n";
6093 std::cout << std::string(__indent,
' ') <<
"Parser::rAllocateExpr 2\n";
6107 exp=
exprt(ID_side_effect);
6108 exp.
set(ID_statement, ID_cpp_delete_array);
6112 exp=
exprt(ID_side_effect);
6113 exp.
set(ID_statement, ID_cpp_delete);
6128 std::cout << std::string(__indent,
' ') <<
"Parser::rAllocateExpr 3\n";
6131 exp=
exprt(ID_side_effect);
6132 exp.
set(ID_statement, ID_cpp_new);
6135 exprt arguments, initializer;
6141 std::cout << std::string(__indent,
' ') <<
"Parser::rAllocateExpr 4\n";
6144 exp.
add(ID_initializer).
swap(initializer);
6276 decl.
swap(array_type);
6347 std::cout << std::string(__indent,
' ') <<
"Parser::rPostfixExpr 0\n";
6354 std::cout << std::string(__indent,
' ') <<
"Parser::rPostfixExpr 1\n";
6371 std::cout << std::string(__indent,
' ') <<
"Parser::rPostfixExpr 2\n";
6381 exp=
exprt(ID_index);
6389 std::cout << std::string(__indent,
' ') <<
"Parser::rPostfixExpr 3\n";
6400 std::cout << std::string(__indent,
' ') <<
"Parser::rPostfixExpr 4\n";
6410 fc.arguments().push_back(*it);
6443 std::cout << std::string(__indent,
' ') <<
"Parser::rPostfixExpr 5\n";
6450 std::cout << std::string(__indent,
' ') <<
"Parser::rPostfixExpr 6\n";
6458 exp=
exprt(ID_member);
6460 exp=
exprt(ID_ptrmember);
6466 exp.
add(ID_component_cpp_name).
swap(e);
6502 expr=
exprt(ID_msc_uuidof);
6503 expr.
add(ID_type_arg).
swap(tname);
6520 expr=
exprt(ID_msc_uuidof);
6537 if(tk1.
kind!=TOK_MSC_IF_EXISTS &&
6538 tk1.
kind!=TOK_MSC_IF_NOT_EXISTS)
6566 tk1.
kind==TOK_MSC_IF_EXISTS?ID_msc_if_exists:
6567 ID_msc_if_not_exists);
6582 if(tk1.
kind != TOK_MSC_IF_EXISTS && tk1.
kind != TOK_MSC_IF_NOT_EXISTS)
6606 block.
add(std::move(*statement));
6615 tk1.
kind == TOK_MSC_IF_EXISTS ? ID_msc_if_exists : ID_msc_if_not_exists);
6621 return std::move(code);
6640 typet tname1, tname2;
6644 case TOK_UNARY_TYPE_PREDICATE:
6651 expr.
add(ID_type_arg).
swap(tname1);
6654 case TOK_BINARY_TYPE_PREDICATE:
6665 expr.
add(
"type_arg1").
swap(tname1);
6666 expr.
add(
"type_arg2").
swap(tname2);
6699 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 0 "
6712 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 1\n";
6721 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 2\n";
6727 exp=
exprt(
"cpp-this");
6730 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 3\n";
6739 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 4\n";
6748 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 5\n";
6758 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 6\n";
6764 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 7\n";
6772 exp =
exprt(ID_side_effect);
6773 exp.
set(ID_statement, ID_statement_expression);
6791 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 8\n";
6801 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 9\n";
6807 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 10\n";
6814 case TOK_UNARY_TYPE_PREDICATE:
6815 case TOK_BINARY_TYPE_PREDICATE:
6817 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 11\n";
6821 case TOK_MSC_UUIDOF:
6823 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 12\n";
6829 case TOK_MSC_IF_EXISTS:
6830 case TOK_MSC_IF_NOT_EXISTS:
6832 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 13\n";
6838 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 14\n";
6847 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 15\n";
6860 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 16\n";
6870 exp=
exprt(
"explicit-constructor-call");
6886 exp=
exprt(
"explicit-constructor-call");
6910 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 17\n";
6931 std::cout << std::string(__indent,
' ') <<
"Parser::rVarName 0\n";
6944 std::cout << std::string(__indent,
' ') <<
"Parser::rVarNameCore 0\n";
6954 name.
set(ID_typename,
true);
6964 std::cout << std::string(__indent,
' ') <<
"Parser::rVarNameCore 1\n";
6972 std::cout << std::string(__indent,
' ') <<
"Parser::rVarNameCore 1.1 "
6982 std::cout << std::string(__indent,
' ') <<
"Parser::rVarNameCore 2\n";
6990 case TOK_GCC_IDENTIFIER:
6991 case TOK_MSC_IDENTIFIER:
6993 std::cout << std::string(__indent,
' ') <<
"Parser::rVarNameCore 3\n";
7006 std::cout << std::string(__indent,
' ') <<
"Parser::rVarNameCore 4\n";
7016 components.push_back(
irept(ID_template_args));
7017 components.back().add(ID_arguments).swap(args);
7026 std::cout << std::string(__indent,
' ') <<
"Parser::rVarNameCore 5\n";
7030 components.push_back(
irept(
"::"));
7036 std::cout << std::string(__indent,
' ') <<
"Parser::rVarNameCore 6\n";
7044 components.push_back(
irept(
"~"));
7050 std::cout << std::string(__indent,
' ') <<
"Parser::rVarNameCore 7\n";
7055 components.push_back(
irept(ID_operator));
7063 components.push_back(op);
7078 if(
is_identifier(t) || t ==
'~' || t == TOK_OPERATOR || t == TOK_TEMPLATE)
7097 std::cout << std::string(__indent,
' ') <<
"Parser::maybeTemplateArgs 0\n";
7106 if(u==
'\0' || u==
';' || u==
'}')
7108 else if((u==
'>' || u==TOK_SHIFTRIGHT) &&
7119 std::cout << std::string(__indent,
' ')
7120 <<
"Parser::maybeTemplateArgs 1\n";
7126 std::cout << std::string(__indent,
' ')
7127 <<
"Parser::maybeTemplateArgs 2\n";
7142 std::cout << std::string(__indent,
' ')
7143 <<
"Parser::maybeTemplateArgs 3\n";
7150 else if(v==
'\0' || v==
';' || v==
'}')
7154 else if(u==
'\0' || u==
';' || u==
'}')
7156 else if(u==TOK_SHIFTRIGHT && n>=2)
7160 std::cout << std::string(__indent,
' ')
7161 <<
"Parser::maybeTemplateArgs 4\n";
7166 std::cout << std::string(__indent,
' ') <<
"Parser::maybeTemplateArgs 5\n";
7172 std::cout << std::string(__indent,
' ') <<
"Parser::maybeTemplateArgs 6\n";
7175 return t==TOK_SCOPE || t==
'(';
7180 std::cout << std::string(__indent,
' ') <<
"Parser::maybeTemplateArgs 7\n";
7211 declarator.
value()=body;
7221 declarator.
value() = std::move(*body);
7244 std::cout << std::string(__indent,
' ') <<
"Parser::rCompoundStatement 1\n";
7251 std::cout << std::string(__indent,
' ') <<
"Parser::rCompoundStatement 2\n";
7260 statement.
add(std::move(*statement2));
7268 return std::move(statement);
7275 return std::move(statement);
7306 std::cout << std::string(__indent,
' ') <<
"Parser::rStatement 0 "
7347 codet statement(k == TOK_BREAK ? ID_break : ID_continue);
7353 return std::move(statement);
7358 std::cout << std::string(__indent,
' ') <<
"Parser::rStatement RETURN 0\n";
7369 std::cout << std::string(__indent,
' ')
7370 <<
"Parser::rStatement RETURN 1\n";
7377 std::cout << std::string(__indent,
' ')
7378 <<
"Parser::rStatement RETURN 2\n";
7385 std::cout << std::string(__indent,
' ')
7386 <<
"Parser::rStatement RETURN 3\n";
7393 return std::move(statement);
7408 return std::move(statement);
7434 std::move(case_expr), std::move(range_end), std::move(*statement2));
7436 return std::move(code);
7449 std::move(case_expr), std::move(*statement2));
7451 return std::move(statement);
7470 return std::move(statement);
7482 case TOK_MSC_IF_EXISTS:
7483 case TOK_MSC_IF_NOT_EXISTS:
7486 case TOK_GCC_IDENTIFIER:
7487 case TOK_MSC_IDENTIFIER:
7499 return std::move(label);
7517 return std::move(statement);
7528 case TOK_STATIC_ASSERT:
7535 codet statement(ID_static_assert);
7537 statement.
operands().swap(cpp_static_assert.operands());
7539 return std::move(statement);
7569 if(!then.has_value())
7579 std::move(exp), std::move(*then), std::move(*otherwise));
7581 return std::move(statement);
7590 return std::move(statement);
7617 code_switcht statement(std::move(exp), std::move(*body));
7619 return std::move(statement);
7648 code_whilet statement(std::move(exp), std::move(*body));
7650 return std::move(statement);
7668 if(!body.has_value())
7689 return std::move(statement);
7709 if(!exp1.has_value())
7739 std::move(*exp1), std::move(exp2), std::move(exp3), std::move(*body));
7741 return std::move(statement);
7763 if(!try_body.has_value())
7786 codet ellipsis(ID_ellipsis);
7788 catch_op = std::move(ellipsis);
7799 declaration.
declarators().size() == 1,
"exactly one declarator");
7801 if(declaration.
declarators().front().name().is_nil())
7808 catch_op = std::move(code_decl);
7827 return std::move(statement);
7842 if(!body1.has_value())
7847 codet statement(ID_msc_try_except);
7867 std::move(*body1), std::move(exp), std::move(*body2));
7868 return std::move(statement);
7875 codet statement(ID_msc_try_finally);
7883 return std::move(statement);
7902 codet statement(ID_msc_leave);
7905 return std::move(statement);
7914 std::cout << std::string(__indent,
' ') <<
"Parser::rGCCAsmStatement 1\n";
7929 std::cout << std::string(__indent,
' ') <<
"Parser::rGCCAsmStatement 3\n";
7940 std::cout << std::string(__indent,
' ') <<
"Parser::rGCCAsmStatement 3\n";
7946 std::cout << std::string(__indent,
' ') <<
"Parser::rGCCAsmStatement 4\n";
7967 std::cout << std::string(__indent,
' ')
7968 <<
"Parser::rGCCAsmStatement 5\n";
7976 std::cout << std::string(__indent,
' ')
7977 <<
"Parser::rGCCAsmStatement 6\n";
7992 std::cout << std::string(__indent,
' ') <<
"Parser::rGCCAsmStatement 7\n";
8001 std::cout << std::string(__indent,
' ') <<
"Parser::rGCCAsmStatement 8\n";
8004 return std::move(statement);
8013 std::cout << std::string(__indent,
' ') <<
"Parser::rMSCAsmStatement 1\n";
8027 std::cout << std::string(__indent,
' ') <<
"Parser::rMSCAsmStatement 2\n";
8035 std::cout << std::string(__indent,
' ') <<
"Parser::rMSCAsmStatement 3\n";
8048 std::cout << std::string(__indent,
' ') <<
"Parser::rMSCAsmStatement 4\n";
8054 std::cout << std::string(__indent,
' ') <<
"Parser::rMSCAsmStatement 5\n";
8058 return std::move(statement);
8064 std::cout << std::string(__indent,
' ') <<
"Parser::rMSCAsmStatement 6\n";
8069 std::cout << std::string(__indent,
' ') <<
"Parser::rMSCAsmStatement 7\n";
8072 return std::move(statement);
8089 std::cout << std::string(__indent,
' ') <<
"Parser::rExprStatement 0\n";
8095 std::cout << std::string(__indent,
' ') <<
"Parser::rExprStatement 1\n";
8101 return std::move(statement);
8106 std::cout << std::string(__indent,
' ') <<
"Parser::rExprStatement 2\n";
8114 std::cout << std::string(__indent,
' ') <<
"rDe " << statement->pretty()
8126 std::cout << std::string(__indent,
' ') <<
"Parser::rExprStatement 3\n";
8133 std::cout << std::string(__indent,
' ') <<
"Parser::rExprStatement 4\n";
8137 std::cout << std::string(__indent,
' ') <<
"Parser::rExprStatement 5 "
8145 std::cout << std::string(__indent,
' ') <<
"Parser::rExprStatement 6\n";
8150 return std::move(expr_statement);
8165 statement=
codet(ID_decl);
8197 typet cv_q, integral;
8202 std::cout << std::string(__indent,
' ')
8203 <<
"Parser::rDeclarationStatement 1\n";
8225 std::cout << std::string(__indent,
' ')
8226 <<
"Parser::rDeclarationStatement 2\n";
8236 std::cout << std::string(__indent,
' ')
8237 <<
"Parser::rDeclarationStatement 3 " << t <<
'\n';
8245 std::cout << std::string(__indent,
' ')
8246 <<
"Parser::rDeclarationStatement 4\n";
8286 return std::move(statement);
8299 return std::move(statement);
8315 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclStatement 1\n";
8318 if(!
rName(type_name))
8322 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclStatement 2\n";
8329 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclStatement 3\n";
8335 declaration.
type().
swap(type_name);
8342 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclStatement 4\n";
8351 return std::move(statement);
8366 if(t==token || t==
'\0')
ansi_c_parsert ansi_c_parser
pointer_typet pointer_type(const typet &subtype)
bool optCvQualify(typet &)
bool rDeclaratorQualifier()
bool rShiftExpr(exprt &, bool)
optionalt< codet > rStatement()
bool rPostfixExpr(exprt &)
bool rIntegralDeclaration(cpp_declarationt &, cpp_storage_spect &, cpp_member_spect &, typet &, typet &)
bool MaybeTypeNameOrClassTemplate(cpp_tokent &)
bool rClassMember(cpp_itemt &)
bool rDefinition(cpp_itemt &)
bool rTypedefUsing(cpp_declarationt &)
bool rAllocateExpr(exprt &)
bool rMSC_if_existsExpr(exprt &)
bool rBaseSpecifiers(irept &)
bool rPtrToMember(irept &)
bool optMemberSpec(cpp_member_spect &)
void make_sub_scope(const irept &name, new_scopet::kindt)
bool rLinkageBody(cpp_linkage_spect::itemst &)
bool rTypePredicate(exprt &)
bool rAndExpr(exprt &, bool)
bool optPtrOperator(typet &)
Parser(cpp_parsert &_cpp_parser)
bool rLogicalAndExpr(exprt &, bool)
bool rExpression(exprt &, bool)
optionalt< codet > rTypedefStatement()
bool rString(cpp_tokent &tk)
bool rOtherDeclaration(cpp_declarationt &, cpp_storage_spect &, cpp_member_spect &, typet &)
optionalt< codet > rWhileStatement()
bool optAttribute(typet &)
bool rAdditiveExpr(exprt &)
bool rMemberInit(exprt &)
optionalt< codet > rExprStatement()
bool rConstDeclaration(cpp_declarationt &)
bool rSimpleDeclaration(cpp_declarationt &)
bool rInclusiveOrExpr(exprt &, bool)
bool rAllocateInitializer(exprt &)
bool rPrimaryExpr(exprt &)
bool rStaticAssert(cpp_static_assertt &)
optionalt< codet > rDoStatement()
bool rArgDeclListOrInit(exprt &, bool &, bool)
bool rNewDeclarator(typet &)
void make_subtype(const typet &src, typet &dest)
optionalt< codet > rIntegralDeclStatement(cpp_storage_spect &, typet &, typet &)
optionalt< codet > rTryStatement()
bool rAccessDecl(cpp_declarationt &)
optionalt< codet > rDeclarationStatement()
bool rRelationalExpr(exprt &, bool)
bool rNoexceptExpr(exprt &)
bool rNamespaceSpec(cpp_namespace_spect &)
bool rArgDeclaration(cpp_declarationt &)
optionalt< codet > rCompoundStatement()
new_scopet & add_id(const irept &name, new_scopet::kindt)
bool rVarNameCore(exprt &)
bool rDeclarators(cpp_declarationt::declaratorst &, bool, bool=false)
bool rLinkageSpec(cpp_linkage_spect &)
bool rDeclarator(cpp_declaratort &, DeclKind, bool, bool)
bool rAllocateType(exprt &, typet &, exprt &)
bool rTypeSpecifier(typet &, bool)
bool optThrowDecl(irept &)
bool rExclusiveOrExpr(exprt &, bool)
optionalt< codet > rIfStatement()
bool rEqualityExpr(exprt &, bool)
bool rCommaExpression(exprt &)
bool rGCCAttribute(typet &)
bool rTempArgList(irept &)
optionalt< codet > rMSC_leaveStatement()
bool rArgDeclList(irept &)
bool rMultiplyExpr(exprt &)
optionalt< codet > rMSC_if_existsStatement()
optionalt< codet > rMSCAsmStatement()
bool rTypedef(cpp_declarationt &)
bool rTemplateArgs(irept &)
bool rSizeofExpr(exprt &)
optionalt< codet > rGCCAsmStatement()
bool rTypeNameOrFunctionType(typet &)
bool rMemberInitializers(irept &)
bool rDeclaratorWithInit(cpp_declaratort &, bool, bool)
optionalt< codet > rForStatement()
bool rFunctionArguments(exprt &)
optionalt< codet > rOtherDeclStatement(cpp_storage_spect &, typet &)
irep_idt current_function
new_scopet * current_scope
bool optIntegralTypeOrClassSpec(typet &)
bool rTempArgDeclaration(cpp_declarationt &)
bool rLogicalOrExpr(exprt &, bool)
bool rProgram(cpp_itemt &item)
optionalt< codet > rSwitchStatement()
bool rTemplateDecl2(typet &, TemplateDeclKind &kind)
bool rTypeidExpr(exprt &)
void merge_types(const typet &src, typet &dest)
bool rAlignofExpr(exprt &)
optionalt< codet > rMSC_tryStatement()
bool rCastOperatorName(irept &)
bool rInitializeExpr(exprt &)
bool rFunctionBody(cpp_declaratort &)
bool optStorageSpec(cpp_storage_spect &)
bool rDeclaration(cpp_declarationt &)
bool rUsing(cpp_usingt &)
void set_location(irept &dest, const cpp_tokent &token)
std::size_t number_of_errors
bool rOperatorName(irept &)
bool rExternTemplateDecl(cpp_declarationt &)
bool rNullDeclaration(cpp_declarationt &)
bool rTemplateDecl(cpp_declarationt &)
bool rConstructorDecl(cpp_declaratort &, typet &, typet &trailing_return_type)
bool rConditionalExpr(exprt &, bool)
codet representation of an inline assembler statement, for the gcc flavor.
codet representation of an inline assembler statement.
void set_flavor(const irep_idt &f)
A codet representing sequential composition of program statements.
code_operandst & statements()
void add(const codet &code)
codet representation of a do while statement.
codet representation of an expression statement.
codet representation of a for statement.
A codet representing the declaration of a local variable.
codet representation of a "return from a function" statement.
const exprt & return_value() const
codet representation of a switch-case, i.e. a case statement within a switch.
codet representation of a goto statement.
codet representation of an if-then-else statement.
codet representation of a label for branch targets.
A codet representing a skip statement.
codet representation of a switch-case, i.e. a case statement within a switch.
codet representing a switch statement.
codet representation of a try/catch block.
codet representing a while statement.
Data structure for representing an arbitrary statement in a program.
const declaratorst & declarators() const
const cpp_member_spect & member_spec() const
const cpp_storage_spect & storage_spec() const
std::vector< cpp_declaratort > declaratorst
void set_is_parameter(bool is_parameter)
irept & member_initializers()
irept & method_qualifier()
cpp_static_assertt & make_static_assert()
cpp_linkage_spect & make_linkage_spec()
cpp_namespace_spect & make_namespace_spec()
cpp_usingt & make_using()
cpp_declarationt & make_declaration()
std::vector< class cpp_itemt > itemst
const itemst & items() const
void set_inline(bool value)
void set_virtual(bool value)
void set_friend(bool value)
void set_explicit(bool value)
const itemst & items() const
void set_namespace(const irep_idt &_namespace)
void set_is_inline(bool value)
const exprt & as_expr() const
irep_idt get_base_name() const
cpp_parse_treet parse_tree
int LookAhead(unsigned offset)
int get_token(cpp_tokent &token)
void Replace(const cpp_tokent &token)
cpp_tokent & current_token()
void Insert(const cpp_tokent &token)
void set_namespace(bool value)
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Base class for all expressions.
typet & type()
Return the type of the expression.
const source_locationt & source_location() const
source_locationt & add_source_location()
void add_to_operands(const exprt &expr)
Add the given argument to the end of exprt's operands.
The Boolean constant false.
The trinary if-then-else operator.
There are a large number of kinds of tree structured or tree-like data in CPROVER.
std::string pretty(unsigned indent=0, unsigned max_indent=0) const
const irept & find(const irep_idt &name) const
const irep_idt & get(const irep_idt &name) const
void set(const irep_idt &name, const irep_idt &value)
void move_to_sub(irept &irep)
const irep_idt & id() const
irept & add(const irep_idt &name)
holds a combination of types
source_locationt source_location
void print_rec(std::ostream &, unsigned indent) const
std::string full_name() const
std::map< irep_idt, new_scopet > id_mapt
@ TYPE_TEMPLATE_PARAMETER
@ TEMPLATE_TEMPLATE_PARAMETER
@ NON_TYPE_TEMPLATE_PARAMETER
void print(std::ostream &out) const
bool is_named_scope() const
static const char * kind2string(kindt kind)
The null pointer constant.
save_scopet(new_scopet *&_scope)
A side_effect_exprt representation of a function call side effect.
exprt::operandst & arguments()
A side_effect_exprt representation of a side effect that throws an exception.
An expression containing a side effect.
void set_file(const irep_idt &file)
void set_line(const irep_idt &line)
void set_function(const irep_idt &function)
Expression to hold a symbol (variable)
The Boolean constant true.
void move_to_subtypes(typet &type)
Move the provided type to the subtypes of this type.
Type with a single subtype.
const typet & subtype() const
Semantic type conversion.
The type of an expression, extends irept.
source_locationt & add_source_location()
bool has_subtypes() const
const source_locationt & source_location() const
C++ Language Type Checking.
cpp_namet & to_cpp_name(irept &cpp_name)
C++ Parser: Token Buffer.
static bool is_operator(const ctokent &t)
#define Forall_operands(it, expr)
std::string get_base_name(const std::string &in, bool strip_suffix)
cleans a filename from path and extension
const irept & get_nil_irep()
const std::string & id2string(const irep_idt &d)
static bool is_constructor(const irep_idt &method_name)
const merged_typet & to_merged_type(const typet &type)
conversion to merged_typet
nonstd::optional< T > optionalt
static bool is_identifier(int token)
#define UNREACHABLE
This should be used to mark dead code.
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
const code_blockt & to_code_block(const codet &code)
const type_with_subtypest & to_type_with_subtypes(const typet &type)
const type_with_subtypet & to_type_with_subtype(const typet &type)