Changing domain name
[llvm-complete.git] / utils / Burg / rule.c
blobc80f239a5fc411ca3aa4de874685efce9b0d53d9
1 char rcsid_rule[] = "$Id$";
3 #include "b.h"
4 #include <stdio.h>
6 RuleNum max_rule;
7 int max_erule_num;
9 struct rule stub_rule;
11 List rules;
13 Rule
14 newRule(delta, erulenum, lhs, pat) DeltaPtr delta; ERuleNum erulenum; NonTerminal lhs; Pattern pat;
16 Rule p;
18 p = (Rule) zalloc(sizeof(struct rule));
19 assert(p);
20 ASSIGNCOST(p->delta, delta);
21 p->erulenum = erulenum;
22 if (erulenum > max_erule_num) {
23 max_erule_num = erulenum;
25 p->num = max_rule++;
26 p->lhs = lhs;
27 p->pat = pat;
29 rules = newList(p, rules);
31 return p;
34 void
35 dumpRule(p) Rule p;
37 dumpNonTerminal(p->lhs);
38 printf(" : ");
39 dumpPattern(p->pat);
40 printf(" ");
41 dumpCost(p->delta);
42 printf("\n");
45 void
46 dumpRuleList(l) List l;
48 foreachList((ListFn)dumpRule, l);