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)
283 typet &trailing_return_type);
405 if(p->
id()==ID_merged_type)
408 p = &merged_type.last_type();
423 return token == TOK_GCC_IDENTIFIER || token == TOK_MSC_IDENTIFIER;
430 if(cpp_name.
get_sub().size()==1 &&
431 cpp_name.
get_sub().front().id()==ID_name)
432 id=cpp_name.
get_sub().front().get(ID_identifier);
479 if(dest.
id()!=ID_merged_type)
492 sub.emplace(sub.begin(), src);
498 #define ERROR_TOKENS 4
508 source_location.
set_file(t[0].filename);
511 std::string message =
"parse error before '";
524 log.error().source_location = source_location;
567 std::cout << std::string(__indent,
' ') <<
"Parser::rDefinition 1 " << t
573 else if(t==TOK_TYPEDEF)
575 else if(t==TOK_TEMPLATE)
579 else if(t==TOK_EXTERN &&
lex.
LookAhead(1)==TOK_TEMPLATE)
581 else if(t==TOK_NAMESPACE)
583 else if(t==TOK_INLINE &&
lex.
LookAhead(1)==TOK_NAMESPACE)
585 else if(t==TOK_USING)
587 else if(t==TOK_STATIC_ASSERT)
618 std::cout << std::string(__indent,
' ') <<
"Parser::rTypedef 1\n";
647 std::cout << std::string(__indent,
' ') <<
"Parser::rTypedefUsing 1\n";
663 std::cout << std::string(__indent,
' ') <<
"Parser::rTypedefUsing 2\n";
683 std::cout << std::string(__indent,
' ') <<
"Parser::rTypedefUsing 3\n";
707 std::cout << std::string(__indent,
' ') <<
"Parser::rTypeSpecifier 0\n";
718 std::cout << std::string(__indent,
' ') <<
"Parser::rTypeSpecifier 0.1\n";
730 std::cout << std::string(__indent,
' ') <<
"Parser::rTypeSpecifier 1\n";
738 std::cout << std::string(__indent,
' ') <<
"Parser::rTypeSpecifier 2\n";
746 std::cout << std::string(__indent,
' ') <<
"Parser::rTypeSpecifier 3\n";
755 std::cout << std::string(__indent,
' ') <<
"Parser::rTypeSpecifier 4\n";
767 return is_identifier(t) || t == TOK_SCOPE || t == TOK_CONSTEXPR ||
768 t == TOK_CONST || t == TOK_VOLATILE || t == TOK_RESTRICT ||
769 t == TOK_CHAR || t == TOK_INT || t == TOK_SHORT || t == TOK_LONG ||
770 t == TOK_CHAR16_T || t == TOK_CHAR32_T || t == TOK_WCHAR_T ||
772 || t == TOK_SIGNED || t == TOK_UNSIGNED || t == TOK_FLOAT ||
773 t == TOK_DOUBLE || t == TOK_INT8 || t == TOK_INT16 || t == TOK_INT32 ||
774 t == TOK_INT64 || t == TOK_GCC_INT128 || t == TOK_PTR32 ||
775 t == TOK_PTR64 || t == TOK_GCC_FLOAT16 || t == TOK_GCC_FLOAT80 ||
776 t == TOK_GCC_FLOAT128 || t == TOK_VOID || t == TOK_BOOL ||
777 t == TOK_CPROVER_BOOL || t == TOK_CLASS || t == TOK_STRUCT ||
778 t == TOK_UNION || t == TOK_ENUM || t == TOK_INTERFACE ||
779 t == TOK_TYPENAME || t == TOK_TYPEOF || t == TOK_DECLTYPE ||
780 t == TOK_UNDERLYING_TYPE;
815 linkage_spec.
items().push_back(item);
831 bool is_inline=
false;
848 name=tk2.
data.
get(ID_C_base_name);
1003 items.push_back(item);
1007 items.push_back(item);
1039 typet template_type;
1058 std::cout << std::string(__indent,
' ') <<
"BODY: "
1059 << body.
pretty() <<
'\n';
1060 std::cout << std::string(__indent,
' ') <<
"TEMPLATE_TYPE: "
1061 << template_type.
pretty() <<
'\n';
1063 body.
add(ID_template_type).
swap(template_type);
1064 body.
set(ID_is_template,
true);
1074 body.
add(ID_template_type).
swap(template_type);
1075 body.
set(ID_is_template,
true);
1095 decl=
typet(ID_template);
1108 irept &template_parameters=decl.
add(ID_template_parameters);
1132 if(template_parameters.
get_sub().empty())
1157 args.
get_sub().back().swap(a);
1168 args.
get_sub().back().swap(a);
1185 std::cout << std::string(__indent,
' ') <<
"Parser::rTempArgDeclaration 0\n";
1190 if((t0==TOK_CLASS || t0==TOK_TYPENAME))
1200 declaration.
set(ID_is_type,
true);
1201 declaration.
type()=
typet(
"cpp-template-type");
1211 bool has_ellipsis=
false;
1260 std::cout << std::string(__indent,
' ') <<
"Parser::rTempArgDeclaration 1\n";
1263 if(t0==TOK_TEMPLATE)
1267 typet template_type;
1297 std::cout << std::string(__indent,
' ')
1298 <<
"Parser::rTempArgDeclaration 2\n";
1302 declaration.
set(ID_is_type,
false);
1308 std::cout << std::string(__indent,
' ')
1309 <<
"Parser::rTempArgDeclaration 3\n";
1312 bool has_ellipsis=
false;
1329 std::cout << std::string(__indent,
' ')
1330 <<
"Parser::rTempArgDeclaration 4\n";
1416 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclaration 0.1 token: "
1428 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclaration 0.2\n";
1436 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclaration 1\n";
1444 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclaration 3\n";
1447 typet cv_q, integral;
1465 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclaration 4\n";
1479 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclaration 5\n";
1483 declaration, storage_spec, member_spec, integral, cv_q);
1490 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclaration 6 " << t
1509 typet cv_q, integral;
1535 integral.
swap(cv_q);
1574 std::cout << std::string(__indent,
' ')
1575 <<
"Parser::rIntegralDeclaration 1 token: "
1583 std::cout << std::string(__indent,
' ') <<
"Parser::rIntegralDeclaration 2\n";
1589 std::cout << std::string(__indent,
' ') <<
"Parser::rIntegralDeclaration 3\n";
1602 std::cout << std::string(__indent,
' ')
1603 <<
"Parser::rIntegralDeclaration 4\n";
1611 std::cout << std::string(__indent,
' ')
1612 <<
"Parser::rIntegralDeclaration 5\n";
1632 std::cout << std::string(__indent,
' ') <<
"Parser::rIntegralDeclaration 6 "
1641 declaration.
type().
id() == ID_auto &&
1643 declaration.
declarators().front().type().id() == ID_function_type &&
1644 declaration.
declarators().front().type().add_subtype().is_not_nil())
1646 declaration.
type() =
1649 declaration.
declarators().front().type().add_subtype().make_nil();
1653 std::cout << std::string(__indent,
' ')
1654 <<
"Parser::rIntegralDeclaration 7\n";
1660 std::cout << std::string(__indent,
' ')
1661 <<
"Parser::rIntegralDeclaration 8 "
1662 << declaration.
pretty() <<
'\n';
1670 std::cout << std::string(__indent,
' ')
1671 <<
"Parser::rIntegralDeclaration 9\n";
1681 std::cout << std::string(__indent,
' ')
1682 <<
"Parser::rIntegralDeclaration 10\n";
1694 std::cout << std::string(__indent,
' ') <<
"Parser::rConstDeclaration\n";
1719 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 1\n";
1722 if(!
rName(type_name))
1728 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 2\n";
1742 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 3\n";
1751 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 4\n";
1756 for(std::size_t i=0; i < type_name.
get_sub().size(); i++)
1758 if(type_name.
get_sub()[i].id() == ID_operator)
1769 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 5\n";
1773 typet type = type_name;
1777 typet trailing_return_type;
1779 conv_operator_declarator, type_name, trailing_return_type))
1782 type_name=
typet(
"cpp-cast-operator");
1784 declaration.
declarators().push_back(conv_operator_declarator);
1789 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 6\n";
1794 bool is_destructor=
false;
1795 for(
const auto &irep : type_name.
get_sub())
1797 if(irep.id() ==
"~")
1805 typet trailing_return_type;
1807 constructor_declarator, type_name, trailing_return_type))
1811 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 7\n";
1816 type_name=trailing_return_type;
1818 type_name=
typet(is_destructor?ID_destructor:ID_constructor);
1820 declaration.
declarators().push_back(constructor_declarator);
1825 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 8\n";
1843 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 9\n";
1855 declaration.
type().
swap(type_name);
1860 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 10\n";
1866 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 11\n";
1875 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 12\n";
1899 std::cout << std::string(__indent,
' ') <<
"Parser::isConstructorDecl "
1908 if(t==
'*' || t==
'&' || t==
'(')
1910 else if(t==TOK_STDCALL || t==TOK_FASTCALL || t==TOK_CLRCALL || t==TOK_CDECL)
1961 else if(v==
'\0' || v==
';' || v==
'}')
1965 else if(u==
'\0' || u==
';' || u==
'}')
1990 member_spec.
clear();
1995 t == TOK_FRIEND || t == TOK_INLINE || t == TOK_VIRTUAL ||
1996 t == TOK_EXPLICIT || t == TOK_MSC_FORCEINLINE)
2004 case TOK_MSC_FORCEINLINE:
2007 case TOK_VIRTUAL: member_spec.
set_virtual(
true);
break;
2008 case TOK_FRIEND: member_spec.
set_friend(
true);
break;
2009 case TOK_EXPLICIT: member_spec.
set_explicit(
true);
break;
2028 t == TOK_STATIC || t == TOK_EXTERN || (t == TOK_AUTO && !
cpp11) ||
2029 t == TOK_REGISTER || t == TOK_MUTABLE || t == TOK_GCC_ASM ||
2030 t == TOK_THREAD_LOCAL)
2037 case TOK_STATIC: storage_spec.
set_static();
break;
2038 case TOK_EXTERN: storage_spec.
set_extern();
break;
2039 case TOK_AUTO: storage_spec.
set_auto();
break;
2041 case TOK_MUTABLE: storage_spec.
set_mutable();
break;
2042 case TOK_GCC_ASM: storage_spec.
set_asm();
break;
2061 if(t==TOK_CONSTEXPR ||
2062 t==TOK_CONST || t==TOK_VOLATILE || t==TOK_RESTRICT ||
2063 t==TOK_PTR32 || t==TOK_PTR64 ||
2064 t==TOK_GCC_ATTRIBUTE || t==TOK_GCC_ASM)
2073 p=
typet(ID_constexpr);
2085 p=
typet(ID_volatile);
2091 p=
typet(ID_restrict);
2108 case TOK_GCC_ATTRIBUTE:
2163 exp.add(ID_type_arg).swap(tname);
2166 typet attr(ID_aligned);
2185 typet attr(ID_aligned);
2201 std::cout << std::string(__indent,
' ') <<
"Parser::rGCCAttribute "
2218 case TOK_GCC_ATTRIBUTE_PACKED:
2220 typet attr(ID_packed);
2226 case TOK_GCC_ATTRIBUTE_TRANSPARENT_UNION:
2228 typet attr(ID_transparent_union);
2234 case TOK_GCC_ATTRIBUTE_VECTOR_SIZE:
2250 attr.add_source_location()=
exp.source_location();
2255 case TOK_GCC_ATTRIBUTE_ALIGNED:
2257 typet attr(ID_aligned);
2281 case TOK_GCC_ATTRIBUTE_MODE:
2295 typet attr(ID_gcc_attribute_mode);
2302 case TOK_GCC_ATTRIBUTE_GNU_INLINE:
2304 typet attr(ID_static);
2310 case TOK_GCC_ATTRIBUTE_WEAK:
2312 typet attr(ID_weak);
2318 case TOK_GCC_ATTRIBUTE_ALIAS:
2331 typet attr(ID_alias);
2338 case TOK_GCC_ATTRIBUTE_SECTION:
2351 typet attr(ID_section);
2358 case TOK_GCC_ATTRIBUTE_NORETURN:
2360 typet attr(ID_noreturn);
2366 case TOK_GCC_ATTRIBUTE_CONSTRUCTOR:
2368 typet attr(ID_constructor);
2374 case TOK_GCC_ATTRIBUTE_DESTRUCTOR:
2376 typet attr(ID_destructor);
2430 typet attr(ID_noreturn);
2438 typet attr(ID_nodiscard);
2467 std::cout << std::string(__indent,
' ')
2468 <<
"Parser::optIntegralTypeOrClassSpec 0\n";
2478 bool is_integral=
false;
2488 std::cout << std::string(__indent,
' ')
2489 <<
"Parser::optIntegralTypeOrClassSpec 1\n";
2496 case TOK_CHAR: type_id=ID_char;
break;
2497 case TOK_CHAR16_T: type_id=ID_char16_t;
break;
2498 case TOK_CHAR32_T: type_id=ID_char32_t;
break;
2499 case TOK_INT: type_id=ID_int;
break;
2500 case TOK_SHORT: type_id=ID_short;
break;
2501 case TOK_LONG: type_id=ID_long;
break;
2502 case TOK_SIGNED: type_id=ID_signed;
break;
2503 case TOK_WCHAR_T: type_id=ID_wchar_t;
break;
2504 case TOK_COMPLEX: type_id=ID_complex;
break;
2505 case TOK_UNSIGNED: type_id=ID_unsigned;
break;
2506 case TOK_FLOAT: type_id=ID_float;
break;
2507 case TOK_DOUBLE: type_id=ID_double;
break;
2508 case TOK_VOID: type_id=ID_void;
break;
2509 case TOK_INT8: type_id=ID_int8;
break;
2510 case TOK_INT16: type_id=ID_int16;
break;
2511 case TOK_INT32: type_id=ID_int32;
break;
2512 case TOK_INT64: type_id=ID_int64;
break;
2513 case TOK_GCC_INT128: type_id=ID_gcc_int128;
break;
2514 case TOK_GCC_FLOAT16:
2515 type_id = ID_gcc_float16;
2517 case TOK_GCC_FLOAT80: type_id=ID_gcc_float80;
break;
2518 case TOK_GCC_FLOAT128: type_id=ID_gcc_float128;
break;
2520 type_id = ID_c_bool;
2522 case TOK_CPROVER_BOOL: type_id=ID_proper_bool;
break;
2523 case TOK_AUTO: type_id = ID_auto;
break;
2527 if(!type_id.
empty())
2544 std::cout << std::string(__indent,
' ')
2545 <<
"Parser::optIntegralTypeOrClassSpec 2\n";
2552 std::cout << std::string(__indent,
' ')
2553 <<
"Parser::optIntegralTypeOrClassSpec 3\n";
2556 if(t==TOK_CLASS || t==TOK_STRUCT || t==TOK_UNION || t==TOK_INTERFACE)
2558 else if(t==TOK_ENUM)
2560 else if(t==TOK_TYPEOF)
2563 std::cout << std::string(__indent,
' ')
2564 <<
"Parser::optIntegralTypeOrClassSpec 4\n";
2571 std::cout << std::string(__indent,
' ')
2572 <<
"Parser::optIntegralTypeOrClassSpec 5\n";
2592 p.
add(ID_type_arg).
swap(tname);
2601 std::cout << std::string(__indent,
' ')
2602 <<
"Parser::optIntegralTypeOrClassSpec 6\n";
2610 std::cout << std::string(__indent,
' ')
2611 <<
"Parser::optIntegralTypeOrClassSpec 7\n";
2618 std::cout << std::string(__indent,
' ')
2619 <<
"Parser::optIntegralTypeOrClassSpec 8\n";
2622 p.
add(ID_expr_arg).
swap(expr);
2626 else if(t==TOK_DECLTYPE)
2631 p=
typet(ID_decltype);
2647 p.
add(ID_expr_arg).
swap(expr);
2651 else if(t==TOK_UNDERLYING_TYPE)
2658 p=
typet(ID_msc_underlying_type);
2675 p.
add(ID_type_arg).
swap(tname);
2694 typet &trailing_return_type)
2698 std::cout << std::string(__indent,
' ') <<
"Parser::rConstructorDecl 0\n";
2705 constructor.
name().
swap(type_name);
2712 std::cout << std::string(__indent,
' ') <<
"Parser::rConstructorDecl 1\n";
2715 irept ¶meters=constructor.
type().
add(ID_parameters);
2725 std::cout << std::string(__indent,
' ') <<
"Parser::rConstructorDecl 2\n";
2728 typet &cv=
static_cast<typet &
>(constructor.
add(ID_method_qualifier));
2737 std::cout << std::string(__indent,
' ') <<
"Parser::rConstructorDecl 3\n";
2749 std::cout << std::string(__indent,
' ') <<
"Parser::rConstructorDecl 4\n";
2763 std::cout << std::string(__indent,
' ') <<
"Parser::rConstructorDecl 5\n";
2775 constructor.
value()=
codet(
"cpp-pure-virtual");
2845 else if(t==TOK_ELLIPSIS)
2891 bool should_be_declarator,
2902 declarators.push_back(declarator);
2920 bool should_be_declarator,
2933 typet bit_field_type(ID_c_bit_field);
2934 bit_field_type.
set(ID_size, e);
2938 dw.
type() = std::move(bit_field_type);
2947 declarator,
kDeclarator, should_be_declarator, is_statement))
2992 if(declarator.
type().
id()!=ID_function_type)
3008 typet bit_field_type(ID_c_bit_field);
3009 bit_field_type.
set(ID_size, e);
3016 dw.
swap(declarator);
3033 while(t==TOK_STDCALL || t==TOK_FASTCALL || t==TOK_CLRCALL || t==TOK_CDECL)
3063 bool should_be_declarator,
3070 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 1\n";
3077 typet d_outer, d_inner;
3092 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 2\n";
3100 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 3\n";
3111 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 4\n";
3119 if(!should_be_declarator)
3124 if(t!=
'[' && t!=
'(')
3130 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 5\n";
3141 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 6\n";
3150 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 7\n";
3163 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 8\n";
3183 typet function_type(ID_function_type);
3185 function_type.
add(ID_parameters).
swap(args);
3189 d_outer.
swap(d_inner);
3195 init_args.
swap(args);
3200 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 9\n";
3209 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 10\n";
3230 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 11\n";
3248 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 12\n";
3263 std::list<typet> tl;
3264 tl.push_back(d_outer);
3265 while(tl.back().id() == ID_array)
3267 tl.push_back(tl.back().add_subtype());
3272 d_outer.
swap(array_type);
3275 tl.back().add_subtype().swap(d_outer);
3276 d_outer.
swap(tl.back());
3292 d_outer.
swap(merged_type);
3296 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 13\n";
3322 std::cout << std::string(__indent,
' ') <<
"Parser::optPtrOperator 1\n";
3325 std::list<typet> t_list;
3332 std::cout << std::string(__indent,
' ') <<
"Parser::optPtrOperator 2 " << t
3338 typet op(ID_frontend_pointer);
3349 t_list.push_back(op);
3354 typet op(ID_block_pointer);
3365 t_list.push_back(op);
3379 t_list.push_back(cv);
3382 t_list.push_back(op);
3395 typet op(ID_frontend_pointer);
3396 op.
set(ID_C_reference,
true);
3398 t_list.push_front(op);
3400 else if(t==TOK_ANDAND)
3404 typet op(ID_frontend_pointer);
3405 op.
set(ID_C_rvalue_reference,
true);
3407 t_list.push_front(op);
3411 for(std::list<typet>::reverse_iterator
3416 if(it->id()==ID_merged_type)
3419 merged_type.last_type().add_subtype().swap(ptrs);
3424 it->add_subtype().swap(ptrs);
3444 init=
irept(ID_member_initializers);
3474 std::cout << std::string(__indent,
' ') <<
"Parser::rMemberInit 1\n";
3483 std::cout << std::string(__indent,
' ') <<
"Parser::rMemberInit 2\n";
3486 init=
codet(ID_member_initializer);
3487 init.
add(ID_member).
swap(name);
3497 std::cout << std::string(__indent,
' ') <<
"Parser::rMemberInit 3\n";
3516 std::cout << std::string(__indent,
' ') <<
"Parser::rMemberInit 4\n";
3556 std::cout << std::string(__indent,
' ') <<
"Parser::rName 0\n";
3566 name.
set(ID_typename,
true);
3576 std::cout << std::string(__indent,
' ') <<
"Parser::rName 1\n";
3584 std::cout << std::string(__indent,
' ') <<
"Parser::rName 2 "
3592 std::cout << std::string(__indent,
' ') <<
"Parser::rName 3\n";
3602 std::cout << std::string(__indent,
' ') <<
"Parser::rName 4\n";
3609 components.push_back(
irept(ID_template_args));
3610 components.back().
add(ID_arguments).
swap(args);
3618 case TOK_GCC_IDENTIFIER:
3619 case TOK_MSC_IDENTIFIER:
3621 std::cout << std::string(__indent,
' ') <<
"Parser::rName 5\n";
3630 if(t!=TOK_SCOPE && t!=
'<')
3637 std::cout << std::string(__indent,
' ') <<
"Parser::rName 6\n";
3640 components.push_back(
irept(
"::"));
3646 std::cout << std::string(__indent,
' ') <<
"Parser::rName 7\n";
3654 components.push_back(
irept(
"~"));
3660 std::cout << std::string(__indent,
' ') <<
"Parser::rName 8\n";
3664 components.push_back(
irept(ID_operator));
3667 components.push_back(
irept());
3720 operator_id = std::string(1,
static_cast<char>(t));
3723 case TOK_MULTASSIGN: operator_id=
"*=";
break;
3724 case TOK_DIVASSIGN: operator_id=
"/=";
break;
3725 case TOK_MODASSIGN: operator_id=
"%=";
break;
3726 case TOK_PLUSASSIGN: operator_id=
"+=";
break;
3727 case TOK_MINUSASSIGN: operator_id=
"-=";
break;
3728 case TOK_SHLASSIGN: operator_id=
"<<=";
break;
3729 case TOK_SHRASSIGN: operator_id=
">>=";
break;
3730 case TOK_ANDASSIGN: operator_id=
"&=";
break;
3731 case TOK_XORASSIGN: operator_id=
"^=";
break;
3732 case TOK_ORASSIGN: operator_id=
"|=";
break;
3733 case TOK_SHIFTLEFT: operator_id=
"<<";
break;
3734 case TOK_SHIFTRIGHT: operator_id=
">>";
break;
3735 case TOK_EQ: operator_id=
"==";
break;
3736 case TOK_NE: operator_id=
"!=";
break;
3737 case TOK_LE: operator_id=
"<=";
break;
3738 case TOK_GE: operator_id=
">=";
break;
3739 case TOK_ANDAND: operator_id=
"&&";
break;
3740 case TOK_OROR: operator_id=
"||";
break;
3741 case TOK_INCR: operator_id=
"++";
break;
3742 case TOK_DECR: operator_id=
"--";
break;
3743 case TOK_DOTPM: operator_id=
".*";
break;
3744 case TOK_ARROWPM: operator_id=
"->*";
break;
3745 case TOK_ARROW: operator_id=
"->";
break;
3754 name=
irept(t==TOK_NEW?ID_cpp_new:ID_cpp_delete);
3759 name=
irept(t==TOK_NEW?ID_cpp_new_array:ID_cpp_delete_array);
3788 name=
irept(operator_id);
3802 typet cv1, cv2, type_name, ptr;
3817 if(!
rName(type_name))
3844 std::cout << std::string(__indent,
' ') <<
"Parser::rPtrToMember 0\n";
3847 typet ptm(ID_frontend_pointer);
3848 irept &name = ptm.
add(ID_to_member);
3858 bool loop_cond =
true;
3878 components.push_back(
irept(ID_template_args));
3879 components.back().
add(ID_arguments).
swap(args);
3887 case TOK_GCC_IDENTIFIER:
3888 case TOK_MSC_IDENTIFIER:
3895 if(t != TOK_SCOPE && t !=
'<')
3903 components.push_back(
irept(
"::"));
3910 ptr_to_mem.
swap(ptm);
3913 std::cout << std::string(__indent,
' ') <<
"Parser::rPtrToMember 1\n";
3944 std::cout << std::string(__indent,
' ') <<
"Parser::rTemplateArgs 0\n";
3955 std::cout << std::string(__indent,
' ') <<
"Parser::rTemplateArgs 1\n";
3967 std::cout << std::string(__indent,
' ') <<
"Parser::rTemplateArgs 2\n";
3976 std::cout << std::string(__indent,
' ') <<
"Parser::rTemplateArgs 3\n";
3991 std::cout << std::string(__indent,
' ') <<
"Parser::rTemplateArgs 4\n";
4003 exp.id(ID_ambiguous);
4005 std::cout << std::string(__indent,
' ') <<
"Parser::rTemplateArgs 4.1\n";
4017 std::cout << std::string(__indent,
' ') <<
"Parser::rTemplateArgs 4.2\n";
4024 std::cout << std::string(__indent,
' ') <<
"Parser::rTemplateArgs 5\n";
4042 std::cout << std::string(__indent,
' ') <<
"Parser::rTemplateArgs 6\n";
4058 case TOK_SHIFTRIGHT:
4139 else if(t==TOK_ELLIPSIS)
4151 list.
get_sub().back().swap(declaration);
4155 else if(t==TOK_ELLIPSIS)
4160 else if(t!=
')' && t!=TOK_ELLIPSIS)
4189 header=
typet(ID_register);
4207 declaration.
declarators().push_back(arg_declarator);
4237 expr.
id(ID_initializer_list);
4246 if(t==TOK_MSC_IF_EXISTS ||
4247 t==TOK_MSC_IF_NOT_EXISTS)
4357 std::cout << std::string(__indent,
' ') <<
"Parser::rEnumSpec 1\n";
4374 spec.
set(ID_C_class,
true);
4391 std::cout << std::string(__indent,
' ') <<
"Parser::rEnumSpec 2\n";
4403 std::cout << std::string(__indent,
' ') <<
"Parser::rEnumSpec 3\n";
4426 std::cout << std::string(__indent,
' ') <<
"Parser::rEnumSpec 4\n";
4498 std::cout << std::string(__indent,
' ') <<
"Parser::rClassSpec 1\n";
4502 if(t!=TOK_CLASS && t!=TOK_STRUCT &&
4503 t!=TOK_UNION && t!=TOK_INTERFACE)
4507 std::cout << std::string(__indent,
' ') <<
"Parser::rClassSpec 2\n";
4512 spec=
typet(ID_struct);
4513 spec.
set(ID_C_class,
true);
4515 else if(t==TOK_INTERFACE)
4517 spec=
typet(ID_struct);
4518 spec.
set(ID_C_interface,
true);
4520 else if(t==TOK_STRUCT)
4521 spec=
typet(ID_struct);
4522 else if(t==TOK_UNION)
4523 spec=
typet(ID_union);
4530 std::cout << std::string(__indent,
' ') <<
"Parser::rClassSpec 3\n";
4543 std::cout << std::string(__indent,
' ') <<
"Parser::rClassSpec 4\n";
4556 std::cout << std::string(__indent,
' ') <<
"Parser::rClassSpec 5\n";
4576 std::cout << std::string(__indent,
' ') <<
"Parser::rClassSpec 6\n";
4588 std::cout << std::string(__indent,
' ') <<
"Parser::rClassSpec 7\n";
4612 irept base(ID_base);
4617 base.
set(ID_virtual,
true);
4621 if(t==TOK_PUBLIC || t==TOK_PROTECTED || t==TOK_PRIVATE)
4626 base.
set(ID_protection, ID_public);
4630 base.
set(ID_protection, ID_protected);
4634 base.
set(ID_protection, ID_private);
4647 base.
set(ID_virtual,
true);
4661 bases.
get_sub().back().swap(base);
4679 std::cout << std::string(__indent,
' ') <<
"Parser::rClassBody 0\n";
4704 std::cout << std::string(__indent,
' ') <<
"Parser::rClassBody "
4705 << member.
pretty() <<
'\n';
4709 std::move(
static_cast<exprt &
>(
static_cast<irept &
>(member))));
4741 std::cout << std::string(__indent,
' ') <<
"Parser::rClassMember 0 " << t
4745 if(t==TOK_PUBLIC || t==TOK_PROTECTED || t==TOK_PRIVATE)
4750 member.
id(
"cpp-public");
4754 member.
id(
"cpp-protected");
4758 member.
id(
"cpp-private");
4774 else if(t==TOK_TYPEDEF)
4776 else if(t==TOK_TEMPLATE)
4778 else if(t==TOK_USING)
4780 else if(t==TOK_STATIC_ASSERT)
4809 name_decl.
name() = name;
4826 std::cout << std::string(__indent,
' ') <<
"Parser::rCommaExpression 0\n";
4833 std::cout << std::string(__indent,
' ') <<
"Parser::rCommaExpression 1\n";
4850 exp.add_to_operands(std::move(left), std::move(right));
4855 std::cout << std::string(__indent,
' ') <<
"Parser::rCommaExpression 2\n";
4871 std::cout << std::string(__indent,
' ') <<
"Parser::rExpression 0\n";
4878 std::cout << std::string(__indent,
' ') <<
"Parser::rExpression 1\n";
4884 t==TOK_MULTASSIGN || t==TOK_DIVASSIGN || t==TOK_MODASSIGN ||
4885 t==TOK_PLUSASSIGN || t==TOK_MINUSASSIGN || t==TOK_SHLASSIGN ||
4886 t==TOK_SHRASSIGN || t==TOK_ANDASSIGN ||
4887 t==TOK_XORASSIGN || t==TOK_ORASSIGN)
4892 std::cout << std::string(__indent,
' ') <<
"Parser::rExpression 2\n";
4900 std::cout << std::string(__indent,
' ') <<
"Parser::rExpression 3\n";
4909 exp.set(ID_statement, ID_assign);
4910 else if(t==TOK_PLUSASSIGN)
4911 exp.set(ID_statement, ID_assign_plus);
4912 else if(t==TOK_MINUSASSIGN)
4913 exp.set(ID_statement, ID_assign_minus);
4914 else if(t==TOK_MULTASSIGN)
4915 exp.set(ID_statement, ID_assign_mult);
4916 else if(t==TOK_DIVASSIGN)
4917 exp.set(ID_statement, ID_assign_div);
4918 else if(t==TOK_MODASSIGN)
4919 exp.set(ID_statement, ID_assign_mod);
4920 else if(t==TOK_SHLASSIGN)
4921 exp.set(ID_statement, ID_assign_shl);
4922 else if(t==TOK_SHRASSIGN)
4923 exp.set(ID_statement, ID_assign_shr);
4924 else if(t==TOK_ANDASSIGN)
4925 exp.set(ID_statement, ID_assign_bitand);
4926 else if(t==TOK_XORASSIGN)
4927 exp.set(ID_statement, ID_assign_bitxor);
4928 else if(t==TOK_ORASSIGN)
4929 exp.set(ID_statement, ID_assign_bitor);
4931 exp.add_to_operands(std::move(left), std::move(right));
4936 std::cout << std::string(__indent,
' ') <<
"Parser::rExpression 4\n";
4950 std::cout << std::string(__indent,
' ') <<
"Parser::rConditionalExpr 0\n";
4957 std::cout << std::string(__indent,
' ') <<
"Parser::rConditionalExpr 1\n";
4963 exprt then, otherwise;
4970 std::cout << std::string(__indent,
' ') <<
"Parser::rConditionalExpr 2\n";
4983 if_exprt(std::move(cond), std::move(then), std::move(otherwise),
typet());
4999 std::cout << std::string(__indent,
' ') <<
"Parser::rLogicalOrExpr 0\n";
5006 std::cout << std::string(__indent,
' ') <<
"Parser::rLogicalOrExpr 1\n";
5022 exp.add_to_operands(std::move(left), std::move(right));
5038 std::cout << std::string(__indent,
' ') <<
"Parser::rLogicalAndExpr 1\n";
5045 std::cout << std::string(__indent,
' ') <<
"Parser::rLogicalAndExpr 1\n";
5061 exp.add_to_operands(std::move(left), std::move(right));
5077 std::cout << std::string(__indent,
' ') <<
"Parser::rInclusiveOrExpr 0\n";
5084 std::cout << std::string(__indent,
' ') <<
"Parser::rInclusiveOrExpr 1\n";
5100 exp.add_to_operands(std::move(left), std::move(right));
5116 std::cout << std::string(__indent,
' ') <<
"Parser::rExclusiveOrExpr 0\n";
5123 std::cout << std::string(__indent,
' ') <<
"Parser::rExclusiveOrExpr 1\n";
5132 if(!
rAndExpr(right, template_args))
5139 exp.add_to_operands(std::move(left), std::move(right));
5155 std::cout << std::string(__indent,
' ') <<
"Parser::rAndExpr 0\n";
5162 std::cout << std::string(__indent,
' ') <<
"Parser::rAndExpr 1\n";
5178 exp.add_to_operands(std::move(left), std::move(right));
5194 std::cout << std::string(__indent,
' ') <<
"Parser::rEqualityExpr 0\n";
5201 std::cout << std::string(__indent,
' ') <<
"Parser::rEqualityExpr 1\n";
5218 exp.add_to_operands(std::move(left), std::move(right));
5234 std::cout << std::string(__indent,
' ') <<
"Parser::rRelationalExpr 0\n";
5241 std::cout << std::string(__indent,
' ') <<
"Parser::rRelationalExpr 1\n";
5247 (t==TOK_LE || t==TOK_GE || t==
'<' || (t==
'>' && !template_args)))
5263 case TOK_LE:
id=ID_le;
break;
5264 case TOK_GE:
id=ID_ge;
break;
5265 case '<':
id=ID_lt;
break;
5266 case '>':
id=ID_gt;
break;
5270 exp.add_to_operands(std::move(left), std::move(right));
5286 std::cout << std::string(__indent,
' ') <<
"Parser::rShiftExpr 0\n";
5293 std::cout << std::string(__indent,
' ') <<
"Parser::rShiftExpr 1\n";
5310 exp.add_to_operands(std::move(left), std::move(right));
5326 std::cout << std::string(__indent,
' ') <<
"Parser::rAdditiveExpr 0\n";
5333 std::cout << std::string(__indent,
' ') <<
"Parser::rAdditiveExpr 1\n";
5352 case '+':
id=ID_plus;
break;
5353 case '-':
id=ID_minus;
break;
5357 exp.add_to_operands(std::move(left), std::move(right));
5373 std::cout << std::string(__indent,
' ') <<
"Parser::rMultiplyExpr 0\n";
5380 std::cout << std::string(__indent,
' ') <<
"Parser::rMultiplyExpr 1\n";
5384 while(t=
lex.
LookAhead(0), (t==
'*' || t==
'/' || t==
'%'))
5399 case '*':
id=ID_mult;
break;
5400 case '/':
id=ID_div;
break;
5401 case '%':
id=ID_mod;
break;
5405 exp.add_to_operands(std::move(left), std::move(right));
5410 std::cout << std::string(__indent,
' ') <<
"Parser::rMultiplyExpr 2\n";
5426 std::cout << std::string(__indent,
' ') <<
"Parser::rPmExpr 0\n";
5433 std::cout << std::string(__indent,
' ') <<
"Parser::rPmExpr 1\n";
5450 exp.add_to_operands(std::move(left), std::move(right));
5455 std::cout << std::string(__indent,
' ') <<
"Parser::rPmExpr 2\n";
5470 std::cout << std::string(__indent,
' ') <<
"Parser::rCastExpr 0\n";
5486 std::cout << std::string(__indent,
' ') <<
"Parser::rCastExpr 1\n";
5508 exp.type().swap(tname);
5509 exp.add_to_operands(std::move(op));
5530 std::cout << std::string(__indent,
' ') <<
"Parser::rTypeName 0\n";
5539 std::cout << std::string(__indent,
' ') <<
"Parser::rTypeName 1\n";
5559 std::cout << std::string(__indent,
' ') <<
"Parser::rTypeName 2\n";
5574 std::cout << std::string(__indent,
' ')
5575 <<
"Parser::rTypeNameOrFunctionType 0\n";
5583 std::cout << std::string(__indent,
' ')
5584 <<
"Parser::rTypeNameOrFunctionType 1\n";
5596 std::cout << std::string(__indent,
' ')
5597 <<
"Parser::rTypeNameOrFunctionType 2\n";
5605 std::cout << std::string(__indent,
' ')
5606 <<
"Parser::rTypeNameOrFunctionType 3\n";
5611 tname.
swap(return_type);
5620 std::cout << std::string(__indent,
' ')
5621 <<
"Parser::rTypeNameOrFunctionType 4\n";
5647 type.set(ID_identifier, op.data.get(ID_C_base_name));
5657 type.set(ID_identifier, op.data.get(ID_C_base_name));
5667 std::cout << std::string(__indent,
' ')
5668 <<
"Parser::rTypeNameOrFunctionType 5\n";
5674 else if(t==TOK_ELLIPSIS)
5678 type.make_ellipsis();
5687 parameter.
swap(parameter_declaration);
5688 type.parameters().push_back(parameter);
5696 else if(t==TOK_ELLIPSIS)
5702 type.make_ellipsis();
5710 std::cout << std::string(__indent,
' ')
5711 <<
"Parser::rTypeNameOrFunctionType 6\n";
5722 std::cout << std::string(__indent,
' ')
5723 <<
"Parser::rTypeNameOrFunctionType 7\n";
5733 std::cout << std::string(__indent,
' ')
5734 <<
"Parser::rTypeNameOrFunctionType 8\n";
5756 std::cout << std::string(__indent,
' ') <<
"Parser::rUnaryExpr 0\n";
5759 if(t==
'*' || t==
'&' || t==
'+' ||
5760 t==
'-' || t==
'!' || t==
'~' ||
5761 t==TOK_INCR || t==TOK_DECR)
5767 std::cout << std::string(__indent,
' ') <<
"Parser::rUnaryExpr 1\n";
5775 std::cout << std::string(__indent,
' ') <<
"Parser::rUnaryExpr 2\n";
5806 exp.set(ID_statement, ID_preincrement);
5811 exp.set(ID_statement, ID_predecrement);
5818 exp.add_to_operands(std::move(right));
5823 else if(t==TOK_SIZEOF)
5825 else if(t==TOK_ALIGNOF)
5827 else if(t==TOK_THROW)
5829 else if(t==TOK_NOEXCEPT)
5831 else if(t==TOK_REAL || t==TOK_IMAG)
5842 exp=
exprt(t==TOK_REAL?ID_complex_real:ID_complex_imag);
5843 exp.add_to_operands(std::move(unary));
5863 std::cout << std::string(__indent,
' ') <<
"Parser::rThrowExpr 0\n";
5874 if(t==
':' || t==
';')
5885 exp.add_to_operands(std::move(e));
5902 std::cout << std::string(__indent,
' ') <<
"Parser::rTypeidExpr 0\n";
5968 std::cout << std::string(__indent,
' ') <<
"Parser::rSizeofExpr 0\n";
5987 exp.add(ID_type_arg).swap(tname);
6009 exp.add(ID_type_arg).swap(tname);
6024 exp.add_to_operands(std::move(unary));
6053 exp.add(ID_type_arg).swap(tname);
6068 std::cout << std::string(__indent,
' ') <<
"Parser::rNoexceptExpr 0\n";
6087 exp.add_to_operands(std::move(subexp));
6104 return t==TOK_NEW || t==TOK_DELETE;
6119 std::cout << std::string(__indent,
' ') <<
"Parser::rAllocateExpr 0\n";
6130 std::cout << std::string(__indent,
' ') <<
"Parser::rAllocateExpr 1\n";
6136 std::cout << std::string(__indent,
' ') <<
"Parser::rAllocateExpr 2\n";
6151 exp.set(ID_statement, ID_cpp_delete_array);
6156 exp.set(ID_statement, ID_cpp_delete);
6164 exp.add_to_operands(std::move(obj));
6171 std::cout << std::string(__indent,
' ') <<
"Parser::rAllocateExpr 3\n";
6175 exp.set(ID_statement, ID_cpp_new);
6178 exprt arguments, initializer;
6184 std::cout << std::string(__indent,
' ') <<
"Parser::rAllocateExpr 4\n";
6187 exp.add(ID_initializer).swap(initializer);
6319 decl.
swap(array_type);
6390 std::cout << std::string(__indent,
' ') <<
"Parser::rPostfixExpr 0\n";
6397 std::cout << std::string(__indent,
' ') <<
"Parser::rPostfixExpr 1\n";
6414 std::cout << std::string(__indent,
' ') <<
"Parser::rPostfixExpr 2\n";
6425 exp.add_to_operands(std::move(left), std::move(e));
6432 std::cout << std::string(__indent,
' ') <<
"Parser::rPostfixExpr 3\n";
6443 std::cout << std::string(__indent,
' ') <<
"Parser::rPostfixExpr 4\n";
6453 fc.arguments().push_back(*it);
6486 std::cout << std::string(__indent,
' ') <<
"Parser::rPostfixExpr 5\n";
6493 std::cout << std::string(__indent,
' ') <<
"Parser::rPostfixExpr 6\n";
6505 exp.add_to_operands(std::move(left));
6509 exp.add(ID_component_cpp_name).swap(e);
6545 expr=
exprt(ID_msc_uuidof);
6546 expr.
add(ID_type_arg).
swap(tname);
6563 expr=
exprt(ID_msc_uuidof);
6580 if(tk1.
kind!=TOK_MSC_IF_EXISTS &&
6581 tk1.
kind!=TOK_MSC_IF_NOT_EXISTS)
6609 tk1.
kind==TOK_MSC_IF_EXISTS?ID_msc_if_exists:
6610 ID_msc_if_not_exists);
6625 if(tk1.
kind != TOK_MSC_IF_EXISTS && tk1.
kind != TOK_MSC_IF_NOT_EXISTS)
6649 block.
add(std::move(*statement));
6658 tk1.
kind == TOK_MSC_IF_EXISTS ? ID_msc_if_exists : ID_msc_if_not_exists);
6664 return std::move(code);
6683 typet tname1, tname2;
6687 case TOK_UNARY_TYPE_PREDICATE:
6694 expr.
add(ID_type_arg).
swap(tname1);
6697 case TOK_BINARY_TYPE_PREDICATE:
6708 expr.
add(
"type_arg1").
swap(tname1);
6709 expr.
add(
"type_arg2").
swap(tname2);
6742 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 0 "
6755 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 1\n";
6764 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 2\n";
6773 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 3\n";
6782 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 4\n";
6791 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 5\n";
6801 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 6\n";
6807 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 7\n";
6816 exp.set(ID_statement, ID_statement_expression);
6818 exp.add_to_operands(std::move(*code));
6834 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 8\n";
6844 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 9\n";
6850 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 10\n";
6857 case TOK_UNARY_TYPE_PREDICATE:
6858 case TOK_BINARY_TYPE_PREDICATE:
6860 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 11\n";
6864 case TOK_MSC_UUIDOF:
6866 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 12\n";
6872 case TOK_MSC_IF_EXISTS:
6873 case TOK_MSC_IF_NOT_EXISTS:
6875 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 13\n";
6881 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 14\n";
6890 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 15\n";
6903 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 16\n";
6913 exp=
exprt(
"explicit-constructor-call");
6914 exp.type().swap(type);
6915 exp.add_to_operands(std::move(
exp2));
6929 exp=
exprt(
"explicit-constructor-call");
6930 exp.type().swap(type);
6931 exp.operands().swap(
exp2.operands());
6953 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 17\n";
6974 std::cout << std::string(__indent,
' ') <<
"Parser::rVarName 0\n";
6987 std::cout << std::string(__indent,
' ') <<
"Parser::rVarNameCore 0\n";
6997 name.
set(ID_typename,
true);
7007 std::cout << std::string(__indent,
' ') <<
"Parser::rVarNameCore 1\n";
7015 std::cout << std::string(__indent,
' ') <<
"Parser::rVarNameCore 1.1 "
7025 std::cout << std::string(__indent,
' ') <<
"Parser::rVarNameCore 2\n";
7033 case TOK_GCC_IDENTIFIER:
7034 case TOK_MSC_IDENTIFIER:
7036 std::cout << std::string(__indent,
' ') <<
"Parser::rVarNameCore 3\n";
7049 std::cout << std::string(__indent,
' ') <<
"Parser::rVarNameCore 4\n";
7059 components.push_back(
irept(ID_template_args));
7060 components.back().add(ID_arguments).swap(args);
7069 std::cout << std::string(__indent,
' ') <<
"Parser::rVarNameCore 5\n";
7073 components.push_back(
irept(
"::"));
7079 std::cout << std::string(__indent,
' ') <<
"Parser::rVarNameCore 6\n";
7087 components.push_back(
irept(
"~"));
7093 std::cout << std::string(__indent,
' ') <<
"Parser::rVarNameCore 7\n";
7098 components.push_back(
irept(ID_operator));
7106 components.push_back(op);
7121 if(
is_identifier(t) || t ==
'~' || t == TOK_OPERATOR || t == TOK_TEMPLATE)
7140 std::cout << std::string(__indent,
' ') <<
"Parser::maybeTemplateArgs 0\n";
7149 if(u==
'\0' || u==
';' || u==
'}')
7151 else if((u==
'>' || u==TOK_SHIFTRIGHT) &&
7162 std::cout << std::string(__indent,
' ')
7163 <<
"Parser::maybeTemplateArgs 1\n";
7169 std::cout << std::string(__indent,
' ')
7170 <<
"Parser::maybeTemplateArgs 2\n";
7185 std::cout << std::string(__indent,
' ')
7186 <<
"Parser::maybeTemplateArgs 3\n";
7193 else if(v==
'\0' || v==
';' || v==
'}')
7197 else if(u==
'\0' || u==
';' || u==
'}')
7199 else if(u==TOK_SHIFTRIGHT && n>=2)
7203 std::cout << std::string(__indent,
' ')
7204 <<
"Parser::maybeTemplateArgs 4\n";
7209 std::cout << std::string(__indent,
' ') <<
"Parser::maybeTemplateArgs 5\n";
7215 std::cout << std::string(__indent,
' ') <<
"Parser::maybeTemplateArgs 6\n";
7218 return t==TOK_SCOPE || t==
'(';
7223 std::cout << std::string(__indent,
' ') <<
"Parser::maybeTemplateArgs 7\n";
7254 declarator.
value()=body;
7264 declarator.
value() = std::move(*body);
7287 std::cout << std::string(__indent,
' ') <<
"Parser::rCompoundStatement 1\n";
7294 std::cout << std::string(__indent,
' ') <<
"Parser::rCompoundStatement 2\n";
7303 statement.
add(std::move(*statement2));
7311 return std::move(statement);
7318 return std::move(statement);
7349 std::cout << std::string(__indent,
' ') <<
"Parser::rStatement 0 "
7390 codet statement(k == TOK_BREAK ? ID_break : ID_continue);
7396 return std::move(statement);
7401 std::cout << std::string(__indent,
' ') <<
"Parser::rStatement RETURN 0\n";
7412 std::cout << std::string(__indent,
' ')
7413 <<
"Parser::rStatement RETURN 1\n";
7420 std::cout << std::string(__indent,
' ')
7421 <<
"Parser::rStatement RETURN 2\n";
7428 std::cout << std::string(__indent,
' ')
7429 <<
"Parser::rStatement RETURN 3\n";
7436 return std::move(statement);
7451 return std::move(statement);
7477 std::move(case_expr), std::move(range_end), std::move(*statement2));
7479 return std::move(code);
7492 std::move(case_expr), std::move(*statement2));
7494 return std::move(statement);
7513 return std::move(statement);
7525 case TOK_MSC_IF_EXISTS:
7526 case TOK_MSC_IF_NOT_EXISTS:
7529 case TOK_GCC_IDENTIFIER:
7530 case TOK_MSC_IDENTIFIER:
7542 return std::move(label);
7560 return std::move(statement);
7571 case TOK_STATIC_ASSERT:
7578 codet statement(ID_static_assert);
7580 statement.
operands().swap(cpp_static_assert.operands());
7582 return std::move(statement);
7612 if(!then.has_value())
7622 std::move(
exp), std::move(*then), std::move(*otherwise));
7624 return std::move(statement);
7633 return std::move(statement);
7662 return std::move(statement);
7693 return std::move(statement);
7711 if(!body.has_value())
7732 return std::move(statement);
7752 if(!exp1.has_value())
7782 std::move(*exp1), std::move(
exp2), std::move(exp3), std::move(*body));
7784 return std::move(statement);
7806 if(!try_body.has_value())
7823 std::optional<codet> catch_op;
7829 codet ellipsis(ID_ellipsis);
7831 catch_op = std::move(ellipsis);
7842 declaration.
declarators().size() == 1,
"exactly one declarator");
7844 if(declaration.
declarators().front().name().is_nil())
7851 catch_op = std::move(code_decl);
7870 return std::move(statement);
7885 if(!body1.has_value())
7890 codet statement(ID_msc_try_except);
7910 std::move(*body1), std::move(
exp), std::move(*body2));
7911 return std::move(statement);
7918 codet statement(ID_msc_try_finally);
7926 return std::move(statement);
7945 codet statement(ID_msc_leave);
7948 return std::move(statement);
7957 std::cout << std::string(__indent,
' ') <<
"Parser::rGCCAsmStatement 1\n";
7972 std::cout << std::string(__indent,
' ') <<
"Parser::rGCCAsmStatement 3\n";
7983 std::cout << std::string(__indent,
' ') <<
"Parser::rGCCAsmStatement 3\n";
7989 std::cout << std::string(__indent,
' ') <<
"Parser::rGCCAsmStatement 4\n";
8010 std::cout << std::string(__indent,
' ')
8011 <<
"Parser::rGCCAsmStatement 5\n";
8019 std::cout << std::string(__indent,
' ')
8020 <<
"Parser::rGCCAsmStatement 6\n";
8035 std::cout << std::string(__indent,
' ') <<
"Parser::rGCCAsmStatement 7\n";
8044 std::cout << std::string(__indent,
' ') <<
"Parser::rGCCAsmStatement 8\n";
8047 return std::move(statement);
8056 std::cout << std::string(__indent,
' ') <<
"Parser::rMSCAsmStatement 1\n";
8070 std::cout << std::string(__indent,
' ') <<
"Parser::rMSCAsmStatement 2\n";
8078 std::cout << std::string(__indent,
' ') <<
"Parser::rMSCAsmStatement 3\n";
8091 std::cout << std::string(__indent,
' ') <<
"Parser::rMSCAsmStatement 4\n";
8097 std::cout << std::string(__indent,
' ') <<
"Parser::rMSCAsmStatement 5\n";
8101 return std::move(statement);
8107 std::cout << std::string(__indent,
' ') <<
"Parser::rMSCAsmStatement 6\n";
8112 std::cout << std::string(__indent,
' ') <<
"Parser::rMSCAsmStatement 7\n";
8115 return std::move(statement);
8132 std::cout << std::string(__indent,
' ') <<
"Parser::rExprStatement 0\n";
8138 std::cout << std::string(__indent,
' ') <<
"Parser::rExprStatement 1\n";
8144 return std::move(statement);
8149 std::cout << std::string(__indent,
' ') <<
"Parser::rExprStatement 2\n";
8157 std::cout << std::string(__indent,
' ') <<
"rDe " << statement->pretty()
8169 std::cout << std::string(__indent,
' ') <<
"Parser::rExprStatement 3\n";
8176 std::cout << std::string(__indent,
' ') <<
"Parser::rExprStatement 4\n";
8180 std::cout << std::string(__indent,
' ') <<
"Parser::rExprStatement 5 "
8188 std::cout << std::string(__indent,
' ') <<
"Parser::rExprStatement 6\n";
8193 return std::move(expr_statement);
8208 statement=
codet(ID_decl);
8240 typet cv_q, integral;
8245 std::cout << std::string(__indent,
' ')
8246 <<
"Parser::rDeclarationStatement 1\n";
8268 std::cout << std::string(__indent,
' ')
8269 <<
"Parser::rDeclarationStatement 2\n";
8279 std::cout << std::string(__indent,
' ')
8280 <<
"Parser::rDeclarationStatement 3 " << t <<
'\n';
8288 std::cout << std::string(__indent,
' ')
8289 <<
"Parser::rDeclarationStatement 4\n";
8329 return std::move(statement);
8342 return std::move(statement);
8350 std::optional<codet>
8358 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclStatement 1\n";
8361 if(!
rName(type_name))
8365 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclStatement 2\n";
8372 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclStatement 3\n";
8378 declaration.
type().
swap(type_name);
8385 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclStatement 4\n";
8394 return std::move(statement);
8409 if(t==token || t==
'\0')
8438 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)
bool rUsingOrTypedef(cpp_itemt &)
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)
#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)