Added llvmgcc version to allow tests to be xfailed by frontend version.
[llvm-complete.git] / utils / Burg / nonterminal.c
blobf8d3d783edb7231e5165a4260652924f419e9284
1 char rcsid_nonterminal[] = "$Id$";
3 #include "b.h"
4 #include <stdio.h>
5 #include <string.h>
7 NonTerminal start;
8 NonTerminalNum max_nonterminal = 1;
9 NonTerminalNum last_user_nonterminal;
10 List nonterminals;
12 NonTerminal
13 newNonTerminal(name) char *name;
15 NonTerminal nt;
17 nt = (NonTerminal) zalloc(sizeof(struct nonterminal));
18 assert(nt);
19 if (max_nonterminal == 1) {
20 start = nt;
22 nt->name = name;
23 nt->num = max_nonterminal++;
24 nonterminals = newList(nt, nonterminals);
26 return nt;
29 int
30 nonTerminalName(buf, i) char *buf; int i;
32 List l;
34 for (l = nonterminals; l; l = l->next) {
35 NonTerminal nt = (NonTerminal) l->x;
36 if (nt->num == i) {
37 strcpy(buf, nt->name);
38 return 1;
41 strcpy(buf, "(Unknown NonTerminal)");
42 return 0;
45 void
46 dumpNonTerminal(n) NonTerminal n;
48 printf("%s(%d)", n->name, n->num);