23
23
#include " cpp_member_spec.h"
24
24
#include " cpp_enum_type.h"
25
25
26
- #define DEBUG
26
+ // #define DEBUG
27
27
#ifdef DEBUG
28
28
#include < iostream>
29
29
@@ -3157,7 +3157,10 @@ bool Parser::rDeclarator(
3157
3157
}
3158
3158
3159
3159
#ifdef DEBUG
3160
- std::cout << std::string (__indent, ' ' ) << " Parser::rDeclarator2 2\n " ;
3160
+ std::cout << std::string (__indent, ' ' ) << " Parser::rDeclarator2 2 "
3161
+ << lex.LookAhead (0 )
3162
+ << ' ' << lex.peek ().text
3163
+ << ' \n ' ;
3161
3164
#endif
3162
3165
3163
3166
t=lex.LookAhead (0 );
@@ -3621,7 +3624,11 @@ bool Parser::rName(irept &name)
3621
3624
{
3622
3625
#ifdef DEBUG
3623
3626
indenter _i;
3624
- std::cout << std::string (__indent, ' ' ) << " Parser::rName 0\n " ;
3627
+ std::cout << std::string (__indent, ' ' ) << " Parser::rName 0 "
3628
+ << lex.LookAhead (0 )
3629
+ << ' ' << lex.peek ().text
3630
+ << ' ' << lex.Save ()
3631
+ << ' \n ' ;
3625
3632
#endif
3626
3633
3627
3634
name=cpp_namet ();
@@ -4167,9 +4174,20 @@ bool Parser::rArgDeclListOrInit(
4167
4174
bool &is_args,
4168
4175
bool maybe_init)
4169
4176
{
4177
+ #ifdef DEBUG
4178
+ indenter _i;
4179
+ std::cout << std::string (__indent, ' ' ) << " Parser::rArgDeclListOrInit 0 "
4180
+ << lex.LookAhead (0 )
4181
+ << ' ' << lex.peek ().text
4182
+ << ' \n ' ;
4183
+ #endif
4184
+
4170
4185
cpp_token_buffert::post pos=lex.Save ();
4171
4186
if (maybe_init)
4172
4187
{
4188
+ #ifdef DEBUG
4189
+ std::cout << std::string (__indent, ' ' ) << " Parser::rArgDeclListOrInit 1" << std::endl;
4190
+ #endif
4173
4191
if (rFunctionArguments (arglist))
4174
4192
if (lex.LookAhead (0 )==' )' )
4175
4193
{
@@ -4183,12 +4201,18 @@ bool Parser::rArgDeclListOrInit(
4183
4201
}
4184
4202
else
4185
4203
{
4204
+ #ifdef DEBUG
4205
+ std::cout << std::string (__indent, ' ' ) << " Parser::rArgDeclListOrInit 2" << std::endl;
4206
+ #endif
4186
4207
is_args = rArgDeclList (arglist);
4187
4208
4188
4209
if (is_args)
4189
4210
return true ;
4190
4211
else
4191
4212
{
4213
+ #ifdef DEBUG
4214
+ std::cout << std::string (__indent, ' ' ) << " Parser::rArgDeclListOrInit 3" << std::endl;
4215
+ #endif
4192
4216
lex.Restore (pos);
4193
4217
// encode.Clear();
4194
4218
return rFunctionArguments (arglist);
@@ -4203,25 +4227,45 @@ bool Parser::rArgDeclListOrInit(
4203
4227
*/
4204
4228
bool Parser::rArgDeclList (irept &arglist)
4205
4229
{
4230
+ #ifdef DEBUG
4231
+ indenter _i;
4232
+ std::cout << std::string (__indent, ' ' ) << " Parser::rArgDeclList 0 "
4233
+ << lex.LookAhead (0 )
4234
+ << ' ' << lex.peek ().text
4235
+ << ' \n ' ;
4236
+ #endif
4237
+
4206
4238
irept list;
4207
4239
4208
4240
list.clear ();
4209
4241
for (;;)
4210
4242
{
4243
+ #ifdef DEBUG
4244
+ std::cout << std::string (__indent, ' ' ) << " Parser::rArgDeclList 1" << std::endl;
4245
+ #endif
4211
4246
cpp_declarationt declaration;
4212
4247
4213
4248
int t=lex.LookAhead (0 );
4214
4249
if (t==' )' )
4215
4250
break ;
4216
4251
else if (t==TOK_ELLIPSIS)
4217
4252
{
4253
+ #ifdef DEBUG
4254
+ std::cout << std::string (__indent, ' ' ) << " Parser::rArgDeclList 2" << std::endl;
4255
+ #endif
4218
4256
cpp_tokent tk;
4219
4257
lex.get_token (tk);
4220
4258
list.get_sub ().push_back (irept (ID_ellipsis));
4221
4259
break ;
4222
4260
}
4223
4261
else if (rArgDeclaration (declaration))
4224
4262
{
4263
+ #ifdef DEBUG
4264
+ std::cout << std::string (__indent, ' ' ) << " Parser::rArgDeclList 3 "
4265
+ << lex.LookAhead (0 )
4266
+ << ' ' << lex.peek ().text
4267
+ << ' \n ' ;
4268
+ #endif
4225
4269
cpp_tokent tk;
4226
4270
4227
4271
list.get_sub ().push_back (irept (irep_idt ()));
@@ -4306,7 +4350,7 @@ bool Parser::rInitializeExpr(exprt &expr)
4306
4350
indenter _i;
4307
4351
std::cout << std::string (__indent, ' ' ) << " Parser::rInitializeExpr 0 "
4308
4352
<< lex.LookAhead (0 )
4309
- << ' ' << lex.current_token ().text
4353
+ << ' ' << lex.peek ().text
4310
4354
<< ' \n ' ;
4311
4355
#endif
4312
4356
@@ -4402,6 +4446,11 @@ bool Parser::rInitializeExpr(exprt &expr)
4402
4446
*/
4403
4447
bool Parser::rFunctionArguments (exprt &args)
4404
4448
{
4449
+ #ifdef DEBUG
4450
+ indenter _i;
4451
+ std::cout << std::string (__indent, ' ' ) << " Parser::rFunctionArguments 1\n " ;
4452
+ #endif
4453
+
4405
4454
exprt exp ;
4406
4455
cpp_tokent tk;
4407
4456
@@ -4411,11 +4460,19 @@ bool Parser::rFunctionArguments(exprt &args)
4411
4460
4412
4461
for (;;)
4413
4462
{
4463
+ #ifdef DEBUG
4464
+ std::cout << std::string (__indent, ' ' ) << " Parser::rFunctionArguments 2\n " ;
4465
+ #endif
4466
+
4414
4467
if (!rInitializeExpr (exp ))
4415
4468
return false ;
4416
4469
4417
4470
args.add_to_operands (std::move (exp ));
4418
4471
4472
+ #ifdef DEBUG
4473
+ std::cout << std::string (__indent, ' ' ) << " Parser::rFunctionArguments 3\n " ;
4474
+ #endif
4475
+
4419
4476
if (lex.LookAhead (0 )==TOK_ELLIPSIS &&
4420
4477
(lex.LookAhead (1 )==' )' || lex.LookAhead (1 )==' ,' ))
4421
4478
{
@@ -5111,7 +5168,10 @@ bool Parser::rLogicalOrExpr(exprt &exp, bool template_args)
5111
5168
{
5112
5169
#ifdef DEBUG
5113
5170
indenter _i;
5114
- std::cout << std::string (__indent, ' ' ) << " Parser::rLogicalOrExpr 0\n " ;
5171
+ std::cout << std::string (__indent, ' ' ) << " Parser::rLogicalOrExpr 0 "
5172
+ << lex.LookAhead (0 )
5173
+ << ' ' << lex.peek ().text
5174
+ << ' \n ' ;
5115
5175
#endif
5116
5176
5117
5177
if (!rLogicalAndExpr (exp , template_args))
@@ -6518,7 +6578,11 @@ bool Parser::rPostfixExpr(exprt &exp)
6518
6578
{
6519
6579
#ifdef DEBUG
6520
6580
indenter _i;
6521
- std::cout << std::string (__indent, ' ' ) << " Parser::rPostfixExpr 0\n " ;
6581
+ std::cout << std::string (__indent, ' ' ) << " Parser::rPostfixExpr 0 "
6582
+ << lex.LookAhead (0 )
6583
+ << ' ' << lex.peek ().text
6584
+ << ' ' << lex.Save ()
6585
+ << ' \n ' ;
6522
6586
#endif
6523
6587
6524
6588
typet type;
@@ -6574,13 +6638,16 @@ bool Parser::rPostfixExpr(exprt &exp)
6574
6638
else
6575
6639
{
6576
6640
lex.Restore (pos);
6641
+ #ifdef DEBUG
6642
+ std::cout << std::string (__indent, ' ' ) << " Parser::rPostfixExpr 0.2\n " ;
6643
+ #endif
6577
6644
6578
6645
exprt type_or_function_name;
6579
6646
if (rName (type_or_function_name) &&
6580
6647
(lex.LookAhead (0 ) == ' (' || lex.LookAhead (0 ) == ' {' ))
6581
6648
{
6582
6649
#ifdef DEBUG
6583
- std::cout << std::string (__indent, ' ' ) << " Parser::rPostfixExpr 0.2 \n " ;
6650
+ std::cout << std::string (__indent, ' ' ) << " Parser::rPostfixExpr 0.3 \n " ;
6584
6651
#endif
6585
6652
6586
6653
cpp_tokent tk;
@@ -6612,6 +6679,9 @@ bool Parser::rPostfixExpr(exprt &exp)
6612
6679
}
6613
6680
else
6614
6681
{
6682
+ #ifdef DEBUG
6683
+ std::cout << std::string (__indent, ' ' ) << " Parser::rPostfixExpr 0.4\n " ;
6684
+ #endif
6615
6685
lex.Restore (pos);
6616
6686
if (!rPrimaryExpr (exp ))
6617
6687
return false ;
@@ -7011,7 +7081,7 @@ bool Parser::rPrimaryExpr(exprt &exp)
7011
7081
#ifdef DEBUG
7012
7082
indenter _i;
7013
7083
std::cout << std::string (__indent, ' ' ) << " Parser::rPrimaryExpr 0 "
7014
- << lex.LookAhead (0 ) << ' ' << lex.current_token ().text << ' \n ' ;
7084
+ << lex.LookAhead (0 ) << ' ' << lex.peek ().text << ' \n ' ;
7015
7085
#endif
7016
7086
7017
7087
switch (lex.LookAhead (0 ))
@@ -7175,7 +7245,11 @@ bool Parser::rVarName(exprt &name)
7175
7245
{
7176
7246
#ifdef DEBUG
7177
7247
indenter _i;
7178
- std::cout << std::string (__indent, ' ' ) << " Parser::rVarName 0\n " ;
7248
+ std::cout << std::string (__indent, ' ' ) << " Parser::rVarName 0 "
7249
+ << lex.LookAhead (0 )
7250
+ << ' ' << lex.peek ().text
7251
+ << ' ' << lex.Save ()
7252
+ << ' \n ' ;
7179
7253
#endif
7180
7254
7181
7255
if (rVarNameCore (name))
0 commit comments