31 static unsigned __indent;
35 indenter() { __indent+=2; }
36 ~indenter() { __indent-=2; }
42 lex.LookAhead(0, _tk); \ 43 std::cout << std::string(__indent, ' ') << "Text [" << _tk.line_no << "]: " \ 44 << _tk.text << '\n'; \ 69 NON_TYPE_TEMPLATE_PARAMETER,
70 TYPE_TEMPLATE_PARAMETER,
71 TEMPLATE_TEMPLATE_PARAMETER
79 return kind==kindt::TYPEDEF ||
80 kind==kindt::TYPE_TEMPLATE_PARAMETER ||
82 kind==kindt::CLASS_TEMPLATE;
87 return kind==kindt::FUNCTION_TEMPLATE ||
88 kind==kindt::CLASS_TEMPLATE ||
89 kind==kindt::MEMBER_TEMPLATE;
94 return kind==kindt::NAMESPACE ||
96 kind==kindt::TYPE_TEMPLATE_PARAMETER;
105 case kindt::TEMPLATE:
109 case kindt::FUNCTION:
111 case kindt::VARIABLE:
117 case kindt::NAMESPACE:
119 case kindt::CLASS_TEMPLATE:
120 return "CLASS_TEMPLATE";
121 case kindt::MEMBER_TEMPLATE:
122 return "MEMBER_TEMPLATE";
123 case kindt::FUNCTION_TEMPLATE:
124 return "FUNCTION_TEMPLATE";
127 case kindt::NON_TYPE_TEMPLATE_PARAMETER:
128 return "NON_TYPE_TEMPLATE_PARAMETER";
129 case kindt::TYPE_TEMPLATE_PARAMETER:
130 return "TYPE_TEMPLATE_PARAMETER";
131 case kindt::TEMPLATE_TEMPLATE_PARAMETER:
132 return "TEMPLATE_TEMPLATE_PARAMETER";
138 typedef std::map<irep_idt, new_scopet>
id_mapt;
145 inline void print(std::ostream &out)
const 153 return "#anon"+std::to_string(anon_count);
158 return (parent==
nullptr?
"":(parent->
full_name()+
"::"))+
163 void print_rec(std::ostream &,
unsigned indent)
const;
170 scope_ptr(_scope), old_scope(_scope)
186 for(id_mapt::const_iterator
191 out << std::string(indent,
' ')
193 << kind2string(it->second.kind)
195 it->second.print_rec(out, indent+2);
203 lex(_cpp_parser.token_buffer),
207 current_scope=&root_scope;
237 bool rTypedefStatement(
codet &);
238 bool rTypeSpecifier(
typet &,
bool);
239 bool isTypeSpecifier();
247 bool rTempArgList(
irept &);
249 bool rExternTemplateDecl(
irept &);
252 bool rIntegralDeclaration(
258 bool rConstDeclaration(
263 bool rOtherDeclaration(
268 bool rCondition(
exprt &);
271 bool isConstructorDecl();
272 bool isPtrToMember(
int);
275 bool optCvQualify(
typet &);
276 bool optAlignas(
typet &);
279 bool optIntegralTypeOrClassSpec(
typet &);
280 bool rConstructorDecl(
283 typet &trailing_return_type);
284 bool optThrowDecl(
irept &);
289 bool rDeclaratorQualifier();
290 bool optPtrOperator(
typet &);
291 bool rMemberInitializers(
irept &);
292 bool rMemberInit(
exprt &);
295 bool rOperatorName(
irept &);
296 bool rCastOperatorName(
irept &);
297 bool rPtrToMember(
irept &);
298 bool rTemplateArgs(
irept &);
300 bool rArgDeclListOrInit(
exprt &,
bool&,
bool);
301 bool rArgDeclList(
irept &);
304 bool rFunctionArguments(
exprt &);
305 bool rInitializeExpr(
exprt &);
307 bool rEnumSpec(
typet &);
308 bool rEnumBody(
irept &);
309 bool rClassSpec(
typet &);
310 bool rBaseSpecifiers(
irept &);
311 bool rClassBody(
exprt &);
313 bool rAccessDecl(
irept &);
315 bool rCommaExpression(
exprt &);
317 bool rExpression(
exprt &,
bool);
318 bool rConditionalExpr(
exprt &,
bool);
319 bool rLogicalOrExpr(
exprt &,
bool);
320 bool rLogicalAndExpr(
exprt &,
bool);
321 bool rInclusiveOrExpr(
exprt &,
bool);
322 bool rExclusiveOrExpr(
exprt &,
bool);
323 bool rAndExpr(
exprt &,
bool);
324 bool rEqualityExpr(
exprt &,
bool);
325 bool rRelationalExpr(
exprt &,
bool);
326 bool rShiftExpr(
exprt &,
bool);
327 bool rAdditiveExpr(
exprt &);
328 bool rMultiplyExpr(
exprt &);
329 bool rPmExpr(
exprt &);
330 bool rCastExpr(
exprt &);
331 bool rTypeName(
typet &);
332 bool rTypeNameOrFunctionType(
typet &);
333 bool rUnaryExpr(
exprt &);
334 bool rThrowExpr(
exprt &);
335 bool rNoexceptExpr(
exprt &);
336 bool rSizeofExpr(
exprt &);
337 bool rTypeidExpr(
exprt &);
338 bool rAlignofExpr(
exprt &);
339 bool isAllocateExpr(
int);
340 bool rAllocateExpr(
exprt &);
342 bool rNewDeclarator(
typet &);
343 bool rAllocateInitializer(
exprt &);
344 bool rPostfixExpr(
exprt &);
345 bool rPrimaryExpr(
exprt &);
346 bool rVarName(
exprt &);
347 bool rVarNameCore(
exprt &);
348 bool maybeTemplateArgs();
351 bool rCompoundStatement(
codet &);
352 bool rStatement(
codet &);
353 bool rIfStatement(
codet &);
354 bool rSwitchStatement(
codet &);
355 bool rWhileStatement(
codet &);
356 bool rDoStatement(
codet &);
357 bool rForStatement(
codet &);
358 bool rTryStatement(
codet &);
360 bool rExprStatement(
codet &);
361 bool rDeclarationStatement(
codet &);
365 bool MaybeTypeNameOrClassTemplate(
cpp_tokent &);
366 void SkipTo(
int token);
372 bool rGCCAsmStatement(
codet &);
375 bool rMSC_tryStatement(
codet &);
376 bool rMSC_leaveStatement(
codet &);
377 bool rMSCAsmStatement(
codet &);
378 bool rMSC_if_existsStatement(
codet &);
379 bool rTypePredicate(
exprt &);
380 bool rMSCuuidof(
exprt &);
381 bool rMSC_if_existsExpr(
exprt &);
386 void merge_types(
const typet &src,
typet &dest);
394 if(!current_function.
empty())
404 if(p->
id()==ID_merged_type)
423 if(cpp_name.
get_sub().size()==1 &&
424 cpp_name.
get_sub().front().id()==ID_name)
425 id=cpp_name.
get_sub().front().get(ID_identifier);
427 id=current_scope->get_anon_id();
429 return add_id(
id, kind);
472 if(dest.
id()!=ID_merged_type)
474 typet tmp(ID_merged_type);
485 #define ERROR_TOKENS 4 490 lex.LookAhead(i, t[i]);
495 source_location.
set_file(t[0].filename);
496 source_location.
set_line(std::to_string(t[0].line_no));
498 std::string message=
"parse error before `";
510 parser.error().source_location=source_location;
514 return ++number_of_errors < max_errors;
519 while(lex.LookAhead(0)!=
'\0')
520 if(rDefinition(item))
549 int t=lex.LookAhead(0);
553 std::cout << std::string(__indent,
' ') <<
"Parser::rDefinition 1 " << t
573 lex.LookAhead(2)==
'=')
587 if(lex.get_token(tk)!=
';')
590 set_location(decl, tk);
608 std::cout << std::string(__indent,
' ') <<
"Parser::rTypedef 1\n";
612 set_location(declaration, tk);
615 if(!rTypeSpecifier(declaration.
type(),
true))
637 std::cout << std::string(__indent,
' ') <<
"Parser::rTypedefUsing 1\n";
641 set_location(declaration, tk);
653 std::cout << std::string(__indent,
' ') <<
"Parser::rTypedefUsing 2\n";
656 if(lex.get_token(tk)!=
'=')
659 if(!rTypeNameOrFunctionType(type_name))
662 merge_types(type_name, declaration.
type());
666 if(lex.get_token(tk)!=
';')
670 std::cout << std::string(__indent,
' ') <<
"Parser::rTypedefUsing 3\n";
678 statement=
codet(ID_decl);
691 std::cout << std::string(__indent,
' ') <<
"Parser::rTypeSpecifier 0\n";
698 if(!optCvQualify(cv_q))
702 std::cout << std::string(__indent,
' ') <<
"Parser::rTypeSpecifier 0.1\n";
705 if(!optIntegralTypeOrClassSpec(tspec))
711 lex.LookAhead(0, tk);
714 std::cout << std::string(__indent,
' ') <<
"Parser::rTypeSpecifier 1\n";
718 if(!MaybeTypeNameOrClassTemplate(tk))
722 std::cout << std::string(__indent,
' ') <<
"Parser::rTypeSpecifier 2\n";
730 std::cout << std::string(__indent,
' ') <<
"Parser::rTypeSpecifier 3\n";
733 if(!optCvQualify(cv_q))
736 merge_types(cv_q, tspec);
739 std::cout << std::string(__indent,
' ') <<
"Parser::rTypeSpecifier 4\n";
749 int t=lex.LookAhead(0);
790 set_location(linkage_spec, tk1);
792 set_location(linkage_spec.
linkage(), tk2);
794 if(lex.LookAhead(0)==
'{')
796 if(!rLinkageBody(linkage_spec.
items()))
803 if(!rDefinition(item))
806 linkage_spec.
items().push_back(item);
822 bool is_inline=
false;
835 if(lex.LookAhead(0)==
'{')
840 name=tk2.
data.
get(ID_C_base_name);
846 set_location(namespace_spec, tk1);
850 switch(lex.LookAhead(0))
853 return rLinkageBody(namespace_spec.
items());
857 return rName(namespace_spec.
alias());
861 return rDefinition(namespace_spec.
items().back());
876 set_location(cpp_using, tk);
884 if(!rName(cpp_using.
name()))
887 if(lex.get_token(tk)!=
';')
904 set_location(cpp_static_assert, tk);
906 if(lex.get_token(tk)!=
'(')
909 if(!rExpression(cpp_static_assert.
cond(),
false))
912 if(lex.get_token(tk)!=
',')
915 if(!rExpression(cpp_static_assert.
description(),
false))
918 if(lex.get_token(tk)!=
')')
921 if(lex.get_token(tk)!=
';')
936 if(lex.get_token(op)!=
'{')
940 while(lex.LookAhead(0)!=
'}')
944 if(!rDefinition(item))
951 items.push_back(item);
955 items.push_back(item);
985 current_scope->id_map.clear();
988 if(!rTemplateDecl2(template_type, kind))
994 if(!rTypedefUsing(body))
997 else if(!rDeclaration(body))
1006 std::cout << std::string(__indent,
' ') <<
"BODY: " 1007 << body.
pretty() <<
'\n';
1008 std::cout << std::string(__indent,
' ') <<
"TEMPLATE_TYPE: " 1009 << template_type.
pretty() <<
'\n';
1011 body.
add(ID_template_type).
swap(template_type);
1012 body.
set(ID_is_template,
true);
1016 case tdk_instantiation:
1021 case tdk_specialization:
1022 body.
add(ID_template_type).
swap(template_type);
1023 body.
set(ID_is_template,
true);
1042 decl=
typet(ID_template);
1043 set_location(decl, tk);
1045 if(lex.LookAhead(0)!=
'<')
1048 kind=tdk_instantiation;
1052 if(lex.get_token(tk)!=
'<')
1055 irept &template_parameters=decl.
add(ID_template_parameters);
1057 if(!rTempArgList(template_parameters))
1060 if(lex.get_token(tk)!=
'>')
1067 if(lex.LookAhead(0)!=
'<')
1072 if(!rTempArgList(dummy_args))
1075 if(lex.get_token(tk)!=
'>')
1079 if(template_parameters.
get_sub().empty())
1081 kind=tdk_specialization;
1096 if(lex.LookAhead(0)==
'>')
1100 if(!rTempArgDeclaration(a))
1104 args.
get_sub().back().swap(a);
1106 while(lex.LookAhead(0)==
',')
1111 if(!rTempArgDeclaration(a))
1115 args.
get_sub().back().swap(a);
1132 std::cout << std::string(__indent,
' ') <<
"Parser::rTempArgDeclaration 0\n";
1135 int t0=lex.LookAhead(0);
1145 set_location(declaration, tk1);
1147 declaration.
set(ID_is_type,
true);
1148 declaration.
type()=
typet(
"cpp-template-type");
1156 set_location(declarator, tk1);
1158 bool has_ellipsis=
false;
1174 exprt name(ID_name);
1175 name.
set(ID_identifier, tk2.
data.
get(ID_C_base_name));
1176 set_location(name, tk2);
1177 cpp_name.
get_sub().push_back(name);
1188 if(lex.LookAhead(0)==
'=')
1196 if(!rTypeName(default_type))
1203 if(lex.LookAhead(0)==
',' ||
1204 lex.LookAhead(0)==
'>')
1211 std::cout << std::string(__indent,
' ') <<
"Parser::rTempArgDeclaration 1\n";
1218 typet template_type;
1220 if(!rTemplateDecl2(template_type, kind))
1235 if(lex.LookAhead(0)==
'=')
1239 if(!rTypeName(default_type))
1249 std::cout << std::string(__indent,
' ')
1250 <<
"Parser::rTempArgDeclaration 2\n";
1254 declaration.
set(ID_is_type,
false);
1256 if(!rTypeSpecifier(declaration.
type(),
true))
1260 std::cout << std::string(__indent,
' ')
1261 <<
"Parser::rTempArgDeclaration 3\n";
1264 bool has_ellipsis=
false;
1277 if(!rDeclarator(declarator, kArgDeclarator,
false,
true))
1281 std::cout << std::string(__indent,
' ')
1282 <<
"Parser::rTempArgDeclaration 4\n";
1294 if(lex.LookAhead(0)==
'=')
1302 if(!rConditionalExpr(value,
true))
1327 if(!rDeclaration(body))
1369 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclaration 0.1 token: " 1370 << lex.LookAhead(0) <<
'\n';
1373 if(!optAttribute(declaration))
1377 if(!optMemberSpec(member_spec))
1381 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclaration 0.2\n";
1385 if(!optStorageSpec(storage_spec))
1389 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclaration 1\n";
1393 if(!optMemberSpec(member_spec))
1397 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclaration 3\n";
1400 typet cv_q, integral;
1403 if(!optCvQualify(cv_q))
1407 if(!optStorageSpec(storage_spec))
1410 if(!optCvQualify(cv_q))
1414 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclaration 4\n";
1417 if(!optIntegralTypeOrClassSpec(integral))
1422 if(!optMemberSpec(member_spec))
1428 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclaration 5\n";
1431 rIntegralDeclaration(
1432 declaration, storage_spec, member_spec, integral, cv_q);
1436 int t=lex.LookAhead(0);
1439 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclaration 6 " << t
1445 return rConstDeclaration(declaration, storage_spec, member_spec, cv_q);
1447 return rOtherDeclaration(declaration, storage_spec, member_spec, cv_q);
1455 typet cv_q, integral;
1468 if(!optCvQualify(cv_q))
1471 if(!optIntegralTypeOrClassSpec(integral))
1479 merge_types(cv_q, integral);
1481 integral.
swap(cv_q);
1487 merge_types(cv_q, integral);
1492 if(!rDeclarator(declarator, kDeclarator,
false,
true,
true))
1497 if(lex.LookAhead(0)!=
'=')
1503 if(!rExpression(declarator.
value(),
false))
1520 std::cout << std::string(__indent,
' ')
1521 <<
"Parser::rIntegralDeclaration 1 token: " 1522 <<
static_cast<char>(lex.LookAhead(0)) <<
"\n";
1525 if(!optCvQualify(cv_q))
1529 std::cout << std::string(__indent,
' ') <<
"Parser::rIntegralDeclaration 2\n";
1532 merge_types(cv_q, integral);
1535 std::cout << std::string(__indent,
' ') <<
"Parser::rIntegralDeclaration 3\n";
1544 switch(lex.LookAhead(0))
1548 std::cout << std::string(__indent,
' ')
1549 <<
"Parser::rIntegralDeclaration 4\n";
1557 std::cout << std::string(__indent,
' ')
1558 <<
"Parser::rIntegralDeclaration 5\n";
1566 if(!rExpression(width,
false))
1569 if(lex.get_token(tk)!=
';')
1578 std::cout << std::string(__indent,
' ')
1579 <<
"Parser::rIntegralDeclaration 6 " 1580 << lex.LookAhead(0) <<
"\n";
1583 if(!rDeclarators(declaration.
declarators(),
true))
1587 std::cout << std::string(__indent,
' ')
1588 <<
"Parser::rIntegralDeclaration 7\n";
1591 if(lex.LookAhead(0)==
';')
1594 std::cout << std::string(__indent,
' ')
1595 <<
"Parser::rIntegralDeclaration 8 " 1596 << declaration.
pretty() <<
'\n';
1604 std::cout << std::string(__indent,
' ')
1605 <<
"Parser::rIntegralDeclaration 9\n";
1611 if(!rFunctionBody(declaration.
declarators().front()))
1615 std::cout << std::string(__indent,
' ')
1616 <<
"Parser::rIntegralDeclaration 10\n";
1632 std::cout << std::string(__indent,
' ') <<
"Parser::rConstDeclaration\n";
1637 if(!rDeclarators(declarators,
false))
1640 if(lex.LookAhead(0)!=
';')
1659 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 1\n";
1662 if(!rName(type_name))
1665 merge_types(cv_q, type_name);
1668 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 2\n";
1673 if(!optMemberSpec(member_spec))
1678 if(!optStorageSpec(storage_spec))
1682 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 3\n";
1685 bool is_constructor = isConstructorDecl();
1686 bool is_operator =
false;
1691 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 4\n";
1694 assert(!type_name.
get_sub().empty());
1696 for(
unsigned i=0; i < type_name.
get_sub().size(); i++)
1698 if(type_name.
get_sub()[i].id() == ID_operator)
1706 if(is_operator && is_constructor)
1709 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 5\n";
1713 typet type = type_name;
1717 typet trailing_return_type;
1718 if(!rConstructorDecl(
1719 conv_operator_declarator, type_name, trailing_return_type))
1722 type_name=
typet(
"cpp-cast-operator");
1724 declaration.
declarators().push_back(conv_operator_declarator);
1726 else if(cv_q.
is_nil() && is_constructor)
1729 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 6\n";
1732 assert(!type_name.
get_sub().empty());
1734 bool is_destructor=
false;
1743 typet trailing_return_type;
1744 if(!rConstructorDecl(
1745 constructor_declarator, type_name, trailing_return_type))
1749 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 7\n";
1754 type_name=trailing_return_type;
1756 type_name=
typet(is_destructor?ID_destructor:ID_constructor);
1758 declaration.
declarators().push_back(constructor_declarator);
1760 else if(!member_spec.
is_empty() && lex.LookAhead(0)==
';')
1763 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 8\n";
1781 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 9\n";
1784 if(!optCvQualify(cv_q))
1787 merge_types(cv_q, type_name);
1789 if(!rDeclarators(declaration.
declarators(),
false))
1793 declaration.
type().
swap(type_name);
1798 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 10\n";
1801 if(lex.LookAhead(0)==
';')
1804 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 11\n";
1813 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclaration 12\n";
1819 if(!rFunctionBody(declaration.
declarators().front()))
1837 std::cout << std::string(__indent,
' ') <<
"Parser::isConstructorDecl " 1838 << lex.LookAhead(0) <<
" "<< lex.LookAhead(1) <<
"\n";
1841 if(lex.LookAhead(0)!=
'(')
1845 int t=lex.LookAhead(1);
1846 if(t==
'*' || t==
'&' || t==
'(')
1850 else if(isPtrToMember(1))
1855 if(lex.LookAhead(2)==
')' &&
1856 lex.LookAhead(3)==
'(')
1871 int t0=lex.LookAhead(i++);
1874 t0=lex.LookAhead(i++);
1878 int t=lex.LookAhead(i++);
1884 int u=lex.LookAhead(i++);
1894 int v=lex.LookAhead(i++);
1899 else if(v==
'\0' || v==
';' || v==
'}')
1903 else if(u==
'\0' || u==
';' || u==
'}')
1907 t=lex.LookAhead(i++);
1913 t0=lex.LookAhead(i++);
1928 member_spec.
clear();
1930 int t=lex.LookAhead(0);
1943 default: assert(
false);
1958 int t=lex.LookAhead(0);
1980 default: assert(
false);
1983 set_location(storage_spec, tk);
1996 int t=lex.LookAhead(0);
2009 p=
typet(ID_constexpr);
2010 set_location(p, tk);
2016 set_location(p, tk);
2021 p=
typet(ID_volatile);
2022 set_location(p, tk);
2027 p=
typet(ID_restrict);
2028 set_location(p, tk);
2034 set_location(p, tk);
2040 set_location(p, tk);
2074 if(lex.LookAhead(0)!=
'(')
2083 if(rTypeName(tname))
2085 if(lex.get_token(cp)==
')')
2096 if(!rUnaryExpr(unary))
2113 if(lex.LookAhead(0)!=
')')
2130 if(lex.LookAhead(0)!=
'[' ||
2131 lex.LookAhead(1)!=
'[')
2175 std::cout << std::string(__indent,
' ')
2176 <<
"Parser::optIntegralTypeOrClassSpec 0\n";
2186 bool is_integral=
false;
2196 std::cout << std::string(__indent,
' ')
2197 <<
"Parser::optIntegralTypeOrClassSpec 1\n";
2204 case TOK_CHAR: type_id=ID_char;
break;
2207 case TOK_INT: type_id=ID_int;
break;
2208 case TOK_SHORT: type_id=ID_short;
break;
2209 case TOK_LONG: type_id=ID_long;
break;
2214 case TOK_FLOAT: type_id=ID_float;
break;
2216 case TOK_VOID: type_id=ID_void;
break;
2217 case TOK_INT8: type_id=ID_int8;
break;
2218 case TOK_INT16: type_id=ID_int16;
break;
2219 case TOK_INT32: type_id=ID_int32;
break;
2220 case TOK_INT64: type_id=ID_int64;
break;
2223 case TOK_BOOL: type_id=ID_bool;
break;
2228 if(!type_id.
empty())
2234 set_location(kw, tk);
2245 std::cout << std::string(__indent,
' ')
2246 <<
"Parser::optIntegralTypeOrClassSpec 2\n";
2253 std::cout << std::string(__indent,
' ')
2254 <<
"Parser::optIntegralTypeOrClassSpec 3\n";
2258 return rClassSpec(p);
2260 return rEnumSpec(p);
2264 std::cout << std::string(__indent,
' ')
2265 <<
"Parser::optIntegralTypeOrClassSpec 4\n";
2269 lex.get_token(typeof_tk);
2272 std::cout << std::string(__indent,
' ')
2273 <<
"Parser::optIntegralTypeOrClassSpec 5\n";
2277 set_location(p, typeof_tk);
2280 if(lex.get_token(tk)!=
'(')
2289 if(rTypeName(tname))
2291 if(lex.get_token(tk)==
')')
2293 p.
add(ID_type_arg).
swap(tname);
2302 std::cout << std::string(__indent,
' ')
2303 <<
"Parser::optIntegralTypeOrClassSpec 6\n";
2307 if(!rCommaExpression(expr))
2311 std::cout << std::string(__indent,
' ')
2312 <<
"Parser::optIntegralTypeOrClassSpec 7\n";
2315 if(lex.get_token(tk)!=
')')
2319 std::cout << std::string(__indent,
' ')
2320 <<
"Parser::optIntegralTypeOrClassSpec 8\n";
2323 p.
add(ID_expr_arg).
swap(expr);
2330 lex.get_token(decltype_tk);
2332 p=
typet(ID_decltype);
2333 set_location(p, decltype_tk);
2336 if(lex.get_token(tk)!=
'(')
2342 if(!rCommaExpression(expr))
2345 if(lex.get_token(tk)!=
')')
2348 p.
add(ID_expr_arg).
swap(expr);
2357 lex.get_token(underlying_type_tk);
2359 p=
typet(ID_msc_underlying_type);
2360 set_location(p, underlying_type_tk);
2363 if(lex.get_token(tk)!=
'(')
2370 if(!rTypeName(tname))
2373 if(lex.get_token(tk)!=
')')
2376 p.
add(ID_type_arg).
swap(tname);
2395 typet &trailing_return_type)
2399 std::cout << std::string(__indent,
' ') <<
"Parser::rConstructorDecl 0\n";
2406 constructor.
name().
swap(type_name);
2409 if(lex.get_token(op)!=
'(')
2413 std::cout << std::string(__indent,
' ') <<
"Parser::rConstructorDecl 1\n";
2416 irept ¶meters=constructor.
type().
add(ID_parameters);
2418 if(lex.LookAhead(0)!=
')')
2419 if(!rArgDeclList(parameters))
2426 std::cout << std::string(__indent,
' ') <<
"Parser::rConstructorDecl 2\n";
2429 typet &cv=
static_cast<typet &
>(constructor.
add(ID_method_qualifier));
2438 std::cout << std::string(__indent,
' ') <<
"Parser::rConstructorDecl 3\n";
2443 lex.get_token(arrow);
2445 if(!rTypeSpecifier(trailing_return_type,
false))
2450 std::cout << std::string(__indent,
' ') <<
"Parser::rConstructorDecl 4\n";
2453 if(lex.LookAhead(0)==
':')
2457 if(rMemberInitializers(mi))
2464 std::cout << std::string(__indent,
' ') <<
"Parser::rConstructorDecl 5\n";
2467 if(lex.LookAhead(0)==
'=')
2472 switch(lex.get_token(value))
2476 constructor.
value()=
codet(
"cpp-pure-virtual");
2477 set_location(constructor.
value(), value);
2484 set_location(constructor.
value(), value);
2491 set_location(constructor.
value(), value);
2521 if(lex.get_token(tk)!=
'(')
2545 if(lex.LookAhead(0)==
',')
2554 if(lex.get_token(tk)!=
')')
2563 if(!rNoexceptExpr(expr))
2580 bool should_be_declarator,
2588 if(!rDeclaratorWithInit(declarator, should_be_declarator, is_statement))
2591 declarators.push_back(declarator);
2593 if(lex.LookAhead(0)==
',')
2609 bool should_be_declarator,
2612 if(lex.LookAhead(0)==
':')
2619 if(!rExpression(e,
false))
2622 typet bit_field_type(ID_c_bit_field);
2623 bit_field_type.
set(ID_size, e);
2625 set_location(bit_field_type, tk);
2635 if(!rDeclarator(declarator, kDeclarator,
false,
2636 should_be_declarator, is_statement))
2647 if(lex.get_token(tk)!=
'(')
2651 if(lex.get_token(tk)!=
')')
2655 int t=lex.LookAhead(0);
2666 set_location(declarator.
value(), tk);
2672 set_location(declarator.
value(), tk);
2676 if(!rInitializeExpr(declarator.
value()))
2685 if(declarator.
type().
id()!=ID_function_type)
2687 if(!rInitializeExpr(declarator.
value()))
2698 if(!rExpression(e,
false))
2701 typet bit_field_type(ID_c_bit_field);
2702 bit_field_type.
set(ID_size, e);
2704 set_location(bit_field_type, tk);
2706 merge_types(bit_field_type, declarator.
type());
2709 dw.
swap(declarator);
2722 int t=lex.LookAhead(0);
2757 bool should_be_declarator,
2764 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 1\n";
2768 if(!rDeclaratorQualifier())
2771 typet d_outer, d_inner;
2778 if(!optPtrOperator(d_outer))
2782 if(!rDeclaratorQualifier())
2786 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 2\n";
2794 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 3\n";
2801 if(!rDeclarator(declarator2, kind,
true,
true,
false))
2805 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 4\n";
2810 if(lex.get_token(cp)!=
')')
2813 if(!should_be_declarator)
2815 if((kind==kDeclarator || kind==kCastDeclarator) && d_outer.
is_nil())
2818 if(t!=
'[' && t!=
'(')
2824 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 5\n";
2830 else if(kind!=kCastDeclarator &&
2834 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 6\n";
2843 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 7\n";
2856 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 8\n";
2865 if(lex.LookAhead(0)==
')')
2868 if(!rArgDeclListOrInit(args, is_args, is_statement))
2871 if(lex.get_token(cp)!=
')')
2876 typet function_type(ID_function_type);
2878 function_type.
add(ID_parameters).
swap(args);
2881 make_subtype(function_type, d_inner);
2882 d_outer.
swap(d_inner);
2884 optCvQualify(method_qualifier);
2888 init_args.
swap(args);
2893 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 9\n";
2897 optThrowDecl(throw_decl);
2902 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 10\n";
2908 lex.get_token(arrow);
2911 if(!rTypeSpecifier(return_type,
false))
2915 if(lex.LookAhead(0)==
':')
2918 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 11\n";
2922 if(rMemberInitializers(mi))
2936 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 12\n";
2942 if(lex.LookAhead(0)==
']')
2945 if(!rCommaExpression(expr))
2948 if(lex.get_token(cb)!=
']')
2951 std::list<typet> tl;
2952 tl.push_back(d_outer);
2953 while(tl.back().id() == ID_array)
2955 tl.push_back(tl.back().subtype());
2958 typet array_type(ID_array);
2959 array_type.
add(ID_size).
swap(expr);
2962 d_outer.
swap(array_type);
2965 tl.back().subtype().swap(d_outer);
2966 d_outer.
swap(tl.back());
2975 std::cout << std::string(__indent,
' ') <<
"Parser::rDeclarator2 13\n";
3001 std::cout << std::string(__indent,
' ') <<
"Parser::optPtrOperator 1\n";
3004 std::list<typet> t_list;
3008 int t=lex.LookAhead(0);
3011 std::cout << std::string(__indent,
' ') <<
"Parser::optPtrOperator 2 " 3020 set_location(op, tk);
3027 merge_types(op, cv);
3028 t_list.push_back(cv);
3031 t_list.push_back(op);
3036 typet op(ID_block_pointer);
3039 set_location(op, tk);
3046 merge_types(op, cv);
3047 t_list.push_back(cv);
3050 t_list.push_back(op);
3052 else if(isPtrToMember(0))
3055 if(!rPtrToMember(op))
3063 merge_types(op, cv);
3064 t_list.push_back(cv);
3067 t_list.push_back(op);
3074 int t=lex.LookAhead(0);
3080 typet op(ID_pointer);
3081 op.
set(ID_C_reference,
true);
3082 set_location(op, tk);
3083 t_list.push_front(op);
3089 typet op(ID_pointer);
3090 op.
set(ID_C_rvalue_reference,
true);
3091 set_location(op, tk);
3092 t_list.push_front(op);
3096 for(std::list<typet>::reverse_iterator
3101 if(it->id()==ID_merged_type)
3103 assert(!it->subtypes().empty());
3104 it->subtypes().back().subtype().swap(ptrs);
3108 assert(it->is_not_nil());
3109 it->subtype().swap(ptrs);
3126 if(lex.get_token(tk)!=
':')
3129 init=
irept(ID_member_initializers);
3130 set_location(init, tk);
3138 while(lex.LookAhead(0)==
',')
3159 std::cout << std::string(__indent,
' ') <<
"Parser::rMemberInit 1\n";
3168 std::cout << std::string(__indent,
' ') <<
"Parser::rMemberInit 2\n";
3171 init=
codet(ID_member_initializer);
3172 init.
add(ID_member).
swap(name);
3176 set_location(init, tk1);
3179 (tk1.
kind==
'(' && lex.LookAhead(0)==
'{'))
3182 std::cout << std::string(__indent,
' ') <<
"Parser::rMemberInit 3\n";
3185 if(!rInitializeExpr(exp))
3201 std::cout << std::string(__indent,
' ') <<
"Parser::rMemberInit 4\n";
3206 if(!rFunctionArguments(args))
3212 if(lex.get_token(tk2)!=
')')
3241 std::cout << std::string(__indent,
' ') <<
"Parser::rName 0\n";
3251 name.
set(ID_typename,
true);
3256 lex.LookAhead(0, tk);
3257 set_location(name, tk);
3261 std::cout << std::string(__indent,
' ') <<
"Parser::rName 1\n";
3269 std::cout << std::string(__indent,
' ') <<
"Parser::rName 2 " 3270 << lex.LookAhead(0) <<
"\n";
3273 switch(lex.LookAhead(0))
3277 std::cout << std::string(__indent,
' ') <<
"Parser::rName 3\n";
3287 std::cout << std::string(__indent,
' ') <<
"Parser::rName 4\n";
3291 if(!rTemplateArgs(args))
3294 components.push_back(
irept(ID_template_args));
3295 components.back().
add(ID_arguments).
swap(args);
3305 std::cout << std::string(__indent,
' ') <<
"Parser::rName 5\n";
3308 components.push_back(
irept(ID_name));
3309 components.back().set(ID_identifier, tk.
data.
get(ID_C_base_name));
3310 set_location(components.back(), tk);
3313 int t=lex.LookAhead(0);
3322 std::cout << std::string(__indent,
' ') <<
"Parser::rName 6\n";
3325 components.push_back(
irept(
"::"));
3326 set_location(components.back(), tk);
3331 std::cout << std::string(__indent,
' ') <<
"Parser::rName 7\n";
3339 components.push_back(
irept(
"~"));
3340 set_location(components.back(), tk);
3345 std::cout << std::string(__indent,
' ') <<
"Parser::rName 8\n";
3349 components.push_back(
irept(ID_operator));
3350 set_location(components.back(), tk);
3352 components.push_back(
irept());
3354 if(!rOperatorName(components.back()))
3359 if(lex.LookAhead(0)!=
'<')
3385 int t=lex.LookAhead(0);
3405 operator_id=
irep_idt(std::string(static_cast<char>(t), 1));
3420 case TOK_EQ: operator_id=
"==";
break;
3421 case TOK_NE: operator_id=
"!=";
break;
3422 case TOK_LE: operator_id=
"<=";
break;
3423 case TOK_GE: operator_id=
">=";
break;
3425 case TOK_OROR: operator_id=
"||";
break;
3426 case TOK_INCR: operator_id=
"++";
break;
3427 case TOK_DECR: operator_id=
"--";
break;
3428 case TOK_DOTPM: operator_id=
".*";
break;
3430 case TOK_ARROW: operator_id=
"->";
break;
3437 if(lex.LookAhead(0)!=
'[')
3440 set_location(name, tk);
3444 name=
irept(t==
TOK_NEW?ID_cpp_new_array:ID_cpp_delete_array);
3445 set_location(name, tk);
3449 if(lex.get_token(tk)!=
']')
3458 set_location(name, tk);
3459 return lex.get_token(tk)==
')';
3464 set_location(name, tk);
3465 return lex.get_token(tk)==
']';
3468 return rCastOperatorName(name);
3471 assert(!operator_id.
empty());
3473 name=
irept(operator_id);
3474 set_location(name, tk);
3487 typet cv1, cv2, type_name, ptr;
3494 if(!optCvQualify(cv1))
3497 if(!optIntegralTypeOrClassSpec(type_name))
3502 if(!rName(type_name))
3506 merge_types(cv1, type_name);
3508 if(!optCvQualify(cv2))
3511 if(!optPtrOperator(ptr))
3514 make_subtype(type_name, ptr);
3515 merge_types(cv2, ptr);
3529 std::cout << std::string(__indent,
' ') <<
"Parser::rPtrToMember 0\n";
3532 irept ptm(ID_pointer);
3533 irept &name = ptm.
add(
"to-member");
3539 lex.LookAhead(0, tk);
3540 set_location(name, tk);
3543 bool loop_cond =
true;
3548 switch(lex.LookAhead(0))
3560 if(!rTemplateArgs(args))
3563 components.push_back(
irept(ID_template_args));
3564 components.back().
add(ID_arguments).
swap(args);
3573 components.push_back(
irept(ID_name));
3574 components.back().set(ID_identifier, tk.
data.
get(ID_C_base_name));
3575 set_location(components.back(), tk);
3578 int t=lex.LookAhead(0);
3586 components.push_back(
irept(
"::"));
3587 set_location(components.back(), tk);
3590 if(lex.LookAhead(0) ==
'*')
3593 ptr_to_mem.
swap(ptm);
3597 std::cout << std::string(__indent,
' ') <<
"Parser::rPtrToMember 1\n";
3628 std::cout << std::string(__indent,
' ') <<
"Parser::rTemplateArgs 0\n";
3633 if(lex.get_token(tk1)!=
'<')
3636 set_location(template_args, tk1);
3639 std::cout << std::string(__indent,
' ') <<
"Parser::rTemplateArgs 1\n";
3643 if(lex.LookAhead(0)==
'>')
3651 std::cout << std::string(__indent,
' ') <<
"Parser::rTemplateArgs 2\n";
3660 std::cout << std::string(__indent,
' ') <<
"Parser::rTemplateArgs 3\n";
3666 if(rTypeNameOrFunctionType(a) &&
3667 ((lex.LookAhead(0) ==
'>' || lex.LookAhead(0) ==
',' ||
3670 (lex.LookAhead(1) ==
'>' ||
3675 std::cout << std::string(__indent,
' ') <<
"Parser::rTemplateArgs 4\n";
3686 if(rConditionalExpr(tmp,
true))
3687 exp.
id(
"ambiguous");
3689 std::cout << std::string(__indent,
' ') <<
"Parser::rTemplateArgs 4.1\n";
3692 rTypeNameOrFunctionType(a);
3701 std::cout << std::string(__indent,
' ') <<
"Parser::rTemplateArgs 4.2\n";
3708 std::cout << std::string(__indent,
' ') <<
"Parser::rTemplateArgs 5\n";
3714 if(!rConditionalExpr(exp,
true))
3726 std::cout << std::string(__indent,
' ') <<
"Parser::rTemplateArgs 6\n";
3730 template_args.
get_sub().back().swap(exp);
3734 switch(lex.get_token(tk2))
3748 assert(lex.LookAhead(0)==
'>');
3749 assert(lex.LookAhead(1)==
'>');
3780 if(rFunctionArguments(arglist))
3781 if(lex.LookAhead(0)==
')')
3789 return(is_args=rArgDeclList(arglist));
3793 if((is_args=rArgDeclList(arglist)))
3799 return rFunctionArguments(arglist);
3818 int t=lex.LookAhead(0);
3828 else if(rArgDeclaration(declaration))
3833 list.
get_sub().back().swap(declaration);
3867 switch(lex.LookAhead(0))
3871 header=
typet(ID_register);
3879 if(!rTypeSpecifier(declaration.
type(),
true))
3884 if(!rDeclarator(arg_declarator, kArgDeclarator,
false,
true))
3887 declaration.
declarators().push_back(arg_declarator);
3889 int t=lex.LookAhead(0);
3893 if(!rInitializeExpr(declaration.
declarators().back().value()))
3907 if(lex.LookAhead(0)!=
'{')
3908 return rExpression(expr,
false);
3917 expr.
id(ID_initializer_list);
3918 set_location(expr, tk);
3920 int t=lex.LookAhead(0);
3933 if(lex.get_token(tk)!=
'(')
3937 if(lex.get_token(tk)!=
')')
3939 if(lex.get_token(tk)!=
'{')
3941 if(!rInitializeExpr(name))
3943 if(lex.LookAhead(0)==
',')
3945 if(lex.get_token(tk)!=
'}')
3949 if(!rInitializeExpr(tmp))
4000 if(lex.LookAhead(0)==
')')
4005 if(!rExpression(exp,
false))
4011 (lex.LookAhead(1)==
')' || lex.LookAhead(1)==
','))
4016 if(lex.LookAhead(0)==
')')
4020 else if(lex.LookAhead(0)!=
',')
4038 std::cout << std::string(__indent,
' ') <<
"Parser::rEnumSpec 1\n";
4048 set_location(spec, tk);
4059 if(lex.LookAhead(0)!=
'{' &&
4060 lex.LookAhead(0)!=
':')
4073 std::cout << std::string(__indent,
' ') <<
"Parser::rEnumSpec 2\n";
4077 if(lex.LookAhead(0)==
':')
4080 if(!rTypeName(spec.
subtype()))
4085 std::cout << std::string(__indent,
' ') <<
"Parser::rEnumSpec 3\n";
4088 if(lex.LookAhead(0)!=
'{')
4093 if(lex.LookAhead(0)==
'}')
4099 if(!rEnumBody(spec.
add(ID_body)))
4104 if(lex.get_token(tk)!=
'}')
4108 std::cout << std::string(__indent,
' ') <<
"Parser::rEnumSpec 4\n";
4126 if(lex.LookAhead(0)==
'}')
4134 set_location(n, tk);
4137 if(lex.LookAhead(0, tk2)==
'=')
4143 if(!rExpression(exp,
false))
4158 if(lex.LookAhead(0)!=
',')
4180 std::cout << std::string(__indent,
' ') <<
"Parser::rClassSpec 1\n";
4183 int t=lex.get_token(tk);
4189 std::cout << std::string(__indent,
' ') <<
"Parser::rClassSpec 2\n";
4194 spec=
typet(ID_struct);
4195 spec.
set(ID_C_class,
true);
4199 spec=
typet(ID_struct);
4200 spec.
set(ID_C_interface,
true);
4203 spec=
typet(ID_struct);
4205 spec=
typet(ID_union);
4209 set_location(spec, tk);
4212 std::cout << std::string(__indent,
' ') <<
"Parser::rClassSpec 3\n";
4215 if(lex.LookAhead(0)==
'{')
4219 std::cout << std::string(__indent,
' ') <<
"Parser::rClassSpec 4\n";
4224 if(!optAlignas(spec))
4234 std::cout << std::string(__indent,
' ') <<
"Parser::rClassSpec 5\n";
4241 if(!rBaseSpecifiers(spec.
add(ID_bases)))
4254 std::cout << std::string(__indent,
' ') <<
"Parser::rClassSpec 6\n";
4262 if(!rClassBody(body))
4266 std::cout << std::string(__indent,
' ') <<
"Parser::rClassSpec 7\n";
4269 ((
exprt&)spec.
add(ID_body)).operands().
swap(body.operands());
4284 if(lex.get_token(tk)!=
':')
4289 int t=lex.LookAhead(0);
4290 irept base(ID_base);
4295 base.
set(ID_virtual,
true);
4301 switch(lex.get_token(tk))
4304 base.
set(ID_protection, ID_public);
4308 base.
set(ID_protection, ID_protected);
4312 base.
set(ID_protection, ID_private);
4325 base.
set(ID_virtual,
true);
4328 if(!rName(base.
add(ID_name)))
4339 bases.
get_sub().back().swap(base);
4341 if(lex.LookAhead(0)!=
',')
4357 std::cout << std::string(__indent,
' ') <<
"Parser::rClassBody 0\n";
4360 if(lex.get_token(tk)!=
'{')
4365 set_location(members, tk);
4367 while(lex.LookAhead(0)!=
'}')
4371 if(!rClassMember(member))
4382 std::cout << std::string(__indent,
' ') <<
"Parser::rClassBody " 4383 << member.
pretty() <<
'\n';
4387 static_cast<exprt &>(static_cast<irept &>(member)));
4415 int t=lex.LookAhead(0);
4419 std::cout << std::string(__indent,
' ') <<
"Parser::rClassMember 0 " << t
4425 switch(lex.get_token(tk1))
4428 member.
id(
"cpp-public");
4432 member.
id(
"cpp-protected");
4436 member.
id(
"cpp-private");
4443 set_location(member, tk1);
4445 if(lex.get_token(tk2)!=
':')
4458 lex.LookAhead(2)==
'=')
4471 return rAccessDecl(member);
4487 if(lex.get_token(tk)!=
';')
4504 std::cout << std::string(__indent,
' ') <<
"Parser::rCommaExpression 0\n";
4507 if(!rExpression(exp,
false))
4511 std::cout << std::string(__indent,
' ') <<
"Parser::rCommaExpression 1\n";
4514 while(lex.LookAhead(0)==
',')
4521 if(!rExpression(right,
false))
4527 exp=
exprt(ID_comma);
4529 set_location(exp, tk);
4533 std::cout << std::string(__indent,
' ') <<
"Parser::rCommaExpression 2\n";
4549 std::cout << std::string(__indent,
' ') <<
"Parser::rExpression 0\n";
4552 if(!rConditionalExpr(exp, template_args))
4556 std::cout << std::string(__indent,
' ') <<
"Parser::rExpression 1\n";
4559 int t=lex.LookAhead(0);
4570 std::cout << std::string(__indent,
' ') <<
"Parser::rExpression 2\n";
4574 if(!rExpression(right, template_args))
4578 std::cout << std::string(__indent,
' ') <<
"Parser::rExpression 3\n";
4584 exp=
exprt(ID_side_effect);
4587 exp.
set(ID_statement, ID_assign);
4589 exp.
set(ID_statement, ID_assign_plus);
4591 exp.
set(ID_statement, ID_assign_minus);
4593 exp.
set(ID_statement, ID_assign_mult);
4595 exp.
set(ID_statement, ID_assign_div);
4597 exp.
set(ID_statement, ID_assign_mod);
4599 exp.
set(ID_statement, ID_assign_shl);
4601 exp.
set(ID_statement, ID_assign_shr);
4603 exp.
set(ID_statement, ID_assign_bitand);
4605 exp.
set(ID_statement, ID_assign_bitxor);
4607 exp.
set(ID_statement, ID_assign_bitor);
4610 set_location(exp, tk);
4614 std::cout << std::string(__indent,
' ') <<
"Parser::rExpression 4\n";
4628 std::cout << std::string(__indent,
' ') <<
"Parser::rConditionalExpr 0\n";
4631 if(!rLogicalOrExpr(exp, template_args))
4635 std::cout << std::string(__indent,
' ') <<
"Parser::rConditionalExpr 1\n";
4638 if(lex.LookAhead(0)==
'?')
4641 exprt then, otherwise;
4644 if(!rCommaExpression(then))
4648 std::cout << std::string(__indent,
' ') <<
"Parser::rConditionalExpr 2\n";
4651 if(lex.get_token(tk2)!=
':')
4654 if(!rExpression(otherwise, template_args))
4662 set_location(exp, tk1);
4677 std::cout << std::string(__indent,
' ') <<
"Parser::rLogicalOrExpr 0\n";
4680 if(!rLogicalAndExpr(exp, template_args))
4684 std::cout << std::string(__indent,
' ') <<
"Parser::rLogicalOrExpr 1\n";
4693 if(!rLogicalAndExpr(right, template_args))
4701 set_location(exp, tk);
4716 std::cout << std::string(__indent,
' ') <<
"Parser::rLogicalAndExpr 1\n";
4719 if(!rInclusiveOrExpr(exp, template_args))
4723 std::cout << std::string(__indent,
' ') <<
"Parser::rLogicalAndExpr 1\n";
4732 if(!rInclusiveOrExpr(right, template_args))
4740 set_location(exp, tk);
4755 std::cout << std::string(__indent,
' ') <<
"Parser::rInclusiveOrExpr 0\n";
4758 if(!rExclusiveOrExpr(exp, template_args))
4762 std::cout << std::string(__indent,
' ') <<
"Parser::rInclusiveOrExpr 1\n";
4765 while(lex.LookAhead(0)==
'|')
4771 if(!rExclusiveOrExpr(right, template_args))
4777 exp=
exprt(ID_bitor);
4779 set_location(exp, tk);
4794 std::cout << std::string(__indent,
' ') <<
"Parser::rExclusiveOrExpr 0\n";
4797 if(!rAndExpr(exp, template_args))
4801 std::cout << std::string(__indent,
' ') <<
"Parser::rExclusiveOrExpr 1\n";
4804 while(lex.LookAhead(0)==
'^')
4810 if(!rAndExpr(right, template_args))
4816 exp=
exprt(ID_bitxor);
4818 set_location(exp, tk);
4833 std::cout << std::string(__indent,
' ') <<
"Parser::rAndExpr 0\n";
4836 if(!rEqualityExpr(exp, template_args))
4840 std::cout << std::string(__indent,
' ') <<
"Parser::rAndExpr 1\n";
4843 while(lex.LookAhead(0)==
'&')
4849 if(!rEqualityExpr(right, template_args))
4855 exp=
exprt(ID_bitand);
4857 set_location(exp, tk);
4872 std::cout << std::string(__indent,
' ') <<
"Parser::rEqualityExpr 0\n";
4875 if(!rRelationalExpr(exp, template_args))
4879 std::cout << std::string(__indent,
' ') <<
"Parser::rEqualityExpr 1\n";
4882 while(lex.LookAhead(0)==
TOK_EQ ||
4883 lex.LookAhead(0)==
TOK_NE)
4889 if(!rRelationalExpr(right, template_args))
4897 set_location(exp, tk);
4912 std::cout << std::string(__indent,
' ') <<
"Parser::rRelationalExpr 0\n";
4915 if(!rShiftExpr(exp, template_args))
4919 std::cout << std::string(__indent,
' ') <<
"Parser::rRelationalExpr 1\n";
4924 while(t=lex.LookAhead(0),
4925 (t==
TOK_LE || t==
TOK_GE || t==
'<' || (t==
'>' && !template_args)))
4931 if(!rShiftExpr(right, template_args))
4941 case TOK_LE:
id=ID_le;
break;
4942 case TOK_GE:
id=ID_ge;
break;
4943 case '<':
id=ID_lt;
break;
4944 case '>':
id=ID_gt;
break;
4949 set_location(exp, tk);
4964 std::cout << std::string(__indent,
' ') <<
"Parser::rShiftExpr 0\n";
4967 if(!rAdditiveExpr(exp))
4971 std::cout << std::string(__indent,
' ') <<
"Parser::rShiftExpr 1\n";
4981 if(!rAdditiveExpr(right))
4989 set_location(exp, tk);
5004 std::cout << std::string(__indent,
' ') <<
"Parser::rAdditiveExpr 0\n";
5007 if(!rMultiplyExpr(exp))
5011 std::cout << std::string(__indent,
' ') <<
"Parser::rAdditiveExpr 1\n";
5015 while(t=lex.LookAhead(0), (t==
'+' || t==
'-'))
5021 if(!rMultiplyExpr(right))
5030 case '+':
id=ID_plus;
break;
5031 case '-':
id=ID_minus;
break;
5036 set_location(exp, tk);
5051 std::cout << std::string(__indent,
' ') <<
"Parser::rMultiplyExpr 0\n";
5058 std::cout << std::string(__indent,
' ') <<
"Parser::rMultiplyExpr 1\n";
5062 while(t=lex.LookAhead(0), (t==
'*' || t==
'/' || t==
'%'))
5077 case '*':
id=ID_mult;
break;
5078 case '/':
id=ID_div;
break;
5079 case '%':
id=ID_mod;
break;
5084 set_location(exp, tk);
5088 std::cout << std::string(__indent,
' ') <<
"Parser::rMultiplyExpr 2\n";
5104 std::cout << std::string(__indent,
' ') <<
"Parser::rPmExpr 0\n";
5111 std::cout << std::string(__indent,
' ') <<
"Parser::rPmExpr 1\n";
5121 if(!rCastExpr(right))
5127 exp=
exprt(
"pointer-to-member");
5129 set_location(exp, tk);
5133 std::cout << std::string(__indent,
' ') <<
"Parser::rPmExpr 2\n";
5148 std::cout << std::string(__indent,
' ') <<
"Parser::rCastExpr 0\n";
5151 if(lex.LookAhead(0)!=
'(')
5152 return rUnaryExpr(exp);
5164 std::cout << std::string(__indent,
' ') <<
"Parser::rCastExpr 1\n";
5170 if(rTypeName(tname))
5172 if(lex.get_token(tk2)==
')')
5174 if(lex.LookAhead(0)==
'&' &&
5180 else if(rCastExpr(exp))
5185 exp=
exprt(
"explicit-typecast");
5188 set_location(exp, tk1);
5196 return rUnaryExpr(exp);
5208 std::cout << std::string(__indent,
' ') <<
"Parser::rTypeName 0\n";
5213 if(!rTypeSpecifier(type_name,
true))
5217 std::cout << std::string(__indent,
' ') <<
"Parser::rTypeName 1\n";
5222 if(!rDeclarator(declarator, kCastDeclarator,
false,
false))
5228 make_subtype(type_name, tname);
5231 std::cout << std::string(__indent,
' ') <<
"Parser::rTypeName 2\n";
5246 std::cout << std::string(__indent,
' ')
5247 <<
"Parser::rTypeNameOrFunctionType 0\n";
5252 if(rTypeName(tname) && lex.LookAhead(0)!=
'(')
5255 std::cout << std::string(__indent,
' ')
5256 <<
"Parser::rTypeNameOrFunctionType 1\n";
5259 if(!optPtrOperator(tname))
5268 std::cout << std::string(__indent,
' ')
5269 <<
"Parser::rTypeNameOrFunctionType 2\n";
5278 std::cout << std::string(__indent,
' ')
5279 <<
"Parser::rTypeNameOrFunctionType 3\n";
5282 if(lex.LookAhead(0)!=
'(')
5286 if(!optPtrOperator(tname))
5293 std::cout << std::string(__indent,
' ')
5294 <<
"Parser::rTypeNameOrFunctionType 4\n";
5305 lex.LookAhead(2)==
'*' &&
5306 lex.LookAhead(3)==
')' &&
5307 lex.LookAhead(4)==
'(')
5316 lex.LookAhead(1)==
')' &&
5317 lex.LookAhead(2)==
'(')
5320 type.
set(ID_identifier, op.
data.
get(ID_C_base_name));
5324 else if(lex.LookAhead(0)==
'*' &&
5326 lex.LookAhead(2)==
')' &&
5327 lex.LookAhead(3)==
'(')
5331 type.
set(ID_identifier, op.
data.
get(ID_C_base_name));
5341 std::cout << std::string(__indent,
' ')
5342 <<
"Parser::rTypeNameOrFunctionType 5\n";
5345 int t=lex.LookAhead(0);
5357 if(!rArgDeclaration(parameter_declaration))
5361 parameter.
swap(parameter_declaration);
5384 std::cout << std::string(__indent,
' ')
5385 <<
"Parser::rTypeNameOrFunctionType 6\n";
5392 if(!optCvQualify(type))
5396 std::cout << std::string(__indent,
' ')
5397 <<
"Parser::rTypeNameOrFunctionType 7\n";
5401 if(!optPtrOperator(type))
5407 std::cout << std::string(__indent,
' ')
5408 <<
"Parser::rTypeNameOrFunctionType 8\n";
5426 int t=lex.LookAhead(0);
5430 std::cout << std::string(__indent,
' ') <<
"Parser::rUnaryExpr 0\n";
5433 if(t==
'*' || t==
'&' || t==
'+' ||
5434 t==
'-' || t==
'!' || t==
'~' ||
5441 std::cout << std::string(__indent,
' ') <<
"Parser::rUnaryExpr 1\n";
5445 if(!rCastExpr(right))
5449 std::cout << std::string(__indent,
' ') <<
"Parser::rUnaryExpr 2\n";
5455 exp=
exprt(ID_dereference);
5459 exp=
exprt(ID_address_of);
5463 exp=
exprt(ID_unary_plus);
5467 exp=
exprt(ID_unary_minus);
5475 exp=
exprt(ID_bitnot);
5479 exp=
exprt(ID_side_effect);
5480 exp.
set(ID_statement, ID_preincrement);
5484 exp=
exprt(ID_side_effect);
5485 exp.
set(ID_statement, ID_predecrement);
5493 set_location(exp, tk);
5498 return rSizeofExpr(exp);
5500 return rAlignofExpr(exp);
5502 return rThrowExpr(exp);
5504 return rNoexceptExpr(exp);
5513 if(!rUnaryExpr(unary))
5518 set_location(exp, tk);
5521 else if(isAllocateExpr(t))
5522 return rAllocateExpr(exp);
5524 return rPostfixExpr(exp);
5537 std::cout << std::string(__indent,
' ') <<
"Parser::rThrowExpr 0\n";
5543 int t=lex.LookAhead(0);
5546 set_location(exp, tk);
5548 if(t==
':' || t==
';')
5556 if(!rExpression(e,
false))
5576 std::cout << std::string(__indent,
' ') <<
"Parser::rTypeidExpr 0\n";
5582 if(lex.LookAhead(0)==
'(')
5590 if(rTypeName(tname))
5592 if(lex.get_token(cp)==
')')
5598 exp=
exprt(
"typeid");
5599 set_location(exp, tk);
5607 if(rExpression(subexp,
false))
5609 if(lex.get_token(cp)==
')')
5617 exp=
exprt(
"typeid");
5618 set_location(exp, tk);
5642 std::cout << std::string(__indent,
' ') <<
"Parser::rSizeofExpr 0\n";
5648 if(lex.LookAhead(0)==
'(')
5656 if(rTypeName(tname))
5658 if(lex.get_token(cp)==
')')
5660 exp=
exprt(ID_sizeof);
5661 exp.
add(ID_type_arg).
swap(tname);
5662 set_location(exp, tk);
5678 if(rTypeName(tname))
5680 if(lex.get_token(cp)==
')')
5682 exp=
exprt(ID_sizeof);
5683 exp.
add(ID_type_arg).
swap(tname);
5684 set_location(exp, tk);
5694 if(!rUnaryExpr(unary))
5697 exp=
exprt(ID_sizeof);
5699 set_location(exp, tk);
5720 if(!rTypeName(tname))
5723 if(lex.get_token(cp)!=
')')
5726 exp=
exprt(ID_alignof);
5727 exp.
add(ID_type_arg).
swap(tname);
5728 set_location(exp, tk);
5742 std::cout << std::string(__indent,
' ') <<
"Parser::rNoexceptExpr 0\n";
5748 if(lex.LookAhead(0)==
'(')
5755 if(rExpression(subexp,
false))
5757 if(lex.get_token(cp)==
')')
5760 exp=
exprt(ID_noexcept);
5762 set_location(exp, tk);
5793 std::cout << std::string(__indent,
' ') <<
"Parser::rAllocateExpr 0\n";
5796 int t=lex.LookAhead(0);
5804 std::cout << std::string(__indent,
' ') <<
"Parser::rAllocateExpr 1\n";
5807 t=lex.get_token(tk);
5810 std::cout << std::string(__indent,
' ') <<
"Parser::rAllocateExpr 2\n";
5817 if(lex.LookAhead(0)==
'[')
5821 if(lex.get_token(tk)!=
']')
5824 exp=
exprt(ID_side_effect);
5825 exp.
set(ID_statement, ID_cpp_delete_array);
5829 exp=
exprt(ID_side_effect);
5830 exp.
set(ID_statement, ID_cpp_delete);
5833 set_location(exp, tk);
5845 std::cout << std::string(__indent,
' ') <<
"Parser::rAllocateExpr 3\n";
5848 exp=
exprt(ID_side_effect);
5849 exp.
set(ID_statement, ID_cpp_new);
5850 set_location(exp, tk);
5852 exprt arguments, initializer;
5854 if(!rAllocateType(arguments, exp.
type(), initializer))
5858 std::cout << std::string(__indent,
' ') <<
"Parser::rAllocateExpr 4\n";
5861 exp.
add(ID_initializer).
swap(initializer);
5881 if(lex.LookAhead(0)!=
'(')
5893 if(rTypeName(atype))
5895 if(lex.get_token()==
')')
5899 if(lex.LookAhead(0)!=
'(')
5901 if(!isTypeSpecifier())
5904 else if(rAllocateInitializer(initializer))
5907 if(lex.LookAhead(0)!=
'(')
5917 if(!rFunctionArguments(arguments))
5920 if(lex.get_token()!=
')')
5924 if(lex.LookAhead(0)==
'(')
5930 if(!rTypeName(tname))
5933 if(lex.get_token()!=
')')
5942 if(!rTypeSpecifier(tname,
false))
5945 if(!rNewDeclarator(tname))
5951 if(lex.LookAhead(0)==
'(')
5953 if(!rAllocateInitializer(initializer))
5956 else if(lex.LookAhead(0)==
'{')
5959 if(!rInitializeExpr(initializer))
5974 if(lex.LookAhead(0)!=
'[')
5975 if(!optPtrOperator(decl))
5978 while(lex.LookAhead(0)==
'[')
5984 if(!rCommaExpression(expr))
5987 if(lex.get_token(cb)!=
']')
5993 set_location(array_type, ob);
5995 decl.
swap(array_type);
6007 if(lex.get_token()!=
'(')
6012 if(lex.LookAhead(0)==
')')
6021 if(!rInitializeExpr(exp))
6032 if(lex.LookAhead(0)==
',')
6034 else if(lex.LookAhead(0)==
')')
6066 std::cout << std::string(__indent,
' ') <<
"Parser::rPostfixExpr 0\n";
6069 if(!rPrimaryExpr(exp))
6073 std::cout << std::string(__indent,
' ') <<
"Parser::rPostfixExpr 1\n";
6082 switch(lex.LookAhead(0))
6086 if(!rCommaExpression(e))
6090 std::cout << std::string(__indent,
' ') <<
"Parser::rPostfixExpr 2\n";
6093 if(lex.get_token(cp)!=
']')
6100 exp=
exprt(ID_index);
6102 set_location(exp, op);
6108 std::cout << std::string(__indent,
' ') <<
"Parser::rPostfixExpr 3\n";
6112 if(!rFunctionArguments(e))
6115 if(lex.get_token(cp)!=
')')
6119 std::cout << std::string(__indent,
' ') <<
"Parser::rPostfixExpr 4\n";
6126 set_location(fc, op);
6139 exprt tmp(ID_side_effect);
6141 tmp.
set(ID_statement, ID_postincrement);
6142 set_location(tmp, op);
6151 exprt tmp(ID_side_effect);
6153 tmp.
set(ID_statement, ID_postdecrement);
6154 set_location(tmp, op);
6161 t2=lex.get_token(op);
6164 std::cout << std::string(__indent,
' ') <<
"Parser::rPostfixExpr 5\n";
6171 std::cout << std::string(__indent,
' ') <<
"Parser::rPostfixExpr 6\n";
6179 exp=
exprt(ID_member);
6181 exp=
exprt(ID_ptrmember);
6184 set_location(exp, op);
6187 exp.
add(ID_component_cpp_name).
swap(e);
6210 if(lex.get_token(tk)!=
'(')
6219 if(rTypeName(tname))
6221 if(lex.get_token(cp)==
')')
6223 expr=
exprt(ID_msc_uuidof);
6224 expr.
add(ID_type_arg).
swap(tname);
6225 set_location(expr, tk);
6235 if(!rUnaryExpr(unary))
6238 if(lex.get_token(tk)!=
')')
6241 expr=
exprt(ID_msc_uuidof);
6243 set_location(expr, tk);
6264 if(lex.get_token(tk2)!=
'(')
6272 if(lex.get_token(tk2)!=
')')
6275 if(lex.get_token(tk2)!=
'{')
6283 if(lex.get_token(tk2)!=
'}')
6288 ID_msc_if_not_exists);
6292 set_location(expr, tk1);
6309 if(lex.get_token(tk2)!=
'(')
6317 if(lex.get_token(tk2)!=
')')
6320 if(lex.get_token(tk2)!=
'{')
6325 while(lex.LookAhead(0)!=
'}')
6329 if(!rStatement(statement))
6335 if(lex.get_token(tk2)!=
'}')
6340 ID_msc_if_not_exists);
6344 set_location(code, tk1);
6363 set_location(expr, tk);
6365 typet tname1, tname2;
6370 if(lex.get_token(tk)!=
'(')
6372 if(!rTypeName(tname1))
6374 if(lex.get_token(tk)!=
')')
6376 expr.
add(ID_type_arg).
swap(tname1);
6380 if(lex.get_token(tk)!=
'(')
6382 if(!rTypeName(tname1))
6384 if(lex.get_token(tk)!=
',')
6386 if(!rTypeName(tname2))
6388 if(lex.get_token(tk)!=
')')
6390 expr.
add(
"type_arg1").
swap(tname1);
6391 expr.
add(
"type_arg2").
swap(tname2);
6424 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 0 " 6425 << lex.LookAhead(0) <<
' ' << lex.current_token().
text <<
'\n';
6428 switch(lex.LookAhead(0))
6435 set_location(exp, tk);
6437 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 1\n";
6444 set_location(exp, tk);
6446 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 2\n";
6452 exp=
exprt(
"cpp-this");
6453 set_location(exp, tk);
6455 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 3\n";
6462 set_location(exp, tk);
6464 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 4\n";
6471 set_location(exp, tk);
6473 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 5\n";
6480 set_location(exp, tk);
6482 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 6\n";
6488 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 7\n";
6492 if(lex.LookAhead(0)==
'{')
6496 if(!rCompoundStatement(code))
6499 exp=
exprt(ID_side_effect);
6500 exp.
set(ID_statement, ID_statement_expression);
6501 set_location(exp, tk);
6504 if(lex.get_token(tk2)!=
')')
6511 if(!rCommaExpression(exp2))
6515 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 8\n";
6518 if(lex.get_token(tk2)!=
')')
6525 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 9\n";
6531 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 10\n";
6533 return rInitializeExpr(exp);
6536 return rTypeidExpr(exp);
6541 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 11\n";
6543 return rTypePredicate(exp);
6547 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 12\n";
6549 return rMSCuuidof(exp);
6556 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 13\n";
6558 return rMSC_if_existsExpr(exp);
6562 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 14\n";
6567 if(!optIntegralTypeOrClassSpec(type))
6571 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 15\n";
6584 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 16\n";
6586 if(lex.LookAhead(0)==
'{')
6588 lex.LookAhead(0, tk);
6591 if(!rInitializeExpr(exp2))
6594 exp=
exprt(
"explicit-constructor-call");
6597 set_location(exp, tk);
6599 else if(lex.LookAhead(0)==
'(')
6604 if(!rFunctionArguments(exp2))
6607 if(lex.get_token(tk2)!=
')')
6610 exp=
exprt(
"explicit-constructor-call");
6613 set_location(exp, tk);
6634 std::cout << std::string(__indent,
' ') <<
"Parser::rPrimaryExpr 17\n";
6655 std::cout << std::string(__indent,
' ') <<
"Parser::rVarName 0\n";
6658 if(rVarNameCore(name))
6668 std::cout << std::string(__indent,
' ') <<
"Parser::rVarNameCore 0\n";
6671 name=
exprt(ID_cpp_name);
6678 name.
set(ID_typename,
true);
6683 lex.LookAhead(0, tk);
6684 set_location(name, tk);
6688 std::cout << std::string(__indent,
' ') <<
"Parser::rVarNameCore 1\n";
6696 std::cout << std::string(__indent,
' ') <<
"Parser::rVarNameCore 1.1 " 6701 switch(lex.LookAhead(0))
6706 std::cout << std::string(__indent,
' ') <<
"Parser::rVarNameCore 2\n";
6716 std::cout << std::string(__indent,
' ') <<
"Parser::rVarNameCore 3\n";
6720 components.push_back(
irept(ID_name));
6721 components.back().set(ID_identifier, tk.
data.
get(ID_C_base_name));
6722 set_location(components.back(), tk);
6725 if(maybeTemplateArgs())
6730 std::cout << std::string(__indent,
' ') <<
"Parser::rVarNameCore 4\n";
6734 if(!rTemplateArgs(args))
6740 components.push_back(
irept(ID_template_args));
6741 components.back().
add(ID_arguments).
swap(args);
6750 std::cout << std::string(__indent,
' ') <<
"Parser::rVarNameCore 5\n";
6754 components.push_back(
irept(
"::"));
6755 set_location(components.back(), tk);
6760 std::cout << std::string(__indent,
' ') <<
"Parser::rVarNameCore 6\n";
6768 components.push_back(
irept(
"~"));
6769 set_location(components.back(), tk);
6774 std::cout << std::string(__indent,
' ') <<
"Parser::rVarNameCore 7\n";
6779 components.push_back(
irept(ID_operator));
6780 set_location(components.back(), tk);
6784 if(!rOperatorName(op))
6787 components.push_back(op);
6801 int t=lex.LookAhead(1);
6817 int t=lex.LookAhead(i++);
6821 std::cout << std::string(__indent,
' ') <<
"Parser::maybeTemplateArgs 0\n";
6829 int u=lex.LookAhead(i++);
6830 if(u==
'\0' || u==
';' || u==
'}')
6833 (lex.LookAhead(i)==
TOK_SCOPE || lex.LookAhead(i)==
'(' ||
6834 lex.LookAhead(i)==
')'))
6843 std::cout << std::string(__indent,
' ')
6844 <<
"Parser::maybeTemplateArgs 1\n";
6847 int u=lex.LookAhead(i++);
6850 std::cout << std::string(__indent,
' ')
6851 <<
"Parser::maybeTemplateArgs 2\n";
6863 int v=lex.LookAhead(i++);
6866 std::cout << std::string(__indent,
' ')
6867 <<
"Parser::maybeTemplateArgs 3\n";
6874 else if(v==
'\0' || v==
';' || v==
'}')
6878 else if(u==
'\0' || u==
';' || u==
'}')
6884 std::cout << std::string(__indent,
' ')
6885 <<
"Parser::maybeTemplateArgs 4\n";
6890 std::cout << std::string(__indent,
' ') <<
"Parser::maybeTemplateArgs 5\n";
6896 std::cout << std::string(__indent,
' ') <<
"Parser::maybeTemplateArgs 6\n";
6904 std::cout << std::string(__indent,
' ') <<
"Parser::maybeTemplateArgs 7\n";
6920 if(lex.LookAhead(0)==
'{' &&
6927 set_location(body, ob);
6932 if(lex.get_token(cb)!=
'}')
6935 declarator.
value()=body;
6945 if(!rCompoundStatement(body))
6947 current_function.
clear();
6951 declarator.
value()=body;
6953 current_function.
clear();
6969 std::cout << std::string(__indent,
' ') <<
"Parser::rCompoundStatement 1\n";
6972 if(lex.get_token(ob)!=
'{')
6976 std::cout << std::string(__indent,
' ') <<
"Parser::rCompoundStatement 2\n";
6980 set_location(statement, ob);
6982 while(lex.LookAhead(0)!=
'}')
6986 if(!rStatement(statement2))
6999 if(lex.get_token(cb)!=
'}')
7033 std::cout << std::string(__indent,
' ') <<
"Parser::rStatement 0 " 7034 << lex.LookAhead(0) <<
"\n";
7037 switch(k=lex.LookAhead(0))
7040 return rCompoundStatement(statement);
7043 return rTypedefStatement(statement);
7046 return rIfStatement(statement);
7049 return rSwitchStatement(statement);
7052 return rWhileStatement(statement);
7055 return rDoStatement(statement);
7058 return rForStatement(statement);
7061 return rTryStatement(statement);
7064 return rMSC_tryStatement(statement);
7067 return rMSC_leaveStatement(statement);
7074 statement=
codet(ID_break);
7076 statement=
codet(ID_continue);
7078 set_location(statement, tk1);
7080 if(lex.get_token(tk2)!=
';')
7087 std::cout << std::string(__indent,
' ') <<
"Parser::rStatement RETURN 0\n";
7092 statement=
codet(ID_return);
7093 set_location(statement, tk1);
7095 if(lex.LookAhead(0)==
';')
7098 std::cout << std::string(__indent,
' ')
7099 <<
"Parser::rStatement RETURN 1\n";
7106 std::cout << std::string(__indent,
' ')
7107 <<
"Parser::rStatement RETURN 2\n";
7112 if(!rCommaExpression(exp))
7116 std::cout << std::string(__indent,
' ')
7117 <<
"Parser::rStatement RETURN 3\n";
7120 if(lex.get_token(tk2)!=
';')
7131 statement=
codet(ID_goto);
7132 set_location(statement, tk1);
7137 if(lex.get_token(tk3)!=
';')
7140 statement.
set(ID_destination, tk2.
data.
get(ID_C_base_name));
7149 if(!rExpression(case_expr,
false))
7159 if(!rExpression(range_end,
false))
7162 statement=
codet(ID_gcc_switch_case_range);
7164 statement.
op0()=case_expr;
7165 statement.
op1()=range_end;
7166 set_location(statement, tk1);
7168 if(lex.get_token(tk2)!=
':')
7172 if(!rStatement(statement2))
7175 statement.
op2().
swap(statement2);
7180 set_location(statement, tk1);
7181 statement.
op0()=case_expr;
7183 if(lex.get_token(tk2)!=
':')
7187 if(!rStatement(statement2))
7190 statement.
op1().
swap(statement2);
7200 statement.
set(ID_default,
true);
7201 set_location(statement, tk1);
7203 if(lex.get_token(tk2)!=
':')
7207 if(!rStatement(statement2))
7210 statement.
op1().
swap(statement2);
7215 return rGCCAsmStatement(statement);
7218 return rMSCAsmStatement(statement);
7222 return rMSC_if_existsStatement(statement);
7225 if(lex.LookAhead(1)==
':')
7229 statement=
codet(ID_label);
7230 set_location(statement, tk1);
7231 statement.
set(ID_label, tk1.
data.
get(ID_C_base_name));
7236 if(!rStatement(statement2))
7243 return rExprStatement(statement);
7248 lex.LookAhead(2)==
'=')
7250 statement=
codet(ID_decl);
7257 if(!rUsing(cpp_using))
7269 if(!rStaticAssert(cpp_static_assert))
7280 return rExprStatement(statement);
7292 if(lex.get_token(tk1)!=
TOK_IF)
7295 statement=
codet(ID_ifthenelse);
7296 set_location(statement, tk1);
7298 if(lex.get_token(tk2)!=
'(')
7302 if(!rCondition(exp))
7305 if(lex.get_token(tk3)!=
')')
7309 if(!rStatement(then))
7321 if(!rStatement(otherwise))
7324 statement.
op2().
swap(otherwise);
7343 statement=
codet(ID_switch);
7344 set_location(statement, tk1);
7346 if(lex.get_token(tk2)!=
'(')
7350 if(!rCondition(exp))
7353 if(lex.get_token(tk3)!=
')')
7357 if(!rStatement(body))
7376 statement=
codet(ID_while);
7377 set_location(statement, tk1);
7379 if(lex.get_token(tk2)!=
'(')
7383 if(!rCondition(exp))
7386 if(lex.get_token(tk3)!=
')')
7390 if(!rStatement(body))
7406 if(lex.get_token(tk0)!=
TOK_DO)
7409 statement=
codet(ID_dowhile);
7410 set_location(statement, tk0);
7413 if(!rStatement(body))
7419 if(lex.get_token(tk2)!=
'(')
7423 if(!rCommaExpression(exp))
7426 if(lex.get_token(tk3)!=
')')
7429 if(lex.get_token(tk4)!=
';')
7446 if(lex.get_token(tk1)!=
TOK_FOR)
7449 statement=
codet(ID_for);
7450 set_location(statement, tk1);
7452 if(lex.get_token(tk2)!=
'(')
7457 if(!rExprStatement(exp1))
7462 if(lex.LookAhead(0)==
';')
7465 if(!rCommaExpression(exp2))
7468 if(lex.get_token(tk3)!=
';')
7473 if(lex.LookAhead(0)==
')')
7477 if(!rCommaExpression(exp3))
7481 if(lex.get_token(tk4)!=
')')
7486 if(!rStatement(body))
7511 if(lex.get_token(try_token)!=
TOK_TRY)
7514 statement=
codet(ID_try_catch);
7516 set_location(statement, try_token);
7520 if(!rCompoundStatement(body))
7531 if(lex.get_token(catch_token)!=
TOK_CATCH)
7534 if(lex.get_token(op_token)!=
'(')
7542 lex.get_token(ellipsis_token);
7543 codet ellipsis(ID_ellipsis);
7544 set_location(ellipsis, ellipsis_token);
7551 if(!rArgDeclaration(declaration))
7557 if(declaration.
declarators().front().name().is_nil())
7559 irept name(ID_name);
7560 name.
set(ID_identifier,
"#anon");
7562 declaration.
declarators().front().name().get_sub().push_back(name);
7568 set_location(code_decl, catch_token);
7573 if(lex.get_token(cp_token)!=
')')
7578 if(!rCompoundStatement(body))
7602 set_location(statement, tk);
7606 if(!rCompoundStatement(body1))
7616 if(lex.get_token(tk2)!=
'(')
7620 if(!rCommaExpression(exp))
7623 if(lex.get_token(tk3)!=
')')
7626 if(!rCompoundStatement(body2))
7636 if(!rCompoundStatement(body2))
7657 statement=
codet(
"msc_leave");
7658 set_location(statement, tk);
7669 std::cout << std::string(__indent,
' ') <<
"Parser::rGCCAsmStatement 1\n";
7677 statement=
codet(ID_asm);
7678 statement.
set(ID_flavor, ID_gcc);
7680 set_location(statement, tk);
7686 std::cout << std::string(__indent,
' ') <<
"Parser::rGCCAsmStatement 3\n";
7689 if(lex.get_token(tk)!=
'(')
7697 std::cout << std::string(__indent,
' ') <<
"Parser::rGCCAsmStatement 3\n";
7700 while(lex.LookAhead(0)!=
')')
7703 std::cout << std::string(__indent,
' ') <<
"Parser::rGCCAsmStatement 4\n";
7707 if(lex.get_token(tk)!=
':')
7718 if(lex.LookAhead(0)==
'(')
7724 std::cout << std::string(__indent,
' ')
7725 <<
"Parser::rGCCAsmStatement 5\n";
7729 if(!rCommaExpression(expr))
7733 std::cout << std::string(__indent,
' ')
7734 <<
"Parser::rGCCAsmStatement 6\n";
7737 if(lex.get_token(tk)!=
')')
7742 if(lex.LookAhead(0)!=
',')
7749 std::cout << std::string(__indent,
' ') <<
"Parser::rGCCAsmStatement 7\n";
7752 if(lex.get_token(tk)!=
')')
7754 if(lex.get_token(tk)!=
';')
7758 std::cout << std::string(__indent,
' ') <<
"Parser::rGCCAsmStatement 8\n";
7770 std::cout << std::string(__indent,
' ') <<
"Parser::rMSCAsmStatement 1\n";
7779 statement=
codet(ID_asm);
7780 statement.
set(ID_flavor, ID_msc);
7781 set_location(statement, tk);
7784 std::cout << std::string(__indent,
' ') <<
"Parser::rMSCAsmStatement 2\n";
7787 if(lex.LookAhead(0)==
'{')
7792 std::cout << std::string(__indent,
' ') <<
"Parser::rMSCAsmStatement 3\n";
7801 if(lex.get_token(tk)!=
'}')
7805 std::cout << std::string(__indent,
' ') <<
"Parser::rMSCAsmStatement 4\n";
7811 std::cout << std::string(__indent,
' ') <<
"Parser::rMSCAsmStatement 5\n";
7821 std::cout << std::string(__indent,
' ') <<
"Parser::rMSCAsmStatement 6\n";
7826 std::cout << std::string(__indent,
' ') <<
"Parser::rMSCAsmStatement 7\n";
7846 std::cout << std::string(__indent,
' ') <<
"Parser::rExprStatement 0\n";
7849 if(lex.LookAhead(0)==
';')
7852 std::cout << std::string(__indent,
' ') <<
"Parser::rExprStatement 1\n";
7856 statement=
codet(ID_skip);
7857 set_location(statement, tk);
7863 std::cout << std::string(__indent,
' ') <<
"Parser::rExprStatement 2\n";
7868 if(rDeclarationStatement(statement))
7871 std::cout << std::string(__indent,
' ') <<
"rDe " 7872 << statement.
pretty() <<
'\n';
7883 std::cout << std::string(__indent,
' ') <<
"Parser::rExprStatement 3\n";
7886 if(!rCommaExpression(exp))
7890 std::cout << std::string(__indent,
' ') <<
"Parser::rExprStatement 4\n";
7894 std::cout << std::string(__indent,
' ') <<
"Parser::rExprStatement 5 " 7895 << lex.LookAhead(0) <<
"\n";
7898 if(lex.get_token(tk)!=
';')
7902 std::cout << std::string(__indent,
' ') <<
"Parser::rExprStatement 6\n";
7905 statement=
codet(ID_expression);
7921 if(rSimpleDeclaration(declaration))
7923 statement=
codet(ID_decl);
7931 if(!rCommaExpression(statement))
7955 typet cv_q, integral;
7960 std::cout << std::string(__indent,
' ')
7961 <<
"Parser::rDeclarationStatement 1\n";
7964 if(!optStorageSpec(storage_spec))
7969 if(!optCvQualify(cv_q))
7973 if(!optStorageSpec(storage_spec))
7976 if(!optCvQualify(cv_q))
7979 if(!optIntegralTypeOrClassSpec(integral))
7983 std::cout << std::string(__indent,
' ')
7984 <<
"Parser::rDeclarationStatement 2\n";
7988 return rIntegralDeclStatement(statement, storage_spec, integral, cv_q);
7991 int t=lex.LookAhead(0);
7994 std::cout << std::string(__indent,
' ')
7995 <<
"Parser::rDeclarationStatement 3 " << t <<
"\n";
8002 std::cout << std::string(__indent,
' ')
8003 <<
"Parser::rDeclarationStatement 4\n";
8006 statement=
codet(ID_decl);
8009 return rConstDeclaration(declaration, storage_spec, member_spec, cv_q);
8012 return rOtherDeclStatement(statement, storage_spec, cv_q);
8028 if(!optCvQualify(cv_q))
8031 merge_types(cv_q, integral);
8037 if(lex.LookAhead(0)==
';')
8040 statement=
codet(ID_decl);
8041 set_location(statement, tk);
8046 if(!rDeclarators(declaration.
declarators(),
false,
true))
8049 if(lex.get_token(tk)!=
';')
8052 statement=
codet(ID_decl);
8053 set_location(statement, tk);
8075 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclStatement 1\n";
8078 if(!rName(type_name))
8082 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclStatement 2\n";
8085 if(!optCvQualify(cv_q))
8089 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclStatement 3\n";
8092 merge_types(cv_q, type_name);
8095 declaration.
type().
swap(type_name);
8098 if(!rDeclarators(declaration.
declarators(),
false,
true))
8102 std::cout << std::string(__indent,
' ') <<
"Parser::rOtherDeclStatement 4\n";
8105 if(lex.get_token(tk)!=
';')
8108 statement=
codet(ID_decl);
8109 set_location(statement, tk);
8126 int t=lex.LookAhead(0);
8127 if(t==token || t==
'\0')
8141 while(rProgram(item))
8143 parser.parse_tree.items.push_back(item);
8148 root_scope.print(std::cout);
8151 return number_of_errors!=0;
const irept & get_nil_irep()
std::string full_name() const
const irep_idt & get_statement() const
The type of an expression.
bool rTemplateArgs(irept &)
bool rShiftExpr(exprt &, bool)
void set_function(const irep_idt &function)
bool rInclusiveOrExpr(exprt &, bool)
bool rTryStatement(codet &)
bool rIntegralDeclStatement(codet &, cpp_storage_spect &, typet &, typet &)
bool rTypeidExpr(exprt &)
const std::string & id2string(const irep_idt &d)
bool rTypeNameOrFunctionType(typet &)
const cpp_storage_spect & storage_spec() const
bool rTypedefUsing(cpp_declarationt &)
bool rClassMember(cpp_itemt &)
C++ Parser: Token Buffer.
void set_explicit(bool value)
std::string pretty(unsigned indent=0, unsigned max_indent=0) const
bool rMSC_leaveStatement(codet &)
std::vector< irept > subt
bool rAllocateType(exprt &, typet &, exprt &)
bool rNamespaceSpec(cpp_namespace_spect &)
void move_to_sub(irept &irep)
bool rStaticAssert(cpp_static_assertt &)
bool rVarNameCore(exprt &)
bool rDeclarationStatement(codet &)
void move_to_operands(exprt &expr)
bool rDeclaratorQualifier()
void set_namespace(bool value)
bool rTypedefStatement(codet &)
bool rMemberInitializers(irept &)
bool rArgDeclList(irept &)
bool rExprStatement(codet &)
A constant literal expression.
bool rTypePredicate(exprt &)
static mstreamt & eom(mstreamt &m)
bool rString(cpp_tokent &tk)
bool rConditionalExpr(exprt &, bool)
bool rNullDeclaration(cpp_declarationt &)
bool rNewDeclarator(typet &)
bool optMemberSpec(cpp_member_spect &)
bool rMSC_tryStatement(codet &)
A side effect that throws an exception.
void move_to_subtypes(typet &type)
const cpp_member_spect & member_spec() const
void set_inline(bool value)
bool rExpression(exprt &, bool)
bool optThrowDecl(irept &)
bool rProgram(cpp_itemt &item)
Parser(cpp_parsert &_cpp_parser)
bool rMSC_if_existsStatement(codet &)
bool rPrimaryExpr(exprt &)
cpp_usingt & make_using()
bool rConstDeclaration(cpp_declarationt &, cpp_storage_spect &, cpp_member_spect &, typet &)
bool rCommaExpression(exprt &)
bool MaybeTypeNameOrClassTemplate(cpp_tokent &)
bool rSwitchStatement(codet &)
bool rExternTemplateDecl(irept &)
bool rMSCAsmStatement(codet &)
const irep_idt & id() const
bool rNoexceptExpr(exprt &)
bool rBaseSpecifiers(irept &)
const declaratorst & declarators() const
bool rLinkageBody(cpp_linkage_spect::itemst &)
The boolean constant true.
void make_sub_scope(const irept &name, new_scopet::kindt)
cpp_declarationt & make_declaration()
bool rAndExpr(exprt &, bool)
cpp_namespace_spect & make_namespace_spec()
new_scopet * current_scope
irep_idt current_function
unsigned number_of_errors
bool rLogicalAndExpr(exprt &, bool)
bool rAccessDecl(irept &)
bool rDoStatement(codet &)
cpp_linkage_spect & make_linkage_spec()
bool rPostfixExpr(exprt &)
void set_file(const irep_idt &file)
bool rArgDeclaration(cpp_declarationt &)
bool rMultiplyExpr(exprt &)
bool optPtrOperator(typet &)
cpp_static_assertt & make_static_assert()
API to expression classes.
const irep_idt & get(const irep_namet &name) const
void set_line(const irep_idt &line)
bool rWhileStatement(codet &)
void copy_to_subtypes(const typet &type)
save_scopet(new_scopet *&_scope)
bool rOperatorName(irept &)
bool rTypeSpecifier(typet &, bool)
void set_namespace(const irep_idt &_namespace)
bool rDeclaratorWithInit(cpp_declaratort &, bool, bool)
bool rTempArgDeclaration(cpp_declarationt &)
irept & method_qualifier()
const exprt & size() const
bool optIntegralTypeOrClassSpec(typet &)
Base class for tree-like data structures with sharing.
void set_friend(bool value)
bool optAttribute(cpp_declarationt &)
C++ Language Type Checking.
bool rEqualityExpr(exprt &, bool)
bool rIntegralDeclaration(cpp_declarationt &, cpp_storage_spect &, cpp_member_spect &, typet &, typet &)
bool rRelationalExpr(exprt &, bool)
const itemst & items() const
The boolean constant false.
bool rMSC_if_existsExpr(exprt &)
bool rOtherDeclaration(cpp_declarationt &, cpp_storage_spect &, cpp_member_spect &, typet &)
bool rCastOperatorName(irept &)
bool rOtherDeclStatement(codet &, cpp_storage_spect &, typet &)
std::map< irep_idt, new_scopet > id_mapt
bool rConstructorDecl(cpp_declaratort &, typet &, typet &trailing_return_type)
const source_locationt & source_location() const
bool rIfStatement(codet &)
irep_idt get_base_name() const
A function call side effect.
bool rMemberInit(exprt &)
bool optStorageSpec(cpp_storage_spect &)
bool rLogicalOrExpr(exprt &, bool)
bool rTypedef(cpp_declarationt &)
std::vector< class cpp_itemt > itemst
bool rTempArgList(irept &)
bool rLinkageSpec(cpp_linkage_spect &)
void make_subtype(const typet &src, typet &dest)
bool rAllocateExpr(exprt &)
bool is_named_scope() const
bool rTemplateDecl(cpp_declarationt &)
void set_is_inline(bool value)
bool rDeclaration(cpp_declarationt &)
void set_statement(const irep_idt &statement)
Base class for all expressions.
void merge_types(const typet &src, typet &dest)
const parameterst & parameters() const
bool rGCCAsmStatement(codet &)
irept & member_initializers()
bool rAdditiveExpr(exprt &)
const source_locationt & source_location() const
bool rAlignofExpr(exprt &)
bool rArgDeclListOrInit(exprt &, bool &, bool)
irept & add(const irep_namet &name)
bool rInitializeExpr(exprt &)
exprt::operandst & arguments()
bool rPtrToMember(irept &)
#define Forall_operands(it, expr)
bool rTemplateDecl2(typet &, TemplateDeclKind &kind)
void set_location(irept &dest, const cpp_tokent &token)
source_locationt & add_source_location()
bool rCompoundStatement(codet &)
bool rDefinition(cpp_itemt &)
bool rForStatement(codet &)
A statement in a programming language.
new_scopet & add_id(const irept &name, new_scopet::kindt)
void print(std::ostream &out) const
bool rDeclarator(cpp_declaratort &, DeclKind, bool, bool, bool=false)
const typet & subtype() const
bool rUsing(cpp_usingt &)
bool rFunctionArguments(exprt &)
const itemst & items() const
bool optCvQualify(typet &)
bool rSizeofExpr(exprt &)
static const char * kind2string(kindt kind)
bool rAllocateInitializer(exprt &)
std::vector< cpp_declaratort > declaratorst
void print_rec(std::ostream &, unsigned indent) const
const irept & find(const irep_namet &name) const
bool rExclusiveOrExpr(exprt &, bool)
const typet & return_type() const
void set_virtual(bool value)
bool rDeclarators(cpp_declarationt::declaratorst &, bool, bool=false)
void set(const irep_namet &name, const irep_idt &value)
bool rSimpleDeclaration(cpp_declarationt &)
void reserve_operands(operandst::size_type n)
const exprt & description() const
bool rFunctionBody(cpp_declaratort &)
#define forall_irep(it, irep)