5 /* machine dependent definitions */
6 /* the following definitions are for the VAX */
7 /* they might have to be changed for other machines */
9 /* MAXCHAR is the largest unsigned character value */
10 /* MAXSHORT is the largest value of a C short */
11 /* MAXTABLE is the maximum table size */
12 /* BITS_PER_WORD is the number of bits in a C unsigned */
13 /* WORDSIZE computes the number of words needed to */
15 /* BIT returns the value of the n-th bit starting */
16 /* from r (0-indexed) */
17 /* SETBIT sets the n-th bit starting from r */
20 #define MAXSHORT 32767
21 #define MAXTABLE 32500
22 #define BITS_PER_WORD ((int)sizeof(int)<<3)
23 #define WORDSIZE(n) (((n)+(BITS_PER_WORD-1))/BITS_PER_WORD)
24 #define BIT(r, n) ((((r)[(n)/BITS_PER_WORD]) >> ((n) & (BITS_PER_WORD-1))) & 1)
25 #define SETBIT(r, n) ((r)[(n)/BITS_PER_WORD] |= (1 << ((n) & (BITS_PER_WORD-1))))
30 #define NUL '\0' /* the null character */
31 #define NEWLINE '\n' /* line feed */
32 #define SP ' ' /* space */
33 #define BS '\b' /* backspace */
34 #define HT '\t' /* horizontal tab */
35 #define VT '\013' /* vertical tab */
36 #define CR '\r' /* carriage return */
37 #define FF '\f' /* form feed */
38 #define QUOTE '\'' /* single quote */
39 #define DOUBLE_QUOTE '\"' /* double quote */
40 #define BACKSLASH '\\' /* backslash */
43 /* defines for constructing filenames */
45 #define CODE_SUFFIX ".code.c"
46 #define DEFINES_SUFFIX ".tab.h"
47 #define OUTPUT_SUFFIX ".tab.c"
48 #define VERBOSE_SUFFIX ".output"
72 /* the undefined value */
74 #define UNDEFINED (-1)
83 /* character macros */
85 #define IS_IDENT(c) (isalnum(c) || (c) == '_' || (c) == '.' || (c) == '$')
86 #define IS_OCTAL(c) ((c) >= '0' && (c) <= '7')
87 #define NUMERIC_VALUE(c) ((c) - '0')
92 #define ISTOKEN(s) ((s) < start_symbol)
93 #define ISVAR(s) ((s) >= start_symbol)
96 /* storage allocation macros */
98 #define CALLOC(k,n) (calloc((unsigned)(k),(unsigned)(n)))
99 #define FREE(x) (free((char*)(x)))
100 #define MALLOC(n) (malloc((unsigned)(n)))
101 #define NEW(t) ((t*)allocate(sizeof(t)))
102 #define NEW2(n,t) ((t*)allocate((unsigned)((n)*sizeof(t))))
103 #define REALLOC(p,n) (realloc((char*)(p),(unsigned)(n)))
106 /* the structure of a symbol table entry */
108 typedef struct bucket bucket;
123 /* the structure of the LR(0) state machine */
125 typedef struct core core;
131 short accessing_symbol;
137 /* the structure used to record shifts */
139 typedef struct shifts shifts;
149 /* the structure used to store reductions */
151 typedef struct reductions reductions;
154 struct reductions *next;
161 /* the structure used to represent parser actions */
163 typedef struct action action;
176 /* global variables */
190 extern char *banner[];
191 extern char *tables[];
192 extern char *header[];
194 extern char *trailer[];
196 extern char *action_file_name;
197 extern char *code_file_name;
198 extern char *defines_file_name;
199 extern char *input_file_name;
200 extern char *output_file_name;
201 extern char *text_file_name;
202 extern char *union_file_name;
203 extern char *verbose_file_name;
205 extern FILE *action_file;
206 extern FILE *code_file;
207 extern FILE *defines_file;
208 extern FILE *input_file;
209 extern FILE *output_file;
210 extern FILE *text_file;
211 extern FILE *union_file;
212 extern FILE *verbose_file;
221 extern char unionized;
222 extern char line_format[];
224 extern int start_symbol;
225 extern char **symbol_name;
226 extern short *symbol_value;
227 extern short *symbol_prec;
228 extern char *symbol_assoc;
236 extern short **derives;
237 extern char *nullable;
239 extern bucket *first_symbol;
240 extern bucket *last_symbol;
243 extern core *first_state;
244 extern shifts *first_shift;
245 extern reductions *first_reduction;
246 extern short *accessing_symbol;
247 extern core **state_table;
248 extern shifts **shift_table;
249 extern reductions **reduction_table;
251 extern short *LAruleno;
252 extern short *lookaheads;
253 extern short *goto_map;
254 extern short *from_state;
255 extern short *to_state;
257 extern action **parser;
260 extern short *SRconflicts;
261 extern short *RRconflicts;
262 extern short *defred;
263 extern short *rules_used;
264 extern short nunused;
265 extern short final_state;
267 /* global functions */
269 extern char *allocate();
270 extern bucket *lookup();
271 extern bucket *make_bucket();
274 /* system variables */
279 /* system functions */
282 extern char *calloc();
283 extern char *malloc();
284 extern char *realloc();
285 extern char *strcpy();