Revert back to keeping Burg and TableGen in the utils directory
[oota-llvm.git] / support / tools / Burg / pattern.c
1 char rcsid_pattern[] = "$Id$";
2
3 #include <stdio.h>
4 #include "b.h"
5
6 Pattern
7 newPattern(op) Operator op;
8 {
9         Pattern p;
10
11         p = (Pattern) zalloc(sizeof(struct pattern));
12         p->op = op;
13         return p;
14 }
15
16 void
17 dumpPattern(p) Pattern p;
18 {
19         int i;
20
21         if (!p) {
22                 printf("[no-pattern]");
23                 return;
24         }
25
26         if (p->op) {
27                 printf("%s", p->op->name);
28                 if (p->op->arity > 0) {
29                         printf("(");
30                         for (i = 0; i < p->op->arity; i++) {
31                                 printf("%s ", p->children[i]->name);
32                         }
33                         printf(")");
34                 }
35         } else {
36                 printf("%s", p->children[0]->name);
37         }
38 }