indent 378 B

123456789101112131415161718192021222324
  1. /* Print the depth-first traversal of nodes
  2. * as an indented list
  3. */
  4. BEGIN {
  5. int i, indent;
  6. int seen[string];
  7. void prInd () {
  8. for (i = 0; i < indent; i++) printf (" ");
  9. }
  10. }
  11. BEG_G {
  12. $tvtype = TV_prepostfwd;
  13. $tvroot = node($,ARGV[0]);
  14. }
  15. N {
  16. if (seen[$.name]) indent--;
  17. else {
  18. prInd();
  19. print ($.name);
  20. seen[$.name] = 1;
  21. indent++;
  22. }
  23. }