Fix the build
[mono-project.git] / mcs / jay / defs.h
blobfd9fc2348eeb919a0b77881bb219938e8f64504c
1 /*
2 * Copyright (c) 1989 The Regents of the University of California.
3 * All rights reserved.
5 * This code is derived from software contributed to Berkeley by
6 * Robert Paul Corbett.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
36 * @(#)defs.h 5.6 (Berkeley) 5/24/93
39 #include <assert.h>
40 #include <ctype.h>
41 #include <stdio.h>
42 #include <stdlib.h>
43 #include <string.h>
44 #include <errno.h>
46 /* Quiet warnings which might bother rpm */
47 #ifdef __GNUC__
48 #pragma GCC diagnostic ignored "-Wimplicit-function-declaration"
49 #pragma GCC diagnostic ignored "-Wreturn-type"
50 #endif
52 /* machine-dependent definitions */
53 /* the following definitions are for the Tahoe */
54 /* they might have to be changed for other machines */
56 /* MAXCHAR is the largest unsigned character value */
57 /* MAXSHORT is the largest value of a C short */
58 /* MINSHORT is the most negative value of a C short */
59 /* MAXTABLE is the maximum table size */
60 /* BITS_PER_WORD is the number of bits in a C unsigned */
61 /* WORDSIZE computes the number of words needed to */
62 /* store n bits */
63 /* BIT returns the value of the n-th bit starting */
64 /* from r (0-indexed) */
65 /* SETBIT sets the n-th bit starting from r */
67 #define MAXCHAR 255
68 #define MAXSHORT 32767
69 #define MINSHORT -32768
70 #define MAXTABLE 32500
71 #define BITS_PER_WORD 32
72 #define WORDSIZE(n) (((n)+(BITS_PER_WORD-1))/BITS_PER_WORD)
73 #define BIT(r, n) ((((r)[(n)>>5])>>((n)&31))&1)
74 #define SETBIT(r, n) ((r)[(n)>>5]|=((unsigned)1<<((n)&31)))
77 /* character names */
79 #define NUL '\0' /* the null character */
80 #define NEWLINE '\n' /* line feed */
81 #define SP ' ' /* space */
82 #define BS '\b' /* backspace */
83 #define HT '\t' /* horizontal tab */
84 #define VT '\013' /* vertical tab */
85 #define CR '\r' /* carriage return */
86 #define FF '\f' /* form feed */
87 #define QUOTE '\'' /* single quote */
88 #define DOUBLE_QUOTE '\"' /* double quote */
89 #define BACKSLASH '\\' /* backslash */
92 /* defines for constructing filenames */
94 #define CODE_SUFFIX ".code.c"
95 #define DEFINES_SUFFIX ".tab.h"
96 #define OUTPUT_SUFFIX ".tab.c"
97 #define VERBOSE_SUFFIX ".output"
100 /* keyword codes */
102 #define TOKEN 0
103 #define LEFT 1
104 #define RIGHT 2
105 #define NONASSOC 3
106 #define MARK 4
107 #define TEXT 5
108 #define TYPE 6
109 #define START 7
112 /* symbol classes */
114 #define UNKNOWN 0
115 #define TERM 1
116 #define NONTERM 2
119 /* the undefined value */
121 #define UNDEFINED (-1)
124 /* action codes */
126 #define SHIFT 1
127 #define REDUCE 2
130 /* character macros */
132 #define IS_IDENT(c) (isalnum(c) || (c) == '_' || (c) == '.' || (c) == '$')
133 #define IS_OCTAL(c) ((c) >= '0' && (c) <= '7')
134 #define NUMERIC_VALUE(c) ((c) - '0')
137 /* symbol macros */
139 #define ISTOKEN(s) ((s) < start_symbol)
140 #define ISVAR(s) ((s) >= start_symbol)
143 /* storage allocation macros */
145 #define CALLOC(k,n) (calloc((unsigned)(k),(unsigned)(n)))
146 #define FREE(x) (free((char*)(x)))
147 #define MALLOC(n) (malloc((unsigned)(n)))
148 #define NEW(t) ((t*)allocate(sizeof(t)))
149 #define NEW2(n,t) ((t*)allocate((unsigned)((n)*sizeof(t))))
150 #define REALLOC(p,n) (realloc((char*)(p),(unsigned)(n)))
153 /* the structure of a symbol table entry */
155 typedef struct bucket bucket;
156 struct bucket
158 struct bucket *link;
159 struct bucket *next;
160 char *name;
161 char *tag;
162 short value;
163 short index;
164 short prec;
165 #define class clas
166 char class;
167 char assoc;
171 /* the structure of the LR(0) state machine */
173 typedef struct core core;
174 struct core
176 struct core *next;
177 struct core *link;
178 short number;
179 short accessing_symbol;
180 short nitems;
181 short items[1];
185 /* the structure used to record shifts */
187 typedef struct shifts shifts;
188 struct shifts
190 struct shifts *next;
191 short number;
192 short nshifts;
193 short shift[1];
197 /* the structure used to store reductions */
199 typedef struct reductions reductions;
200 struct reductions
202 struct reductions *next;
203 short number;
204 short nreds;
205 short rules[1];
209 /* the structure used to represent parser actions */
211 typedef struct action action;
212 struct action
214 struct action *next;
215 short symbol;
216 short number;
217 short prec;
218 char action_code;
219 char assoc;
220 char suppressed;
224 /* global variables */
226 extern char tflag;
227 extern char vflag;
229 extern char *myname;
230 extern char *cptr;
231 extern char *line;
232 extern int lineno;
233 extern int outline;
235 extern char *action_file_name;
236 extern char *input_file_name;
237 extern char *prolog_file_name;
238 extern char *local_file_name;
239 extern char *verbose_file_name;
240 extern char *output_file_name;
242 extern FILE *action_file;
243 extern FILE *input_file;
244 extern FILE *prolog_file;
245 extern FILE *local_file;
246 extern FILE *verbose_file;
247 extern FILE *output_file;
249 extern int nitems;
250 extern int nrules;
251 extern int nsyms;
252 extern int ntokens;
253 extern int nvars;
254 extern int nmethods;
256 extern const char *line_format;
257 extern const char *default_line_format;
259 extern int start_symbol;
260 extern char **symbol_name;
261 extern short *symbol_value;
262 extern short *symbol_prec;
263 extern char *symbol_assoc;
264 extern char **methods;
266 extern short *ritem;
267 extern short *rlhs;
268 extern short *rrhs;
269 extern short *rprec;
270 extern char *rassoc;
272 extern short **derives;
273 extern char *nullable;
275 extern bucket *first_symbol;
276 extern bucket *last_symbol;
278 extern int nstates;
279 extern core *first_state;
280 extern shifts *first_shift;
281 extern reductions *first_reduction;
282 extern short *accessing_symbol;
283 extern core **state_table;
284 extern shifts **shift_table;
285 extern reductions **reduction_table;
286 extern unsigned *LA;
287 extern short *LAruleno;
288 extern short *lookaheads;
289 extern short *goto_map;
290 extern short *from_state;
291 extern short *to_state;
293 extern action **parser;
294 extern int SRtotal;
295 extern int RRtotal;
296 extern short *SRconflicts;
297 extern short *RRconflicts;
298 extern short *defred;
299 extern short *rules_used;
300 extern short nunused;
301 extern short final_state;
303 /* global functions */
305 char *
306 allocate (unsigned);
308 bucket *
309 lookup (const char *);
311 bucket *
312 make_bucket (const char *);
314 void
315 reflexive_transitive_closure (unsigned *R, int n);
317 void
318 done (int);
320 void
321 fatal (const char*);
323 void
324 no_space (void);
326 void
327 finalize_closure (void);
329 void
330 closure (short *nucleus, int n);
332 void
333 set_first_derives (void);
335 void
336 open_error (const char *filename);
338 void
339 make_parser (void);
341 void
342 free_parser (void);
344 void
345 lr0 (void);
347 void
348 output (void);
350 void
351 verbose (void);
353 void
354 xxlr0 (void);
356 void
357 reader (void);
359 void
360 lalr (void);
362 void
363 free_symbols (void);
365 void
366 free_symbol_table (void);
368 void
369 create_symbol_table (void);
371 void
372 fatal (const char *msg);
374 void
375 no_space (void);
377 void
378 open_error (const char *filename);
380 void
381 unexpected_EOF (void);
383 void
384 syntax_error (int st_lineno, const char *st_line, const char *st_cptr);
386 void
387 unterminated_comment (int c_lineno, const char *c_line, const char *c_cptr);
389 void
390 unterminated_string (int s_lineno, const char *s_line, const char *s_cptr);
392 void
393 unterminated_text (int t_lineno, const char *t_line, const char *t_cptr);
395 void
396 illegal_tag (int t_lineno, const char *t_line, const char *t_cptr);
398 void
399 illegal_character (const char *c_cptr);
401 void
402 used_reserved (const char *s);
404 void
405 tokenized_start (const char *s);
407 void
408 retyped_warning (const char *s);
410 void
411 reprec_warning (const char *s);
413 void
414 revalued_warning (const char *s);
416 void
417 terminal_start (const char *s);
419 void
420 restarted_warning (void);
422 void
423 no_grammar (void);
425 void
426 terminal_lhs (int s_lineno);
428 void
429 prec_redeclared (void);
431 void
432 unterminated_action (int a_lineno, const char *a_line, const char *a_cptr);
434 void
435 dollar_warning (int a_lineno, int i);
437 void
438 dollar_error (int a_lineno, const char *a_line, char *a_cptr);
440 void
441 untyped_lhs (void);
443 void
444 untyped_rhs (int i, const char *s);
446 void
447 unknown_rhs (int i);
449 void
450 default_action_warning (void);
452 void
453 undefined_goal (const char *s);
455 void
456 undefined_symbol_warning (const char *s);