school

thing1's amazing school repo
Log | Files | Refs | Submodules | README

debug.c (523B)


      1 #include <stdio.h>
      2 #include "tokenizer.h"
      3 
      4 #include "util.h"
      5 
      6 //# a simple util function to visulize an astNode, never used but nice for debugging
      7 void printAST(astNode *head){
      8 	printf("\n>>>\nfunc: %s\n", head->func);
      9 	printf("args: ");
     10 	for (int i = 0; i < 8; i++){
     11 		if (head->children[i] == NULL && head->args[i] == NULL){
     12 			printf("<<<");
     13 			return;
     14 		}
     15 				
     16 		if (head->args[i] != NULL){
     17 			printf("%s ", head->args[i]);
     18 		}
     19 		if (head->children[i] != NULL){
     20 			printAST(head->children[i]);
     21 		}
     22 
     23 	}
     24 	printf("\n");
     25 }