2003-10-05 21:27:59 +02:00
|
|
|
char rcsid_rule[] = "$Id$";
|
|
|
|
|
|
|
|
#include "b.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
RuleNum max_rule;
|
|
|
|
int max_erule_num;
|
|
|
|
|
|
|
|
struct rule stub_rule;
|
|
|
|
|
|
|
|
List rules;
|
|
|
|
|
|
|
|
Rule
|
|
|
|
newRule(delta, erulenum, lhs, pat) DeltaPtr delta; ERuleNum erulenum; NonTerminal lhs; Pattern pat;
|
|
|
|
{
|
2005-04-22 06:13:13 +02:00
|
|
|
Rule p;
|
|
|
|
|
|
|
|
p = (Rule) zalloc(sizeof(struct rule));
|
|
|
|
assert(p);
|
|
|
|
ASSIGNCOST(p->delta, delta);
|
|
|
|
p->erulenum = erulenum;
|
|
|
|
if (erulenum > max_erule_num) {
|
|
|
|
max_erule_num = erulenum;
|
|
|
|
}
|
|
|
|
p->num = max_rule++;
|
|
|
|
p->lhs = lhs;
|
|
|
|
p->pat = pat;
|
|
|
|
|
|
|
|
rules = newList(p, rules);
|
|
|
|
|
|
|
|
return p;
|
2003-10-05 21:27:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dumpRule(p) Rule p;
|
|
|
|
{
|
2005-04-22 06:13:13 +02:00
|
|
|
dumpNonTerminal(p->lhs);
|
|
|
|
printf(" : ");
|
|
|
|
dumpPattern(p->pat);
|
|
|
|
printf(" ");
|
|
|
|
dumpCost(p->delta);
|
|
|
|
printf("\n");
|
2003-10-05 21:27:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dumpRuleList(l) List l;
|
|
|
|
{
|
2005-04-22 06:13:13 +02:00
|
|
|
foreachList((ListFn)dumpRule, l);
|
2003-10-05 21:27:59 +02:00
|
|
|
}
|