19 #include <ansi-c/ansi_c_y.tab.h>
29 static 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),
204 config.cpp.cpp_standard ==
configt::cppt::cpp_standardt::CPP11 ||
205 config.cpp.cpp_standard ==
configt::cppt::cpp_standardt::CPP14 ||
206 config.cpp.cpp_standard ==
configt::cppt::cpp_standardt::CPP17)
282 typet &trailing_return_type);
404 if(p->
id()==ID_merged_type)
407 p = &merged_type.last_type();
422 return token == TOK_GCC_IDENTIFIER || token == TOK_MSC_IDENTIFIER;
429 if(cpp_name.
get_sub().size()==1 &&
430 cpp_name.
get_sub().front().id()==ID_name)
431 id=cpp_name.
get_sub().front().get(ID_identifier);
478 if(dest.
id()!=ID_merged_type)
491 sub.emplace(sub.begin(), src);
497 #define ERROR_TOKENS 4
507 source_location.
set_file(t[0].filename);
510 std::string message =
"parse error before '";
523 log.error().source_location = source_location;
566 std::cout << std::string(__indent,
' ') <<
"Parser::rDefinition 1 " << t
572 else if(t==TOK_TYPEDEF)
574 else if(t==TOK_TEMPLATE)
578 else if(t==TOK_EXTERN &&
lex.
LookAhead(1)==TOK_TEMPLATE)
580 else if(t==TOK_NAMESPACE)
582 else if(t==TOK_INLINE &&
lex.
LookAhead(1)==TOK_NAMESPACE)
590 else if(t==TOK_USING)
592 else if(t==TOK_STATIC_ASSERT)
623 std::cout << std::string(__indent,
' ') <<
"Parser::rTypedef 1\n";
652 std::cout << std::string(__indent,
' ') <<
"Parser::rTypedefUsing 1\n";
668 std::cout << std::string(__indent,
' ') <<
"Parser::rTypedefUsing 2\n";
685 std::cout << std::string(__indent,
' ') <<
"Parser::rTypedefUsing 3\n";
709 std::cout << std::string(__indent,
' ') <<
"Parser::rTypeSpecifier 0\n";
720 std::cout << std::string(__indent,
' ') <<
"Parser::rTypeSpecifier 0.1\n";
732 std::cout << std::string(__indent,
' ') <<
"Parser::rTypeSpecifier 1\n";
740 std::cout << std::string(__indent,
' ') <<
"Parser::rTypeSpecifier 2\n";
748 std::cout << std::string(__indent,
' ') <<
"Parser::rTypeSpecifier 3\n";
757 std::cout << std::string(__indent,
' ') <<
"Parser::rTypeSpecifier 4\n";
769 return is_identifier(t) || t == TOK_SCOPE || t == TOK_CONSTEXPR ||
770 t == TOK_CONST || t == TOK_VOLATILE || t == TOK_RESTRICT ||
771 t == TOK_CHAR || t == TOK_INT || t == TOK_SHORT || t == TOK_LONG ||
772 t == TOK_CHAR16_T || t == TOK_CHAR32_T || t == TOK_WCHAR_T ||
774 || t == TOK_SIGNED || t == TOK_UNSIGNED || t == TOK_FLOAT ||
775 t == TOK_DOUBLE || t == TOK_INT8 || t == TOK_INT16 || t == TOK_INT32 ||
776 t == TOK_INT64 || t == TOK_GCC_INT128 || t == TOK_PTR32 ||
777 t == TOK_PTR64 || t == TOK_GCC_FLOAT80 || t == TOK_GCC_FLOAT128 ||
778 t == TOK_VOID || t == TOK_BOOL || t == TOK_CPROVER_BOOL ||
779 t == TOK_CLASS || t == TOK_STRUCT || t == TOK_UNION || t == TOK_ENUM ||
780 t == TOK_INTERFACE || t == TOK_TYPENAME || t == TOK_TYPEOF ||
781 t == TOK_DECLTYPE || t == TOK_UNDERLYING_TYPE;
816 linkage_spec.
items().push_back(item);
832 bool is_inline=
false;
849 name=tk2.
data.
get(ID_C_base_name);
973 items.push_back(item);
977 items.push_back(item);
1009 typet template_type;
1028 std::cout << std::string(__indent,
' ') <<
"BODY: "
1029 << body.
pretty() <<
'\n';
1030 std::cout << std::string(__indent,
' ') <<
"TEMPLATE_TYPE: "
1031 << template_type.
pretty() <<
'\n';
1033 body.
add(ID_template_type).
swap(template_type);
1034 body.
set(ID_is_template,
true);
1044 body.
add(ID_template_type).
swap(template_type);
1045 body.
set(ID_is_template,
true);
1065 decl=
typet(ID_template);
1078 irept &template_parameters=decl.
add(ID_template_parameters);
1102 if(template_parameters.
get_sub().empty())
1127 args.
get_sub().back().swap(a);
1138 args.
get_sub().back().swap(a);
1155 std::cout << std::string(__indent,
' ') <<
"Parser::rTempArgDeclaration 0\n";
1160 if((t0==TOK_CLASS || t0==TOK_TYPENAME))
1170 declaration.
set(ID_is_type,
true);
1171 declaration.
type()=
typet(
"cpp-template-type");
1181 bool has_ellipsis=
false;
1230 std::cout << std::string(__indent,
' ') <<
"Parser::rTempArgDeclaration 1\n";
1233 if(t0==TOK_TEMPLATE)
1237 typet template_type;
1267 std::cout << std::string(__indent,
' ')
1268 <<
"Parser::rTempArgDeclaration 2\n";
1272 declaration.
set(ID_is_type,
false);
1278 std::cout << std::string(__indent,
' ')
1279 <<
"Parser::rTempArgDeclaration 3\n";
1282 bool has_ellipsis=
false;
1299 std::cout << std::string(__indent,
' ')
1300 <<
"Parser::rTempArgDeclaration 4\n";
1386 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclaration 0.1 token: "
1398 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclaration 0.2\n";
1406 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclaration 1\n";
1414 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclaration 3\n";
1417 typet cv_q, integral;
1435 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclaration 4\n";
1449 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclaration 5\n";
1453 declaration, storage_spec, member_spec, integral, cv_q);
1460 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclaration 6 " << t
1479 typet cv_q, integral;
1505 integral.
swap(cv_q);
1544 std::cout << std::string(__indent,
' ')
1545 <<
"Parser::rIntegralDeclaration 1 token: "
1553 std::cout << std::string(__indent,
' ') <<
"Parser::rIntegralDeclaration 2\n";
1559 std::cout << std::string(__indent,
' ') <<
"Parser::rIntegralDeclaration 3\n";
1572 std::cout << std::string(__indent,
' ')
1573 <<
"Parser::rIntegralDeclaration 4\n";
1581 std::cout << std::string(__indent,
' ')
1582 <<
"Parser::rIntegralDeclaration 5\n";
1602 std::cout << std::string(__indent,
' ') <<
"Parser::rIntegralDeclaration 6 "
1611 declaration.
type().
id() == ID_auto &&
1613 declaration.
declarators().front().type().id() == ID_function_type &&
1614 declaration.
declarators().front().type().add_subtype().is_not_nil())
1616 declaration.
type() =
1619 declaration.
declarators().front().type().add_subtype().make_nil();
1623 std::cout << std::string(__indent,
' ')
1624 <<
"Parser::rIntegralDeclaration 7\n";
1630 std::cout << std::string(__indent,
' ')
1631 <<
"Parser::rIntegralDeclaration 8 "
1632 << declaration.
pretty() <<
'\n';
1640 std::cout << std::string(__indent,
' ')
1641 <<
"Parser::rIntegralDeclaration 9\n";
1651 std::cout << std::string(__indent,
' ')
1652 <<
"Parser::rIntegralDeclaration 10\n";
1664 std::cout << std::string(__indent,
' ') <<
"Parser::rConstDeclaration\n";
1689 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 1\n";
1692 if(!
rName(type_name))
1698 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 2\n";
1712 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 3\n";
1721 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 4\n";
1726 for(std::size_t i=0; i < type_name.
get_sub().size(); i++)
1728 if(type_name.
get_sub()[i].id() == ID_operator)
1739 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 5\n";
1743 typet type = type_name;
1747 typet trailing_return_type;
1749 conv_operator_declarator, type_name, trailing_return_type))
1752 type_name=
typet(
"cpp-cast-operator");
1754 declaration.
declarators().push_back(conv_operator_declarator);
1759 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 6\n";
1764 bool is_destructor=
false;
1765 for(
const auto &irep : type_name.
get_sub())
1767 if(irep.id() ==
"~")
1775 typet trailing_return_type;
1777 constructor_declarator, type_name, trailing_return_type))
1781 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 7\n";
1786 type_name=trailing_return_type;
1788 type_name=
typet(is_destructor?ID_destructor:ID_constructor);
1790 declaration.
declarators().push_back(constructor_declarator);
1795 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 8\n";
1813 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 9\n";
1825 declaration.
type().
swap(type_name);
1830 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 10\n";
1836 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 11\n";
1845 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 12\n";
1869 std::cout << std::string(__indent,
' ') <<
"Parser::isConstructorDecl "
1878 if(t==
'*' || t==
'&' || t==
'(')
1880 else if(t==TOK_STDCALL || t==TOK_FASTCALL || t==TOK_CLRCALL || t==TOK_CDECL)
1931 else if(v==
'\0' || v==
';' || v==
'}')
1935 else if(u==
'\0' || u==
';' || u==
'}')
1960 member_spec.
clear();
1965 t == TOK_FRIEND || t == TOK_INLINE || t == TOK_VIRTUAL ||
1966 t == TOK_EXPLICIT || t == TOK_MSC_FORCEINLINE)
1974 case TOK_MSC_FORCEINLINE:
1977 case TOK_VIRTUAL: member_spec.
set_virtual(
true);
break;
1978 case TOK_FRIEND: member_spec.
set_friend(
true);
break;
1979 case TOK_EXPLICIT: member_spec.
set_explicit(
true);
break;
1998 t == TOK_STATIC || t == TOK_EXTERN || (t == TOK_AUTO && !
cpp11) ||
1999 t == TOK_REGISTER || t == TOK_MUTABLE || t == TOK_GCC_ASM ||
2000 t == TOK_THREAD_LOCAL)
2007 case TOK_STATIC: storage_spec.
set_static();
break;
2008 case TOK_EXTERN: storage_spec.
set_extern();
break;
2009 case TOK_AUTO: storage_spec.
set_auto();
break;
2011 case TOK_MUTABLE: storage_spec.
set_mutable();
break;
2012 case TOK_GCC_ASM: storage_spec.
set_asm();
break;
2031 if(t==TOK_CONSTEXPR ||
2032 t==TOK_CONST || t==TOK_VOLATILE || t==TOK_RESTRICT ||
2033 t==TOK_PTR32 || t==TOK_PTR64 ||
2034 t==TOK_GCC_ATTRIBUTE || t==TOK_GCC_ASM)
2043 p=
typet(ID_constexpr);
2055 p=
typet(ID_volatile);
2061 p=
typet(ID_restrict);
2078 case TOK_GCC_ATTRIBUTE:
2134 exp.add(ID_type_arg).swap(tname);
2137 typet attr(ID_aligned);
2156 typet attr(ID_aligned);
2172 std::cout << std::string(__indent,
' ') <<
"Parser::rGCCAttribute "
2189 case TOK_GCC_ATTRIBUTE_PACKED:
2191 typet attr(ID_packed);
2197 case TOK_GCC_ATTRIBUTE_TRANSPARENT_UNION:
2199 typet attr(ID_transparent_union);
2205 case TOK_GCC_ATTRIBUTE_VECTOR_SIZE:
2221 attr.add_source_location()=
exp.source_location();
2226 case TOK_GCC_ATTRIBUTE_ALIGNED:
2228 typet attr(ID_aligned);
2252 case TOK_GCC_ATTRIBUTE_MODE:
2266 typet attr(ID_gcc_attribute_mode);
2273 case TOK_GCC_ATTRIBUTE_GNU_INLINE:
2275 typet attr(ID_static);
2281 case TOK_GCC_ATTRIBUTE_WEAK:
2283 typet attr(ID_weak);
2289 case TOK_GCC_ATTRIBUTE_ALIAS:
2302 typet attr(ID_alias);
2309 case TOK_GCC_ATTRIBUTE_SECTION:
2322 typet attr(ID_section);
2329 case TOK_GCC_ATTRIBUTE_NORETURN:
2331 typet attr(ID_noreturn);
2337 case TOK_GCC_ATTRIBUTE_CONSTRUCTOR:
2339 typet attr(ID_constructor);
2345 case TOK_GCC_ATTRIBUTE_DESTRUCTOR:
2347 typet attr(ID_destructor);
2399 typet attr(ID_noreturn);
2426 std::cout << std::string(__indent,
' ')
2427 <<
"Parser::optIntegralTypeOrClassSpec 0\n";
2437 bool is_integral=
false;
2447 std::cout << std::string(__indent,
' ')
2448 <<
"Parser::optIntegralTypeOrClassSpec 1\n";
2455 case TOK_CHAR: type_id=ID_char;
break;
2456 case TOK_CHAR16_T: type_id=ID_char16_t;
break;
2457 case TOK_CHAR32_T: type_id=ID_char32_t;
break;
2458 case TOK_INT: type_id=ID_int;
break;
2459 case TOK_SHORT: type_id=ID_short;
break;
2460 case TOK_LONG: type_id=ID_long;
break;
2461 case TOK_SIGNED: type_id=ID_signed;
break;
2462 case TOK_WCHAR_T: type_id=ID_wchar_t;
break;
2463 case TOK_COMPLEX: type_id=ID_complex;
break;
2464 case TOK_UNSIGNED: type_id=ID_unsigned;
break;
2465 case TOK_FLOAT: type_id=ID_float;
break;
2466 case TOK_DOUBLE: type_id=ID_double;
break;
2467 case TOK_VOID: type_id=ID_void;
break;
2468 case TOK_INT8: type_id=ID_int8;
break;
2469 case TOK_INT16: type_id=ID_int16;
break;
2470 case TOK_INT32: type_id=ID_int32;
break;
2471 case TOK_INT64: type_id=ID_int64;
break;
2472 case TOK_GCC_INT128: type_id=ID_gcc_int128;
break;
2473 case TOK_GCC_FLOAT80: type_id=ID_gcc_float80;
break;
2474 case TOK_GCC_FLOAT128: type_id=ID_gcc_float128;
break;
2476 type_id = ID_c_bool;
2478 case TOK_CPROVER_BOOL: type_id=ID_proper_bool;
break;
2479 case TOK_AUTO: type_id = ID_auto;
break;
2483 if(!type_id.
empty())
2500 std::cout << std::string(__indent,
' ')
2501 <<
"Parser::optIntegralTypeOrClassSpec 2\n";
2508 std::cout << std::string(__indent,
' ')
2509 <<
"Parser::optIntegralTypeOrClassSpec 3\n";
2512 if(t==TOK_CLASS || t==TOK_STRUCT || t==TOK_UNION || t==TOK_INTERFACE)
2514 else if(t==TOK_ENUM)
2516 else if(t==TOK_TYPEOF)
2519 std::cout << std::string(__indent,
' ')
2520 <<
"Parser::optIntegralTypeOrClassSpec 4\n";
2527 std::cout << std::string(__indent,
' ')
2528 <<
"Parser::optIntegralTypeOrClassSpec 5\n";
2548 p.
add(ID_type_arg).
swap(tname);
2557 std::cout << std::string(__indent,
' ')
2558 <<
"Parser::optIntegralTypeOrClassSpec 6\n";
2566 std::cout << std::string(__indent,
' ')
2567 <<
"Parser::optIntegralTypeOrClassSpec 7\n";
2574 std::cout << std::string(__indent,
' ')
2575 <<
"Parser::optIntegralTypeOrClassSpec 8\n";
2578 p.
add(ID_expr_arg).
swap(expr);
2582 else if(t==TOK_DECLTYPE)
2587 p=
typet(ID_decltype);
2603 p.
add(ID_expr_arg).
swap(expr);
2607 else if(t==TOK_UNDERLYING_TYPE)
2614 p=
typet(ID_msc_underlying_type);
2631 p.
add(ID_type_arg).
swap(tname);
2650 typet &trailing_return_type)
2654 std::cout << std::string(__indent,
' ') <<
"Parser::rConstructorDecl 0\n";
2661 constructor.
name().
swap(type_name);
2668 std::cout << std::string(__indent,
' ') <<
"Parser::rConstructorDecl 1\n";
2671 irept ¶meters=constructor.
type().
add(ID_parameters);
2681 std::cout << std::string(__indent,
' ') <<
"Parser::rConstructorDecl 2\n";
2684 typet &cv=
static_cast<typet &
>(constructor.
add(ID_method_qualifier));
2693 std::cout << std::string(__indent,
' ') <<
"Parser::rConstructorDecl 3\n";
2705 std::cout << std::string(__indent,
' ') <<
"Parser::rConstructorDecl 4\n";
2719 std::cout << std::string(__indent,
' ') <<
"Parser::rConstructorDecl 5\n";
2731 constructor.
value()=
codet(
"cpp-pure-virtual");
2801 else if(t==TOK_ELLIPSIS)
2847 bool should_be_declarator,
2858 declarators.push_back(declarator);
2876 bool should_be_declarator,
2889 typet bit_field_type(ID_c_bit_field);
2890 bit_field_type.
set(ID_size, e);
2894 dw.
type() = std::move(bit_field_type);
2903 declarator,
kDeclarator, should_be_declarator, is_statement))
2948 if(declarator.
type().
id()!=ID_function_type)
2964 typet bit_field_type(ID_c_bit_field);
2965 bit_field_type.
set(ID_size, e);
2972 dw.
swap(declarator);
2989 while(t==TOK_STDCALL || t==TOK_FASTCALL || t==TOK_CLRCALL || t==TOK_CDECL)
3019 bool should_be_declarator,
3026 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 1\n";
3033 typet d_outer, d_inner;
3048 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 2\n";
3056 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 3\n";
3067 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 4\n";
3075 if(!should_be_declarator)
3080 if(t!=
'[' && t!=
'(')
3086 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 5\n";
3097 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 6\n";
3106 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 7\n";
3119 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 8\n";
3139 typet function_type(ID_function_type);
3141 function_type.
add(ID_parameters).
swap(args);
3145 d_outer.
swap(d_inner);
3151 init_args.
swap(args);
3156 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 9\n";
3165 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 10\n";
3186 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 11\n";
3204 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 12\n";
3219 std::list<typet> tl;
3220 tl.push_back(d_outer);
3221 while(tl.back().id() == ID_array)
3223 tl.push_back(tl.back().add_subtype());
3228 d_outer.
swap(array_type);
3231 tl.back().add_subtype().swap(d_outer);
3232 d_outer.
swap(tl.back());
3248 d_outer.
swap(merged_type);
3252 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 13\n";
3278 std::cout << std::string(__indent,
' ') <<
"Parser::optPtrOperator 1\n";
3281 std::list<typet> t_list;
3288 std::cout << std::string(__indent,
' ') <<
"Parser::optPtrOperator 2 " << t
3294 typet op(ID_frontend_pointer);
3305 t_list.push_back(op);
3310 typet op(ID_block_pointer);
3321 t_list.push_back(op);
3335 t_list.push_back(cv);
3338 t_list.push_back(op);
3351 typet op(ID_frontend_pointer);
3352 op.
set(ID_C_reference,
true);
3354 t_list.push_front(op);
3356 else if(t==TOK_ANDAND)
3360 typet op(ID_frontend_pointer);
3361 op.
set(ID_C_rvalue_reference,
true);
3363 t_list.push_front(op);
3367 for(std::list<typet>::reverse_iterator
3372 if(it->id()==ID_merged_type)
3375 merged_type.last_type().add_subtype().swap(ptrs);
3380 it->add_subtype().swap(ptrs);
3400 init=
irept(ID_member_initializers);
3430 std::cout << std::string(__indent,
' ') <<
"Parser::rMemberInit 1\n";
3439 std::cout << std::string(__indent,
' ') <<
"Parser::rMemberInit 2\n";
3442 init=
codet(ID_member_initializer);
3443 init.
add(ID_member).
swap(name);
3453 std::cout << std::string(__indent,
' ') <<
"Parser::rMemberInit 3\n";
3472 std::cout << std::string(__indent,
' ') <<
"Parser::rMemberInit 4\n";
3512 std::cout << std::string(__indent,
' ') <<
"Parser::rName 0\n";
3522 name.
set(ID_typename,
true);
3532 std::cout << std::string(__indent,
' ') <<
"Parser::rName 1\n";
3540 std::cout << std::string(__indent,
' ') <<
"Parser::rName 2 "
3548 std::cout << std::string(__indent,
' ') <<
"Parser::rName 3\n";
3558 std::cout << std::string(__indent,
' ') <<
"Parser::rName 4\n";
3565 components.push_back(
irept(ID_template_args));
3566 components.back().
add(ID_arguments).
swap(args);
3574 case TOK_GCC_IDENTIFIER:
3575 case TOK_MSC_IDENTIFIER:
3577 std::cout << std::string(__indent,
' ') <<
"Parser::rName 5\n";
3586 if(t!=TOK_SCOPE && t!=
'<')
3593 std::cout << std::string(__indent,
' ') <<
"Parser::rName 6\n";
3596 components.push_back(
irept(
"::"));
3602 std::cout << std::string(__indent,
' ') <<
"Parser::rName 7\n";
3610 components.push_back(
irept(
"~"));
3616 std::cout << std::string(__indent,
' ') <<
"Parser::rName 8\n";
3620 components.push_back(
irept(ID_operator));
3623 components.push_back(
irept());
3676 operator_id = std::string(1,
static_cast<char>(t));
3679 case TOK_MULTASSIGN: operator_id=
"*=";
break;
3680 case TOK_DIVASSIGN: operator_id=
"/=";
break;
3681 case TOK_MODASSIGN: operator_id=
"%=";
break;
3682 case TOK_PLUSASSIGN: operator_id=
"+=";
break;
3683 case TOK_MINUSASSIGN: operator_id=
"-=";
break;
3684 case TOK_SHLASSIGN: operator_id=
"<<=";
break;
3685 case TOK_SHRASSIGN: operator_id=
">>=";
break;
3686 case TOK_ANDASSIGN: operator_id=
"&=";
break;
3687 case TOK_XORASSIGN: operator_id=
"^=";
break;
3688 case TOK_ORASSIGN: operator_id=
"|=";
break;
3689 case TOK_SHIFTLEFT: operator_id=
"<<";
break;
3690 case TOK_SHIFTRIGHT: operator_id=
">>";
break;
3691 case TOK_EQ: operator_id=
"==";
break;
3692 case TOK_NE: operator_id=
"!=";
break;
3693 case TOK_LE: operator_id=
"<=";
break;
3694 case TOK_GE: operator_id=
">=";
break;
3695 case TOK_ANDAND: operator_id=
"&&";
break;
3696 case TOK_OROR: operator_id=
"||";
break;
3697 case TOK_INCR: operator_id=
"++";
break;
3698 case TOK_DECR: operator_id=
"--";
break;
3699 case TOK_DOTPM: operator_id=
".*";
break;
3700 case TOK_ARROWPM: operator_id=
"->*";
break;
3701 case TOK_ARROW: operator_id=
"->";
break;
3710 name=
irept(t==TOK_NEW?ID_cpp_new:ID_cpp_delete);
3715 name=
irept(t==TOK_NEW?ID_cpp_new_array:ID_cpp_delete_array);
3744 name=
irept(operator_id);
3758 typet cv1, cv2, type_name, ptr;
3773 if(!
rName(type_name))
3800 std::cout << std::string(__indent,
' ') <<
"Parser::rPtrToMember 0\n";
3803 typet ptm(ID_frontend_pointer);
3804 irept &name = ptm.
add(ID_to_member);
3814 bool loop_cond =
true;
3834 components.push_back(
irept(ID_template_args));
3835 components.back().
add(ID_arguments).
swap(args);
3843 case TOK_GCC_IDENTIFIER:
3844 case TOK_MSC_IDENTIFIER:
3851 if(t != TOK_SCOPE && t !=
'<')
3859 components.push_back(
irept(
"::"));
3866 ptr_to_mem.
swap(ptm);
3869 std::cout << std::string(__indent,
' ') <<
"Parser::rPtrToMember 1\n";
3900 std::cout << std::string(__indent,
' ') <<
"Parser::rTemplateArgs 0\n";
3911 std::cout << std::string(__indent,
' ') <<
"Parser::rTemplateArgs 1\n";
3923 std::cout << std::string(__indent,
' ') <<
"Parser::rTemplateArgs 2\n";
3932 std::cout << std::string(__indent,
' ') <<
"Parser::rTemplateArgs 3\n";
3947 std::cout << std::string(__indent,
' ') <<
"Parser::rTemplateArgs 4\n";
3959 exp.id(ID_ambiguous);
3961 std::cout << std::string(__indent,
' ') <<
"Parser::rTemplateArgs 4.1\n";
3973 std::cout << std::string(__indent,
' ') <<
"Parser::rTemplateArgs 4.2\n";
3980 std::cout << std::string(__indent,
' ') <<
"Parser::rTemplateArgs 5\n";
3998 std::cout << std::string(__indent,
' ') <<
"Parser::rTemplateArgs 6\n";
4014 case TOK_SHIFTRIGHT:
4095 else if(t==TOK_ELLIPSIS)
4107 list.
get_sub().back().swap(declaration);
4111 else if(t==TOK_ELLIPSIS)
4116 else if(t!=
')' && t!=TOK_ELLIPSIS)
4145 header=
typet(ID_register);
4163 declaration.
declarators().push_back(arg_declarator);
4193 expr.
id(ID_initializer_list);
4202 if(t==TOK_MSC_IF_EXISTS ||
4203 t==TOK_MSC_IF_NOT_EXISTS)
4313 std::cout << std::string(__indent,
' ') <<
"Parser::rEnumSpec 1\n";
4330 spec.
set(ID_C_class,
true);
4347 std::cout << std::string(__indent,
' ') <<
"Parser::rEnumSpec 2\n";
4359 std::cout << std::string(__indent,
' ') <<
"Parser::rEnumSpec 3\n";
4382 std::cout << std::string(__indent,
' ') <<
"Parser::rEnumSpec 4\n";
4454 std::cout << std::string(__indent,
' ') <<
"Parser::rClassSpec 1\n";
4458 if(t!=TOK_CLASS && t!=TOK_STRUCT &&
4459 t!=TOK_UNION && t!=TOK_INTERFACE)
4463 std::cout << std::string(__indent,
' ') <<
"Parser::rClassSpec 2\n";
4468 spec=
typet(ID_struct);
4469 spec.
set(ID_C_class,
true);
4471 else if(t==TOK_INTERFACE)
4473 spec=
typet(ID_struct);
4474 spec.
set(ID_C_interface,
true);
4476 else if(t==TOK_STRUCT)
4477 spec=
typet(ID_struct);
4478 else if(t==TOK_UNION)
4479 spec=
typet(ID_union);
4486 std::cout << std::string(__indent,
' ') <<
"Parser::rClassSpec 3\n";
4493 std::cout << std::string(__indent,
' ') <<
"Parser::rClassSpec 4\n";
4512 std::cout << std::string(__indent,
' ') <<
"Parser::rClassSpec 5\n";
4532 std::cout << std::string(__indent,
' ') <<
"Parser::rClassSpec 6\n";
4544 std::cout << std::string(__indent,
' ') <<
"Parser::rClassSpec 7\n";
4568 irept base(ID_base);
4573 base.
set(ID_virtual,
true);
4577 if(t==TOK_PUBLIC || t==TOK_PROTECTED || t==TOK_PRIVATE)
4582 base.
set(ID_protection, ID_public);
4586 base.
set(ID_protection, ID_protected);
4590 base.
set(ID_protection, ID_private);
4603 base.
set(ID_virtual,
true);
4617 bases.
get_sub().back().swap(base);
4635 std::cout << std::string(__indent,
' ') <<
"Parser::rClassBody 0\n";
4660 std::cout << std::string(__indent,
' ') <<
"Parser::rClassBody "
4661 << member.
pretty() <<
'\n';
4665 std::move(
static_cast<exprt &
>(
static_cast<irept &
>(member))));
4697 std::cout << std::string(__indent,
' ') <<
"Parser::rClassMember 0 " << t
4701 if(t==TOK_PUBLIC || t==TOK_PROTECTED || t==TOK_PRIVATE)
4706 member.
id(
"cpp-public");
4710 member.
id(
"cpp-protected");
4714 member.
id(
"cpp-private");
4730 else if(t==TOK_TYPEDEF)
4732 else if(t==TOK_TEMPLATE)
4740 else if(t==TOK_USING)
4742 else if(t==TOK_STATIC_ASSERT)
4771 name_decl.
name() = name;
4788 std::cout << std::string(__indent,
' ') <<
"Parser::rCommaExpression 0\n";
4795 std::cout << std::string(__indent,
' ') <<
"Parser::rCommaExpression 1\n";
4812 exp.add_to_operands(std::move(left), std::move(right));
4817 std::cout << std::string(__indent,
' ') <<
"Parser::rCommaExpression 2\n";
4833 std::cout << std::string(__indent,
' ') <<
"Parser::rExpression 0\n";
4840 std::cout << std::string(__indent,
' ') <<
"Parser::rExpression 1\n";
4846 t==TOK_MULTASSIGN || t==TOK_DIVASSIGN || t==TOK_MODASSIGN ||
4847 t==TOK_PLUSASSIGN || t==TOK_MINUSASSIGN || t==TOK_SHLASSIGN ||
4848 t==TOK_SHRASSIGN || t==TOK_ANDASSIGN ||
4849 t==TOK_XORASSIGN || t==TOK_ORASSIGN)
4854 std::cout << std::string(__indent,
' ') <<
"Parser::rExpression 2\n";
4862 std::cout << std::string(__indent,
' ') <<
"Parser::rExpression 3\n";
4871 exp.set(ID_statement, ID_assign);
4872 else if(t==TOK_PLUSASSIGN)
4873 exp.set(ID_statement, ID_assign_plus);
4874 else if(t==TOK_MINUSASSIGN)
4875 exp.set(ID_statement, ID_assign_minus);
4876 else if(t==TOK_MULTASSIGN)
4877 exp.set(ID_statement, ID_assign_mult);
4878 else if(t==TOK_DIVASSIGN)
4879 exp.set(ID_statement, ID_assign_div);
4880 else if(t==TOK_MODASSIGN)
4881 exp.set(ID_statement, ID_assign_mod);
4882 else if(t==TOK_SHLASSIGN)
4883 exp.set(ID_statement, ID_assign_shl);
4884 else if(t==TOK_SHRASSIGN)
4885 exp.set(ID_statement, ID_assign_shr);
4886 else if(t==TOK_ANDASSIGN)
4887 exp.set(ID_statement, ID_assign_bitand);
4888 else if(t==TOK_XORASSIGN)
4889 exp.set(ID_statement, ID_assign_bitxor);
4890 else if(t==TOK_ORASSIGN)
4891 exp.set(ID_statement, ID_assign_bitor);
4893 exp.add_to_operands(std::move(left), std::move(right));
4898 std::cout << std::string(__indent,
' ') <<
"Parser::rExpression 4\n";
4912 std::cout << std::string(__indent,
' ') <<
"Parser::rConditionalExpr 0\n";
4919 std::cout << std::string(__indent,
' ') <<
"Parser::rConditionalExpr 1\n";
4925 exprt then, otherwise;
4932 std::cout << std::string(__indent,
' ') <<
"Parser::rConditionalExpr 2\n";
4945 if_exprt(std::move(cond), std::move(then), std::move(otherwise),
typet());
4961 std::cout << std::string(__indent,
' ') <<
"Parser::rLogicalOrExpr 0\n";
4968 std::cout << std::string(__indent,
' ') <<
"Parser::rLogicalOrExpr 1\n";
4984 exp.add_to_operands(std::move(left), std::move(right));
5000 std::cout << std::string(__indent,
' ') <<
"Parser::rLogicalAndExpr 1\n";
5007 std::cout << std::string(__indent,
' ') <<
"Parser::rLogicalAndExpr 1\n";
5023 exp.add_to_operands(std::move(left), std::move(right));
5039 std::cout << std::string(__indent,
' ') <<
"Parser::rInclusiveOrExpr 0\n";
5046 std::cout << std::string(__indent,
' ') <<
"Parser::rInclusiveOrExpr 1\n";
5062 exp.add_to_operands(std::move(left), std::move(right));
5078 std::cout << std::string(__indent,
' ') <<
"Parser::rExclusiveOrExpr 0\n";
5085 std::cout << std::string(__indent,
' ') <<
"Parser::rExclusiveOrExpr 1\n";
5094 if(!
rAndExpr(right, template_args))
5101 exp.add_to_operands(std::move(left), std::move(right));
5117 std::cout << std::string(__indent,
' ') <<
"Parser::rAndExpr 0\n";
5124 std::cout << std::string(__indent,
' ') <<
"Parser::rAndExpr 1\n";
5140 exp.add_to_operands(std::move(left), std::move(right));
5156 std::cout << std::string(__indent,
' ') <<
"Parser::rEqualityExpr 0\n";
5163 std::cout << std::string(__indent,
' ') <<
"Parser::rEqualityExpr 1\n";
5180 exp.add_to_operands(std::move(left), std::move(right));
5196 std::cout << std::string(__indent,
' ') <<
"Parser::rRelationalExpr 0\n";
5203 std::cout << std::string(__indent,
' ') <<
"Parser::rRelationalExpr 1\n";
5209 (t==TOK_LE || t==TOK_GE || t==
'<' || (t==
'>' && !template_args)))
5225 case TOK_LE:
id=ID_le;
break;
5226 case TOK_GE:
id=ID_ge;
break;
5227 case '<':
id=ID_lt;
break;
5228 case '>':
id=ID_gt;
break;
5232 exp.add_to_operands(std::move(left), std::move(right));
5248 std::cout << std::string(__indent,
' ') <<
"Parser::rShiftExpr 0\n";
5255 std::cout << std::string(__indent,
' ') <<
"Parser::rShiftExpr 1\n";
5272 exp.add_to_operands(std::move(left), std::move(right));
5288 std::cout << std::string(__indent,
' ') <<
"Parser::rAdditiveExpr 0\n";
5295 std::cout << std::string(__indent,
' ') <<
"Parser::rAdditiveExpr 1\n";
5314 case '+':
id=ID_plus;
break;
5315 case '-':
id=ID_minus;
break;
5319 exp.add_to_operands(std::move(left), std::move(right));
5335 std::cout << std::string(__indent,
' ') <<
"Parser::rMultiplyExpr 0\n";
5342 std::cout << std::string(__indent,
' ') <<
"Parser::rMultiplyExpr 1\n";
5346 while(t=
lex.
LookAhead(0), (t==
'*' || t==
'/' || t==
'%'))
5361 case '*':
id=ID_mult;
break;
5362 case '/':
id=ID_div;
break;
5363 case '%':
id=ID_mod;
break;
5367 exp.add_to_operands(std::move(left), std::move(right));
5372 std::cout << std::string(__indent,
' ') <<
"Parser::rMultiplyExpr 2\n";
5388 std::cout << std::string(__indent,
' ') <<
"Parser::rPmExpr 0\n";
5395 std::cout << std::string(__indent,
' ') <<
"Parser::rPmExpr 1\n";
5412 exp.add_to_operands(std::move(left), std::move(right));
5417 std::cout << std::string(__indent,
' ') <<
"Parser::rPmExpr 2\n";
5432 std::cout << std::string(__indent,
' ') <<
"Parser::rCastExpr 0\n";
5448 std::cout << std::string(__indent,
' ') <<
"Parser::rCastExpr 1\n";
5470 exp.type().swap(tname);
5471 exp.add_to_operands(std::move(op));
5492 std::cout << std::string(__indent,
' ') <<
"Parser::rTypeName 0\n";
5501 std::cout << std::string(__indent,
' ') <<
"Parser::rTypeName 1\n";
5521 std::cout << std::string(__indent,
' ') <<
"Parser::rTypeName 2\n";
5536 std::cout << std::string(__indent,
' ')
5537 <<
"Parser::rTypeNameOrFunctionType 0\n";
5545 std::cout << std::string(__indent,
' ')
5546 <<
"Parser::rTypeNameOrFunctionType 1\n";
5558 std::cout << std::string(__indent,
' ')
5559 <<
"Parser::rTypeNameOrFunctionType 2\n";
5567 std::cout << std::string(__indent,
' ')
5568 <<
"Parser::rTypeNameOrFunctionType 3\n";
5573 tname.
swap(return_type);
5582 std::cout << std::string(__indent,
' ')
5583 <<
"Parser::rTypeNameOrFunctionType 4\n";
5609 type.set(ID_identifier, op.data.get(ID_C_base_name));
5619 type.set(ID_identifier, op.data.get(ID_C_base_name));
5629 std::cout << std::string(__indent,
' ')
5630 <<
"Parser::rTypeNameOrFunctionType 5\n";
5636 else if(t==TOK_ELLIPSIS)
5640 type.make_ellipsis();
5649 parameter.
swap(parameter_declaration);
5650 type.parameters().push_back(parameter);
5658 else if(t==TOK_ELLIPSIS)
5664 type.make_ellipsis();
5672 std::cout << std::string(__indent,
' ')
5673 <<
"Parser::rTypeNameOrFunctionType 6\n";
5684 std::cout << std::string(__indent,
' ')
5685 <<
"Parser::rTypeNameOrFunctionType 7\n";
5695 std::cout << std::string(__indent,
' ')
5696 <<
"Parser::rTypeNameOrFunctionType 8\n";
5718 std::cout << std::string(__indent,
' ') <<
"Parser::rUnaryExpr 0\n";
5721 if(t==
'*' || t==
'&' || t==
'+' ||
5722 t==
'-' || t==
'!' || t==
'~' ||
5723 t==TOK_INCR || t==TOK_DECR)
5729 std::cout << std::string(__indent,
' ') <<
"Parser::rUnaryExpr 1\n";
5737 std::cout << std::string(__indent,
' ') <<
"Parser::rUnaryExpr 2\n";
5768 exp.set(ID_statement, ID_preincrement);
5773 exp.set(ID_statement, ID_predecrement);
5780 exp.add_to_operands(std::move(right));
5785 else if(t==TOK_SIZEOF)
5787 else if(t==TOK_ALIGNOF)
5789 else if(t==TOK_THROW)
5791 else if(t==TOK_NOEXCEPT)
5793 else if(t==TOK_REAL || t==TOK_IMAG)
5804 exp=
exprt(t==TOK_REAL?ID_complex_real:ID_complex_imag);
5805 exp.add_to_operands(std::move(unary));
5825 std::cout << std::string(__indent,
' ') <<
"Parser::rThrowExpr 0\n";
5836 if(t==
':' || t==
';')
5847 exp.add_to_operands(std::move(e));
5864 std::cout << std::string(__indent,
' ') <<
"Parser::rTypeidExpr 0\n";
5930 std::cout << std::string(__indent,
' ') <<
"Parser::rSizeofExpr 0\n";
5949 exp.add(ID_type_arg).swap(tname);
5971 exp.add(ID_type_arg).swap(tname);
5986 exp.add_to_operands(std::move(unary));
6015 exp.add(ID_type_arg).swap(tname);
6030 std::cout << std::string(__indent,
' ') <<
"Parser::rNoexceptExpr 0\n";
6049 exp.add_to_operands(std::move(subexp));
6066 return t==TOK_NEW || t==TOK_DELETE;
6081 std::cout << std::string(__indent,
' ') <<
"Parser::rAllocateExpr 0\n";
6092 std::cout << std::string(__indent,
' ') <<
"Parser::rAllocateExpr 1\n";
6098 std::cout << std::string(__indent,
' ') <<
"Parser::rAllocateExpr 2\n";
6113 exp.set(ID_statement, ID_cpp_delete_array);
6118 exp.set(ID_statement, ID_cpp_delete);
6126 exp.add_to_operands(std::move(obj));
6133 std::cout << std::string(__indent,
' ') <<
"Parser::rAllocateExpr 3\n";
6137 exp.set(ID_statement, ID_cpp_new);
6140 exprt arguments, initializer;
6146 std::cout << std::string(__indent,
' ') <<
"Parser::rAllocateExpr 4\n";
6149 exp.add(ID_initializer).swap(initializer);
6281 decl.
swap(array_type);
6352 std::cout << std::string(__indent,
' ') <<
"Parser::rPostfixExpr 0\n";
6359 std::cout << std::string(__indent,
' ') <<
"Parser::rPostfixExpr 1\n";
6376 std::cout << std::string(__indent,
' ') <<
"Parser::rPostfixExpr 2\n";
6387 exp.add_to_operands(std::move(left), std::move(e));
6394 std::cout << std::string(__indent,
' ') <<
"Parser::rPostfixExpr 3\n";
6405 std::cout << std::string(__indent,
' ') <<
"Parser::rPostfixExpr 4\n";
6415 fc.arguments().push_back(*it);
6448 std::cout << std::string(__indent,
' ') <<
"Parser::rPostfixExpr 5\n";
6455 std::cout << std::string(__indent,
' ') <<
"Parser::rPostfixExpr 6\n";
6467 exp.add_to_operands(std::move(left));
6471 exp.add(ID_component_cpp_name).swap(e);
6507 expr=
exprt(ID_msc_uuidof);
6508 expr.
add(ID_type_arg).
swap(tname);
6525 expr=
exprt(ID_msc_uuidof);
6542 if(tk1.
kind!=TOK_MSC_IF_EXISTS &&
6543 tk1.
kind!=TOK_MSC_IF_NOT_EXISTS)
6571 tk1.
kind==TOK_MSC_IF_EXISTS?ID_msc_if_exists:
6572 ID_msc_if_not_exists);
6587 if(tk1.
kind != TOK_MSC_IF_EXISTS && tk1.
kind != TOK_MSC_IF_NOT_EXISTS)
6611 block.
add(std::move(*statement));
6620 tk1.
kind == TOK_MSC_IF_EXISTS ? ID_msc_if_exists : ID_msc_if_not_exists);
6626 return std::move(code);
6645 typet tname1, tname2;
6649 case TOK_UNARY_TYPE_PREDICATE:
6656 expr.
add(ID_type_arg).
swap(tname1);
6659 case TOK_BINARY_TYPE_PREDICATE:
6670 expr.
add(
"type_arg1").
swap(tname1);
6671 expr.
add(
"type_arg2").
swap(tname2);
6704 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 0 "
6717 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 1\n";
6726 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 2\n";
6735 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 3\n";
6744 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 4\n";
6753 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 5\n";
6763 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 6\n";
6769 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 7\n";
6778 exp.set(ID_statement, ID_statement_expression);
6780 exp.add_to_operands(std::move(*code));
6796 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 8\n";
6806 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 9\n";
6812 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 10\n";
6819 case TOK_UNARY_TYPE_PREDICATE:
6820 case TOK_BINARY_TYPE_PREDICATE:
6822 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 11\n";
6826 case TOK_MSC_UUIDOF:
6828 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 12\n";
6834 case TOK_MSC_IF_EXISTS:
6835 case TOK_MSC_IF_NOT_EXISTS:
6837 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 13\n";
6843 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 14\n";
6852 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 15\n";
6865 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 16\n";
6875 exp=
exprt(
"explicit-constructor-call");
6876 exp.type().swap(type);
6877 exp.add_to_operands(std::move(
exp2));
6891 exp=
exprt(
"explicit-constructor-call");
6892 exp.type().swap(type);
6893 exp.operands().swap(
exp2.operands());
6915 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 17\n";
6936 std::cout << std::string(__indent,
' ') <<
"Parser::rVarName 0\n";
6949 std::cout << std::string(__indent,
' ') <<
"Parser::rVarNameCore 0\n";
6959 name.
set(ID_typename,
true);
6969 std::cout << std::string(__indent,
' ') <<
"Parser::rVarNameCore 1\n";
6977 std::cout << std::string(__indent,
' ') <<
"Parser::rVarNameCore 1.1 "
6987 std::cout << std::string(__indent,
' ') <<
"Parser::rVarNameCore 2\n";
6995 case TOK_GCC_IDENTIFIER:
6996 case TOK_MSC_IDENTIFIER:
6998 std::cout << std::string(__indent,
' ') <<
"Parser::rVarNameCore 3\n";
7011 std::cout << std::string(__indent,
' ') <<
"Parser::rVarNameCore 4\n";
7021 components.push_back(
irept(ID_template_args));
7022 components.back().add(ID_arguments).swap(args);
7031 std::cout << std::string(__indent,
' ') <<
"Parser::rVarNameCore 5\n";
7035 components.push_back(
irept(
"::"));
7041 std::cout << std::string(__indent,
' ') <<
"Parser::rVarNameCore 6\n";
7049 components.push_back(
irept(
"~"));
7055 std::cout << std::string(__indent,
' ') <<
"Parser::rVarNameCore 7\n";
7060 components.push_back(
irept(ID_operator));
7068 components.push_back(op);
7083 if(
is_identifier(t) || t ==
'~' || t == TOK_OPERATOR || t == TOK_TEMPLATE)
7102 std::cout << std::string(__indent,
' ') <<
"Parser::maybeTemplateArgs 0\n";
7111 if(u==
'\0' || u==
';' || u==
'}')
7113 else if((u==
'>' || u==TOK_SHIFTRIGHT) &&
7124 std::cout << std::string(__indent,
' ')
7125 <<
"Parser::maybeTemplateArgs 1\n";
7131 std::cout << std::string(__indent,
' ')
7132 <<
"Parser::maybeTemplateArgs 2\n";
7147 std::cout << std::string(__indent,
' ')
7148 <<
"Parser::maybeTemplateArgs 3\n";
7155 else if(v==
'\0' || v==
';' || v==
'}')
7159 else if(u==
'\0' || u==
';' || u==
'}')
7161 else if(u==TOK_SHIFTRIGHT && n>=2)
7165 std::cout << std::string(__indent,
' ')
7166 <<
"Parser::maybeTemplateArgs 4\n";
7171 std::cout << std::string(__indent,
' ') <<
"Parser::maybeTemplateArgs 5\n";
7177 std::cout << std::string(__indent,
' ') <<
"Parser::maybeTemplateArgs 6\n";
7180 return t==TOK_SCOPE || t==
'(';
7185 std::cout << std::string(__indent,
' ') <<
"Parser::maybeTemplateArgs 7\n";
7216 declarator.
value()=body;
7226 declarator.
value() = std::move(*body);
7249 std::cout << std::string(__indent,
' ') <<
"Parser::rCompoundStatement 1\n";
7256 std::cout << std::string(__indent,
' ') <<
"Parser::rCompoundStatement 2\n";
7265 statement.
add(std::move(*statement2));
7273 return std::move(statement);
7280 return std::move(statement);
7311 std::cout << std::string(__indent,
' ') <<
"Parser::rStatement 0 "
7352 codet statement(k == TOK_BREAK ? ID_break : ID_continue);
7358 return std::move(statement);
7363 std::cout << std::string(__indent,
' ') <<
"Parser::rStatement RETURN 0\n";
7374 std::cout << std::string(__indent,
' ')
7375 <<
"Parser::rStatement RETURN 1\n";
7382 std::cout << std::string(__indent,
' ')
7383 <<
"Parser::rStatement RETURN 2\n";
7390 std::cout << std::string(__indent,
' ')
7391 <<
"Parser::rStatement RETURN 3\n";
7398 return std::move(statement);
7413 return std::move(statement);
7439 std::move(case_expr), std::move(range_end), std::move(*statement2));
7441 return std::move(code);
7454 std::move(case_expr), std::move(*statement2));
7456 return std::move(statement);
7475 return std::move(statement);
7487 case TOK_MSC_IF_EXISTS:
7488 case TOK_MSC_IF_NOT_EXISTS:
7491 case TOK_GCC_IDENTIFIER:
7492 case TOK_MSC_IDENTIFIER:
7504 return std::move(label);
7522 return std::move(statement);
7533 case TOK_STATIC_ASSERT:
7540 codet statement(ID_static_assert);
7542 statement.
operands().swap(cpp_static_assert.operands());
7544 return std::move(statement);
7574 if(!then.has_value())
7584 std::move(
exp), std::move(*then), std::move(*otherwise));
7586 return std::move(statement);
7595 return std::move(statement);
7624 return std::move(statement);
7655 return std::move(statement);
7673 if(!body.has_value())
7694 return std::move(statement);
7714 if(!exp1.has_value())
7744 std::move(*exp1), std::move(
exp2), std::move(exp3), std::move(*body));
7746 return std::move(statement);
7768 if(!try_body.has_value())
7785 std::optional<codet> catch_op;
7791 codet ellipsis(ID_ellipsis);
7793 catch_op = std::move(ellipsis);
7804 declaration.
declarators().size() == 1,
"exactly one declarator");
7806 if(declaration.
declarators().front().name().is_nil())
7813 catch_op = std::move(code_decl);
7832 return std::move(statement);
7847 if(!body1.has_value())
7852 codet statement(ID_msc_try_except);
7872 std::move(*body1), std::move(
exp), std::move(*body2));
7873 return std::move(statement);
7880 codet statement(ID_msc_try_finally);
7888 return std::move(statement);
7907 codet statement(ID_msc_leave);
7910 return std::move(statement);
7919 std::cout << std::string(__indent,
' ') <<
"Parser::rGCCAsmStatement 1\n";
7934 std::cout << std::string(__indent,
' ') <<
"Parser::rGCCAsmStatement 3\n";
7945 std::cout << std::string(__indent,
' ') <<
"Parser::rGCCAsmStatement 3\n";
7951 std::cout << std::string(__indent,
' ') <<
"Parser::rGCCAsmStatement 4\n";
7972 std::cout << std::string(__indent,
' ')
7973 <<
"Parser::rGCCAsmStatement 5\n";
7981 std::cout << std::string(__indent,
' ')
7982 <<
"Parser::rGCCAsmStatement 6\n";
7997 std::cout << std::string(__indent,
' ') <<
"Parser::rGCCAsmStatement 7\n";
8006 std::cout << std::string(__indent,
' ') <<
"Parser::rGCCAsmStatement 8\n";
8009 return std::move(statement);
8018 std::cout << std::string(__indent,
' ') <<
"Parser::rMSCAsmStatement 1\n";
8032 std::cout << std::string(__indent,
' ') <<
"Parser::rMSCAsmStatement 2\n";
8040 std::cout << std::string(__indent,
' ') <<
"Parser::rMSCAsmStatement 3\n";
8053 std::cout << std::string(__indent,
' ') <<
"Parser::rMSCAsmStatement 4\n";
8059 std::cout << std::string(__indent,
' ') <<
"Parser::rMSCAsmStatement 5\n";
8063 return std::move(statement);
8069 std::cout << std::string(__indent,
' ') <<
"Parser::rMSCAsmStatement 6\n";
8074 std::cout << std::string(__indent,
' ') <<
"Parser::rMSCAsmStatement 7\n";
8077 return std::move(statement);
8094 std::cout << std::string(__indent,
' ') <<
"Parser::rExprStatement 0\n";
8100 std::cout << std::string(__indent,
' ') <<
"Parser::rExprStatement 1\n";
8106 return std::move(statement);
8111 std::cout << std::string(__indent,
' ') <<
"Parser::rExprStatement 2\n";
8119 std::cout << std::string(__indent,
' ') <<
"rDe " << statement->pretty()
8131 std::cout << std::string(__indent,
' ') <<
"Parser::rExprStatement 3\n";
8138 std::cout << std::string(__indent,
' ') <<
"Parser::rExprStatement 4\n";
8142 std::cout << std::string(__indent,
' ') <<
"Parser::rExprStatement 5 "
8150 std::cout << std::string(__indent,
' ') <<
"Parser::rExprStatement 6\n";
8155 return std::move(expr_statement);
8170 statement=
codet(ID_decl);
8202 typet cv_q, integral;
8207 std::cout << std::string(__indent,
' ')
8208 <<
"Parser::rDeclarationStatement 1\n";
8230 std::cout << std::string(__indent,
' ')
8231 <<
"Parser::rDeclarationStatement 2\n";
8241 std::cout << std::string(__indent,
' ')
8242 <<
"Parser::rDeclarationStatement 3 " << t <<
'\n';
8250 std::cout << std::string(__indent,
' ')
8251 <<
"Parser::rDeclarationStatement 4\n";
8291 return std::move(statement);
8304 return std::move(statement);
8312 std::optional<codet>
8320 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclStatement 1\n";
8323 if(!
rName(type_name))
8327 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclStatement 2\n";
8334 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclStatement 3\n";
8340 declaration.
type().
swap(type_name);
8347 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclStatement 4\n";
8356 return std::move(statement);
8371 if(t==token || t==
'\0')
8400 Parser parser(cpp_parser, message_handler);
pointer_typet pointer_type(const typet &subtype)
bool optCvQualify(typet &)
bool rDeclaratorQualifier()
bool rShiftExpr(exprt &, bool)
std::optional< codet > rIfStatement()
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 &)
message_handlert & message_handler
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 &)
std::optional< codet > rForStatement()
std::optional< codet > rDeclarationStatement()
bool rLogicalAndExpr(exprt &, bool)
bool rExpression(exprt &, bool)
std::optional< codet > rDoStatement()
std::optional< codet > rMSC_leaveStatement()
bool rString(cpp_tokent &tk)
std::optional< codet > rTryStatement()
bool rOtherDeclaration(cpp_declarationt &, cpp_storage_spect &, cpp_member_spect &, typet &)
bool optAttribute(typet &)
bool rAdditiveExpr(exprt &)
bool rMemberInit(exprt &)
bool rConstDeclaration(cpp_declarationt &)
bool rSimpleDeclaration(cpp_declarationt &)
bool rInclusiveOrExpr(exprt &, bool)
bool rAllocateInitializer(exprt &)
bool rPrimaryExpr(exprt &)
bool rStaticAssert(cpp_static_assertt &)
std::optional< codet > rCompoundStatement()
bool rArgDeclListOrInit(exprt &, bool &, bool)
bool rNewDeclarator(typet &)
void make_subtype(const typet &src, typet &dest)
bool rAccessDecl(cpp_declarationt &)
bool rRelationalExpr(exprt &, bool)
bool rNoexceptExpr(exprt &)
bool rNamespaceSpec(cpp_namespace_spect &)
cpp_parse_treet & parse_tree
bool rArgDeclaration(cpp_declarationt &)
std::optional< codet > rGCCAsmStatement()
std::optional< codet > rSwitchStatement()
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)
bool rEqualityExpr(exprt &, bool)
bool rCommaExpression(exprt &)
bool rGCCAttribute(typet &)
bool rTempArgList(irept &)
bool rArgDeclList(irept &)
bool rMultiplyExpr(exprt &)
bool rTypedef(cpp_declarationt &)
bool rTemplateArgs(irept &)
bool rSizeofExpr(exprt &)
bool rTypeNameOrFunctionType(typet &)
bool rMemberInitializers(irept &)
bool rDeclaratorWithInit(cpp_declaratort &, bool, bool)
bool rFunctionArguments(exprt &)
std::optional< codet > rExprStatement()
irep_idt current_function
new_scopet * current_scope
bool optIntegralTypeOrClassSpec(typet &)
bool rTempArgDeclaration(cpp_declarationt &)
bool rLogicalOrExpr(exprt &, bool)
bool rProgram(cpp_itemt &item)
std::optional< codet > rMSC_if_existsStatement()
bool rTemplateDecl2(typet &, TemplateDeclKind &kind)
std::optional< codet > rWhileStatement()
bool rTypeidExpr(exprt &)
std::optional< codet > rIntegralDeclStatement(cpp_storage_spect &, typet &, typet &)
std::optional< codet > rOtherDeclStatement(cpp_storage_spect &, typet &)
void merge_types(const typet &src, typet &dest)
bool rAlignofExpr(exprt &)
std::optional< codet > rStatement()
bool rCastOperatorName(irept &)
bool rInitializeExpr(exprt &)
bool rFunctionBody(cpp_declaratort &)
bool optStorageSpec(cpp_storage_spect &)
std::optional< codet > rTypedefStatement()
bool rDeclaration(cpp_declarationt &)
Parser(cpp_parsert &_cpp_parser, message_handlert &message_handler)
std::optional< codet > rMSC_tryStatement()
bool rUsing(cpp_usingt &)
void set_location(irept &dest, const cpp_tokent &token)
std::size_t number_of_errors
bool rOperatorName(irept &)
std::optional< codet > rMSCAsmStatement()
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.
void add(const codet &code)
code_operandst & statements()
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.
Globally accessible architectural configuration.
const declaratorst & declarators() const
const cpp_storage_spect & storage_spec() const
const cpp_member_spect & member_spec() const
std::vector< cpp_declaratort > declaratorst
irept & member_initializers()
void set_is_parameter(bool is_parameter)
irept & method_qualifier()
cpp_declarationt & make_declaration()
cpp_static_assertt & make_static_assert()
cpp_namespace_spect & make_namespace_spec()
cpp_usingt & make_using()
cpp_linkage_spect & make_linkage_spec()
const itemst & items() const
std::vector< class cpp_itemt > itemst
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)
irep_idt get_base_name() const
const exprt & as_expr() const
int LookAhead(unsigned offset)
int get_token(cpp_tokent &token)
cpp_tokent & current_token()
void Replace(const cpp_tokent &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.
source_locationt & add_source_location()
const source_locationt & source_location() const
typet & type()
Return the type of the expression.
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)
const irep_idt & id() const
void move_to_sub(irept &irep)
irept & add(const irep_idt &name)
holds a combination of types
Class that provides messages with a built-in verbosity 'level'.
void print_rec(std::ostream &, unsigned indent) const
static const char * kind2string(kindt kind)
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
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.
const source_locationt & source_location() const
bool has_subtypes() const
source_locationt & add_source_location()
C++ Language Type Checking.
cpp_namet & to_cpp_name(irept &cpp_name)
C++ Parser: Token Buffer.
static bool is_operator(const ctokent &t)
@ NONE
Do not apply loop contracts.
#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
bool cpp_parse(cpp_parsert &cpp_parser, message_handlert &message_handler)
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)
std::string to_string(const string_not_contains_constraintt &expr)
Used for debug printing.
const type_with_subtypest & to_type_with_subtypes(const typet &type)
const type_with_subtypet & to_type_with_subtype(const typet &type)