compile-pp.c 971 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * This program is free software; you can redistribute it and/or
  3. * modify it under the terms of the GNU General Public License
  4. * as published by the Free Software Foundation; either version 2
  5. * of the License, or (at your option) any later version.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. * Author: g0tsu
  12. * Email: g0tsu at dnmx.0rg
  13. */
  14. #include <libhighlight.h>
  15. #include <stdio.h>
  16. static void hl_print_node(hl_node *node) {
  17. switch (node->type) {
  18. default:
  19. printf(" %d<%s>", node->type, node->text);
  20. break;
  21. }
  22. }
  23. /*
  24. * A simple pretty print compiler
  25. */
  26. void hl_compile_pp(hl_node *node) {
  27. hl_node *iter = node->root;
  28. while (1) {
  29. iter = iter->children;
  30. if (!iter)
  31. break;
  32. hl_print_node(iter);
  33. }
  34. }