@@ -200,33 +200,26 @@ DelimTokenTree::as_string () const
200
200
end_delim = " }" ;
201
201
break ;
202
202
default :
203
- // error
204
- return " " ;
203
+ fprintf (stderr, " Invalid delimiter type, "
204
+ " Should be PARENS, SQUARE, or CURLY." );
205
+ return " Invalid delimiter type" ;
205
206
}
206
207
::std::string str = start_delim;
207
- if (token_trees.empty ())
208
+ if (! token_trees.empty ())
208
209
{
209
- str += " none" ;
210
- }
211
- else
212
- {
213
- auto i = token_trees.begin ();
214
- auto e = token_trees.end ();
215
-
216
- // DEBUG: null pointer check
217
- if (*i == NULL )
210
+ for (const auto &tree : token_trees)
218
211
{
219
- fprintf (stderr,
220
- " something really terrible has gone wrong - null pointer "
221
- " token tree in delim token tree." );
222
- return " NULL_POINTER_MARK" ;
223
- }
212
+ // DEBUG: null pointer check
213
+ if (tree == NULL )
214
+ {
215
+ fprintf (
216
+ stderr,
217
+ " something really terrible has gone wrong - null pointer "
218
+ " token tree in delim token tree." );
219
+ return " NULL_POINTER_MARK" ;
220
+ }
224
221
225
- for (; i != e; i++)
226
- {
227
- str += (*i)->as_string ();
228
- if (e != i + 1 )
229
- str += " , " ;
222
+ str += tree->as_string ();
230
223
}
231
224
}
232
225
str += end_delim;
@@ -242,7 +235,8 @@ Token::as_string () const
242
235
// return get_token_description(token_id);
243
236
244
237
// maybe fixed - stores everything as string though, so storage-inefficient
245
- return str;
238
+ ::std::string quote = is_string_lit () ? " \" " : " " ;
239
+ return quote + str + quote;
246
240
}
247
241
248
242
::std::string
@@ -411,7 +405,7 @@ StaticItem::as_string () const
411
405
{
412
406
::std::string str = VisItem::as_string ();
413
407
414
- str += " static" ;
408
+ str += indent_spaces (stay) + " static" ;
415
409
416
410
if (has_mut)
417
411
{
@@ -427,7 +421,7 @@ StaticItem::as_string () const
427
421
" pointer type in static item." );
428
422
return " NULL_POINTER_MARK" ;
429
423
}
430
- str += " \n Type: " + type->as_string ();
424
+ str += " \n " + indent_spaces (stay) + " Type: " + type->as_string ();
431
425
432
426
// DEBUG: null pointer check
433
427
if (expr == NULL )
@@ -436,7 +430,7 @@ StaticItem::as_string () const
436
430
" pointer expr in static item." );
437
431
return " NULL_POINTER_MARK" ;
438
432
}
439
- str += " \n Expression: " + expr->as_string ();
433
+ str += " \n " + indent_spaces (stay) + " Expression: " + expr->as_string ();
440
434
441
435
return str + " \n " ;
442
436
}
@@ -1528,7 +1522,8 @@ MacroRulesDefinition::as_string () const
1528
1522
::std::string
1529
1523
MacroInvocation::as_string () const
1530
1524
{
1531
- return path.as_string () + " !" + token_tree.as_string ();
1525
+ return " MacroInvocation: " + path.as_string () + " !"
1526
+ + token_tree.as_string ();
1532
1527
}
1533
1528
1534
1529
::std::string
@@ -3326,13 +3321,15 @@ LetStmt::as_string () const
3326
3321
{
3327
3322
// note that this does not print them with "outer attribute" syntax -
3328
3323
// just the body
3324
+ indent_spaces (enter);
3329
3325
for (const auto &attr : outer_attrs)
3330
3326
{
3331
- str += " \n " + attr.as_string ();
3327
+ str += " \n " + indent_spaces (stay) + attr.as_string ();
3332
3328
}
3329
+ indent_spaces (out);
3333
3330
}
3334
3331
3335
- str += " \n let " + variables_pattern->as_string ();
3332
+ str += " \n " + indent_spaces (stay) + " let " + variables_pattern->as_string ();
3336
3333
3337
3334
if (has_type ())
3338
3335
{
0 commit comments