Skip to content

Commit e509402

Browse files
committed
Reapply "DEBUG"
This reverts commit ce919cf.
1 parent 7278536 commit e509402

File tree

1 file changed

+88
-2
lines changed

1 file changed

+88
-2
lines changed

src/cpp/parse.cpp

Lines changed: 88 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Author: Daniel Kroening, [email protected]
2323
#include "cpp_member_spec.h"
2424
#include "cpp_enum_type.h"
2525

26+
#define DEBUG
2627
#ifdef DEBUG
2728
#include <iostream>
2829

@@ -1031,6 +1032,11 @@ bool Parser::rLinkageBody(cpp_linkage_spect::itemst &items)
10311032
*/
10321033
bool Parser::rTemplateDecl(cpp_declarationt &decl)
10331034
{
1035+
#ifdef DEBUG
1036+
indenter _i;
1037+
std::cout << std::string(__indent, ' ') << "Parser::rTemplateDecl 1\n";
1038+
#endif
1039+
10341040
TemplateDeclKind kind=tdk_unknown;
10351041

10361042
make_sub_scope("#template", new_scopet::kindt::TEMPLATE);
@@ -1040,6 +1046,10 @@ bool Parser::rTemplateDecl(cpp_declarationt &decl)
10401046
if(!rTemplateDecl2(template_type, kind))
10411047
return false;
10421048

1049+
#ifdef DEBUG
1050+
std::cout << std::string(__indent, ' ') << "Parser::rTemplateDecl 2\n";
1051+
#endif
1052+
10431053
cpp_declarationt body;
10441054
if(lex.LookAhead(0)==TOK_USING)
10451055
{
@@ -1087,11 +1097,20 @@ bool Parser::rTemplateDecl(cpp_declarationt &decl)
10871097

10881098
bool Parser::rTemplateDecl2(typet &decl, TemplateDeclKind &kind)
10891099
{
1100+
#ifdef DEBUG
1101+
indenter _i;
1102+
std::cout << std::string(__indent, ' ') << "Parser::rTemplateDecl2 1\n";
1103+
#endif
1104+
10901105
cpp_tokent tk;
10911106

10921107
if(lex.get_token(tk)!=TOK_TEMPLATE)
10931108
return false;
10941109

1110+
#ifdef DEBUG
1111+
std::cout << std::string(__indent, ' ') << "Parser::rTemplateDecl2 2\n";
1112+
#endif
1113+
10951114
decl=typet(ID_template);
10961115
set_location(decl, tk);
10971116

@@ -1102,17 +1121,33 @@ bool Parser::rTemplateDecl2(typet &decl, TemplateDeclKind &kind)
11021121
return true; // ignore TEMPLATE
11031122
}
11041123

1124+
#ifdef DEBUG
1125+
std::cout << std::string(__indent, ' ') << "Parser::rTemplateDecl2 3\n";
1126+
#endif
1127+
11051128
if(lex.get_token(tk)!='<')
11061129
return false;
11071130

11081131
irept &template_parameters=decl.add(ID_template_parameters);
11091132

1133+
#ifdef DEBUG
1134+
std::cout << std::string(__indent, ' ') << "Parser::rTemplateDecl2 4\n";
1135+
#endif
1136+
11101137
if(!rTempArgList(template_parameters))
11111138
return false;
11121139

1140+
#ifdef DEBUG
1141+
std::cout << std::string(__indent, ' ') << "Parser::rTemplateDecl2 5\n";
1142+
#endif
1143+
11131144
if(lex.get_token(tk)!='>')
11141145
return false;
11151146

1147+
#ifdef DEBUG
1148+
std::cout << std::string(__indent, ' ') << "Parser::rTemplateDecl2 6\n";
1149+
#endif
1150+
11161151
// ignore nested TEMPLATE
11171152
while(lex.LookAhead(0)==TOK_TEMPLATE)
11181153
{
@@ -1129,6 +1164,10 @@ bool Parser::rTemplateDecl2(typet &decl, TemplateDeclKind &kind)
11291164
return false;
11301165
}
11311166

1167+
#ifdef DEBUG
1168+
std::cout << std::string(__indent, ' ') << "Parser::rTemplateDecl2 7\n";
1169+
#endif
1170+
11321171
if(template_parameters.get_sub().empty())
11331172
// template < > declaration
11341173
kind=tdk_specialization;
@@ -1189,6 +1228,10 @@ bool Parser::rTempArgDeclaration(cpp_declarationt &declaration)
11891228

11901229
if((t0==TOK_CLASS || t0==TOK_TYPENAME))
11911230
{
1231+
#ifdef DEBUG
1232+
std::cout << std::string(__indent, ' ') << "Parser::rTempArgDeclaration 0.1\n";
1233+
#endif
1234+
11921235
cpp_token_buffert::post pos=lex.Save();
11931236

11941237
cpp_tokent tk1;
@@ -1228,6 +1271,10 @@ bool Parser::rTempArgDeclaration(cpp_declarationt &declaration)
12281271

12291272
if(lex.LookAhead(0)=='=')
12301273
{
1274+
#ifdef DEBUG
1275+
std::cout << std::string(__indent, ' ') << "Parser::rTempArgDeclaration 0.2\n";
1276+
#endif
1277+
12311278
if(declarator.get_has_ellipsis())
12321279
return false;
12331280

@@ -1240,10 +1287,38 @@ bool Parser::rTempArgDeclaration(cpp_declarationt &declaration)
12401287
declarator.value()=exprt(ID_type);
12411288
declarator.value().type().swap(default_type);
12421289
}
1290+
#ifdef DEBUG
1291+
std::cout << std::string(__indent, ' ') << "Parser::rTempArgDeclaration 0.3\n";
1292+
#endif
12431293

12441294
if(lex.LookAhead(0)==',' ||
12451295
lex.LookAhead(0)=='>')
12461296
return true;
1297+
#if 0
1298+
else if(lex.LookAhead(0) == TOK_SHIFTRIGHT)
1299+
{
1300+
#ifdef DEBUG
1301+
std::cout << std::string(__indent, ' ') << "Parser::rTempArgDeclaration 0.4\n";
1302+
#endif
1303+
1304+
// turn >> into > >
1305+
cpp_token_buffert::post pos=lex.Save();
1306+
cpp_tokent tk;
1307+
lex.get_token(tk);
1308+
lex.Restore(pos);
1309+
tk.kind='>';
1310+
tk.text='>';
1311+
lex.Replace(tk);
1312+
lex.Insert(tk);
1313+
DATA_INVARIANT(lex.LookAhead(0) == '>', "should be >");
1314+
DATA_INVARIANT(lex.LookAhead(1) == '>', "should be >");
1315+
return true;
1316+
}
1317+
#endif
1318+
#ifdef DEBUG
1319+
std::cout << std::string(__indent, ' ') << "Parser::rTempArgDeclaration 0.5\n";
1320+
#endif
1321+
12471322

12481323
lex.Restore(pos);
12491324
}
@@ -3969,7 +4044,8 @@ bool Parser::rTemplateArgs(irept &template_args)
39694044
)
39704045
{
39714046
#ifdef DEBUG
3972-
std::cout << std::string(__indent, ' ') << "Parser::rTemplateArgs 4\n";
4047+
std::cout << std::string(__indent, ' ') << "Parser::rTemplateArgs 4 " <<
4048+
lex.LookAhead(0) << "\n";
39734049
#endif
39744050

39754051
// ok
@@ -3981,20 +4057,30 @@ bool Parser::rTemplateArgs(irept &template_args)
39814057
lex.Restore(pos);
39824058
exprt tmp;
39834059
if(rConditionalExpr(tmp, true))
4060+
{
4061+
#ifdef DEBUG
4062+
std::cout << std::string(__indent, ' ') << "Parser::rTemplateArgs 4.0\n";
4063+
#endif
39844064
exp.id(ID_ambiguous);
4065+
}
39854066
#ifdef DEBUG
39864067
std::cout << std::string(__indent, ' ') << "Parser::rTemplateArgs 4.1\n";
39874068
#endif
39884069
lex.Restore(pos);
39894070
rTypeNameOrFunctionType(a);
39904071

4072+
#ifdef DEBUG
4073+
std::cout << std::string(__indent, ' ') << "Parser::rTemplateArgs 4.1a " <<
4074+
lex.LookAhead(0) << "\n";
4075+
#endif
39914076
if(lex.LookAhead(0)==TOK_ELLIPSIS)
39924077
{
39934078
lex.get_token(tk1);
39944079
exp.set(ID_ellipsis, true);
39954080
}
39964081
#ifdef DEBUG
3997-
std::cout << std::string(__indent, ' ') << "Parser::rTemplateArgs 4.2\n";
4082+
std::cout << std::string(__indent, ' ') << "Parser::rTemplateArgs 4.2 " <<
4083+
lex.LookAhead(0) << "\n";
39984084
#endif
39994085
}
40004086
else

0 commit comments

Comments
 (0)