00001 #ifndef BURG_INCLUDED
00002 #define BURG_INCLUDED
00003
00004
00005 extern void *alloc(int nbytes);
00006
00007 typedef enum { TERM=1, NONTERM } Kind;
00008 typedef struct rule *Rule;
00009 typedef struct term *Term;
00010 struct term {
00011 char *name;
00012 Kind kind;
00013 int esn;
00014 int arity;
00015 Term link;
00016 Rule rules;
00017 };
00018
00019 typedef struct nonterm *Nonterm;
00020 struct nonterm {
00021 char *name;
00022 Kind kind;
00023 int number;
00024 int lhscount;
00025 int reached;
00026 Rule rules;
00027 Rule chain;
00028 Nonterm link;
00029 };
00030 extern Nonterm nonterm(char *id);
00031 extern Term term(char *id, int esn);
00032
00033 typedef struct tree *Tree;
00034 struct tree {
00035 void *op;
00036 Tree left, right;
00037 int nterms;
00038 };
00039 extern Tree tree(char *op, Tree left, Tree right);
00040
00041 struct rule {
00042 Nonterm lhs;
00043 Tree pattern;
00044 int ern;
00045 int packed;
00046 int cost;
00047 char *code;
00048 char *template;
00049 Rule link;
00050 Rule next;
00051 Rule chain;
00052 Rule decode;
00053 Rule kids;
00054 };
00055 extern Rule rule(char *id, Tree pattern, char *template, char *code);
00056
00057
00058 void yyerror(char *fmt, ...);
00059 int yyparse(void);
00060 void yywarn(char *fmt, ...);
00061 extern int errcnt;
00062 extern FILE *infp;
00063 extern FILE *outfp;
00064
00065 #endif