Mercurial > hg > Members > masakoha > testcode
view c/regexParser/node.cc @ 144:d8a4922eceae pairPro
remove some errors (not working)
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 14 Dec 2015 17:14:33 +0900 |
parents | 6c258910cacb |
children | 50217a0545e8 |
line wrap: on
line source
#include <stdio.h> #include "node.h" static void printCharacterClass(CharClassPtr cc, long nodeNumber,int d) { if (cc->type == 'r') { printf("%*c",d*4, ' '); for (RangeList range = cc->cond.range; range.begin != 0; range = *range.next) { printf("[%c-%c] ",(unsigned char)range.begin,(unsigned char)range.end); } printf("(%lu)\n",nodeNumber); } } static void descendTree(NodePtr n, int d) { if (n->left != NULL) { d++; descendTree(n->left, d); d--; } if (n->tokenType == 'a') { printf("%*c",d*4, ' '); for (int i = 0; i < n->cc->cond.w.length; i++) { putchar(n->cc->cond.w.word[i]); } printf("(%lu)\n",n->nodeNumber); } else if (n->tokenType == 'c') { printCharacterClass(n->cc,n->nodeNumber,d); } else { printf("%*c%c(%lu)\n",d*4, ' ',n->tokenType,n->nodeNumber); } if (n->right != NULL) { d++; descendTree(n->right, d); d--; } } void printTree(NodePtr n) { puts("---Print Node----"); int d = 0; descendTree(n,d); puts("-----------------"); }