Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

lburg.h

Go to the documentation of this file.
00001 #ifndef BURG_INCLUDED
00002 #define BURG_INCLUDED
00003 
00004 /* iburg.c: */
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 {       /* terminals: */
00011     char *name;     /* terminal name */
00012     Kind kind;      /* TERM */
00013     int esn;        /* external symbol number */
00014     int arity;      /* operator arity */
00015     Term link;      /* next terminal in esn order */
00016     Rule rules;     /* rules whose pattern starts with term */
00017 };
00018 
00019 typedef struct nonterm *Nonterm;
00020 struct nonterm {    /* nonterminals: */
00021     char *name;     /* nonterminal name */
00022     Kind kind;      /* NONTERM */
00023     int number;     /* identifying number */
00024     int lhscount;       /* # times nt appears in a rule lhs */
00025     int reached;        /* 1 iff reached from start nonterminal */
00026     Rule rules;     /* rules w/nonterminal on lhs */
00027     Rule chain;     /* chain rules w/nonterminal on rhs */
00028     Nonterm link;       /* next terminal in number order */
00029 };
00030 extern Nonterm nonterm(char *id);
00031 extern Term term(char *id, int esn);
00032 
00033 typedef struct tree *Tree;
00034 struct tree {       /* tree patterns: */
00035     void *op;       /* a terminal or nonterminal */
00036     Tree left, right;   /* operands */
00037     int nterms;     /* number of terminal nodes in this tree */
00038 };
00039 extern Tree tree(char *op, Tree left, Tree right);
00040 
00041 struct rule {       /* rules: */
00042     Nonterm lhs;        /* lefthand side nonterminal */
00043     Tree pattern;       /* rule pattern */
00044     int ern;        /* external rule number */
00045     int packed;     /* packed external rule number */
00046     int cost;       /* cost, if a constant */
00047     char *code;     /* cost, if an expression */
00048     char *template;     /* assembler template */
00049     Rule link;      /* next rule in ern order */
00050     Rule next;      /* next rule with same pattern root */
00051     Rule chain;     /* next chain rule with same rhs */
00052     Rule decode;        /* next rule with same lhs */
00053     Rule kids;      /* next rule with same _kids pattern */
00054 };
00055 extern Rule rule(char *id, Tree pattern, char *template, char *code);
00056 
00057 /* gram.y: */
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

Generated on Thu Aug 25 12:38:11 2005 for Quake III Arena by  doxygen 1.3.9.1