2003-10-06 03:27:59 +08:00
|
|
|
char rcsid_pattern[] = "$Id$";
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "b.h"
|
|
|
|
|
|
|
|
Pattern
|
|
|
|
newPattern(op) Operator op;
|
|
|
|
{
|
2005-04-22 12:13:13 +08:00
|
|
|
Pattern p;
|
2003-10-06 03:27:59 +08:00
|
|
|
|
2005-04-22 12:13:13 +08:00
|
|
|
p = (Pattern) zalloc(sizeof(struct pattern));
|
|
|
|
p->op = op;
|
|
|
|
return p;
|
2003-10-06 03:27:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dumpPattern(p) Pattern p;
|
|
|
|
{
|
2005-04-22 12:13:13 +08:00
|
|
|
int i;
|
2003-10-06 03:27:59 +08:00
|
|
|
|
2005-04-22 12:13:13 +08:00
|
|
|
if (!p) {
|
|
|
|
printf("[no-pattern]");
|
|
|
|
return;
|
|
|
|
}
|
2003-10-06 03:27:59 +08:00
|
|
|
|
2005-04-22 12:13:13 +08:00
|
|
|
if (p->op) {
|
|
|
|
printf("%s", p->op->name);
|
|
|
|
if (p->op->arity > 0) {
|
|
|
|
printf("(");
|
|
|
|
for (i = 0; i < p->op->arity; i++) {
|
|
|
|
printf("%s ", p->children[i]->name);
|
|
|
|
}
|
|
|
|
printf(")");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
printf("%s", p->children[0]->name);
|
|
|
|
}
|
2003-10-06 03:27:59 +08:00
|
|
|
}
|