1*0a6a1f1dSLionel Sambuc /* $NetBSD: defs.h,v 1.9 2015/01/04 01:34:20 christos Exp $ */ 24a17663cSThomas Veerman 34a17663cSThomas Veerman #if HAVE_NBTOOL_CONFIG_H 44a17663cSThomas Veerman #include "nbtool_config.h" 54a17663cSThomas Veerman #endif 6*0a6a1f1dSLionel Sambuc /* Id: defs.h,v 1.51 2014/10/02 22:38:13 tom Exp */ 74a17663cSThomas Veerman 84a17663cSThomas Veerman #ifdef HAVE_CONFIG_H 94a17663cSThomas Veerman #include <config.h> 104a17663cSThomas Veerman #endif 114a17663cSThomas Veerman 12*0a6a1f1dSLionel Sambuc #include <limits.h> 134a17663cSThomas Veerman #include <stdlib.h> 144a17663cSThomas Veerman #include <string.h> 154a17663cSThomas Veerman #include <errno.h> 164a17663cSThomas Veerman #include <assert.h> 174a17663cSThomas Veerman #include <ctype.h> 184a17663cSThomas Veerman #include <stdio.h> 194a17663cSThomas Veerman 2084d9c625SLionel Sambuc #if defined(__cplusplus) /* __cplusplus, etc. */ 2184d9c625SLionel Sambuc #define class myClass 2284d9c625SLionel Sambuc #endif 2384d9c625SLionel Sambuc 244a17663cSThomas Veerman #define YYMAJOR 1 254a17663cSThomas Veerman #define YYMINOR 9 264a17663cSThomas Veerman 274a17663cSThomas Veerman #define CONCAT(first,second) first #second 284a17663cSThomas Veerman #define CONCAT1(string,number) CONCAT(string, number) 294a17663cSThomas Veerman #define CONCAT2(first,second) #first "." #second 304a17663cSThomas Veerman 314a17663cSThomas Veerman #ifdef YYPATCH 324a17663cSThomas Veerman #define VSTRING(a,b) CONCAT2(a,b) CONCAT1(" ",YYPATCH) 334a17663cSThomas Veerman #else 344a17663cSThomas Veerman #define VSTRING(a,b) CONCAT2(a,b) 354a17663cSThomas Veerman #endif 364a17663cSThomas Veerman 374a17663cSThomas Veerman #define VERSION VSTRING(YYMAJOR, YYMINOR) 384a17663cSThomas Veerman 39*0a6a1f1dSLionel Sambuc /* machine-dependent definitions: */ 404a17663cSThomas Veerman 414a17663cSThomas Veerman /* MAXCHAR is the largest unsigned character value */ 424a17663cSThomas Veerman /* MAXTABLE is the maximum table size */ 43*0a6a1f1dSLionel Sambuc /* YYINT is the smallest C integer type that can be */ 44*0a6a1f1dSLionel Sambuc /* used to address a table of size MAXTABLE */ 45*0a6a1f1dSLionel Sambuc /* MAXYYINT is the largest value of a YYINT */ 46*0a6a1f1dSLionel Sambuc /* MINYYINT is the most negative value of a YYINT */ 474a17663cSThomas Veerman /* BITS_PER_WORD is the number of bits in a C unsigned */ 484a17663cSThomas Veerman /* WORDSIZE computes the number of words needed to */ 494a17663cSThomas Veerman /* store n bits */ 504a17663cSThomas Veerman /* BIT returns the value of the n-th bit starting */ 514a17663cSThomas Veerman /* from r (0-indexed) */ 524a17663cSThomas Veerman /* SETBIT sets the n-th bit starting from r */ 534a17663cSThomas Veerman 54*0a6a1f1dSLionel Sambuc #define MAXCHAR UCHAR_MAX 55*0a6a1f1dSLionel Sambuc #ifndef MAXTABLE 564a17663cSThomas Veerman #define MAXTABLE 32500 57*0a6a1f1dSLionel Sambuc #endif 58*0a6a1f1dSLionel Sambuc #if MAXTABLE <= SHRT_MAX 59*0a6a1f1dSLionel Sambuc #define YYINT short 60*0a6a1f1dSLionel Sambuc #define MAXYYINT SHRT_MAX 61*0a6a1f1dSLionel Sambuc #define MINYYINT SHRT_MIN 62*0a6a1f1dSLionel Sambuc #elif MAXTABLE <= INT_MAX 63*0a6a1f1dSLionel Sambuc #define YYINT int 64*0a6a1f1dSLionel Sambuc #define MAXYYINT INT_MAX 65*0a6a1f1dSLionel Sambuc #define MINYYINT INT_MIN 66*0a6a1f1dSLionel Sambuc #else 67*0a6a1f1dSLionel Sambuc #error "MAXTABLE is too large for this machine architecture!" 68*0a6a1f1dSLionel Sambuc #endif 69*0a6a1f1dSLionel Sambuc 70*0a6a1f1dSLionel Sambuc #define BITS_PER_WORD ((int) sizeof (unsigned) * CHAR_BIT) 714a17663cSThomas Veerman #define WORDSIZE(n) (((n)+(BITS_PER_WORD-1))/BITS_PER_WORD) 72*0a6a1f1dSLionel Sambuc #define BIT(r, n) ((((r)[(n)/BITS_PER_WORD])>>((n)&(BITS_PER_WORD-1)))&1) 73*0a6a1f1dSLionel Sambuc #define SETBIT(r, n) ((r)[(n)/BITS_PER_WORD]|=((unsigned)1<<((n)&(BITS_PER_WORD-1)))) 744a17663cSThomas Veerman 754a17663cSThomas Veerman /* character names */ 764a17663cSThomas Veerman 774a17663cSThomas Veerman #define NUL '\0' /* the null character */ 784a17663cSThomas Veerman #define NEWLINE '\n' /* line feed */ 794a17663cSThomas Veerman #define SP ' ' /* space */ 804a17663cSThomas Veerman #define BS '\b' /* backspace */ 814a17663cSThomas Veerman #define HT '\t' /* horizontal tab */ 824a17663cSThomas Veerman #define VT '\013' /* vertical tab */ 834a17663cSThomas Veerman #define CR '\r' /* carriage return */ 844a17663cSThomas Veerman #define FF '\f' /* form feed */ 854a17663cSThomas Veerman #define QUOTE '\'' /* single quote */ 864a17663cSThomas Veerman #define DOUBLE_QUOTE '\"' /* double quote */ 874a17663cSThomas Veerman #define BACKSLASH '\\' /* backslash */ 884a17663cSThomas Veerman 894a17663cSThomas Veerman #define UCH(c) (unsigned char)(c) 904a17663cSThomas Veerman 914a17663cSThomas Veerman /* defines for constructing filenames */ 924a17663cSThomas Veerman 934a17663cSThomas Veerman #if defined(VMS) 944a17663cSThomas Veerman #define CODE_SUFFIX "_code.c" 954a17663cSThomas Veerman #define DEFINES_SUFFIX "_tab.h" 964a17663cSThomas Veerman #define EXTERNS_SUFFIX "_tab.i" 974a17663cSThomas Veerman #define OUTPUT_SUFFIX "_tab.c" 984a17663cSThomas Veerman #else 994a17663cSThomas Veerman #define CODE_SUFFIX ".code.c" 1004a17663cSThomas Veerman #define DEFINES_SUFFIX ".tab.h" 1014a17663cSThomas Veerman #define EXTERNS_SUFFIX ".tab.i" 1024a17663cSThomas Veerman #define OUTPUT_SUFFIX ".tab.c" 1034a17663cSThomas Veerman #endif 1044a17663cSThomas Veerman #define VERBOSE_SUFFIX ".output" 1054a17663cSThomas Veerman #define GRAPH_SUFFIX ".dot" 1064a17663cSThomas Veerman 1074a17663cSThomas Veerman /* keyword codes */ 1084a17663cSThomas Veerman 1094a17663cSThomas Veerman #define TOKEN 0 1104a17663cSThomas Veerman #define LEFT 1 1114a17663cSThomas Veerman #define RIGHT 2 1124a17663cSThomas Veerman #define NONASSOC 3 1134a17663cSThomas Veerman #define MARK 4 1144a17663cSThomas Veerman #define TEXT 5 1154a17663cSThomas Veerman #define TYPE 6 1164a17663cSThomas Veerman #define START 7 1174a17663cSThomas Veerman #define UNION 8 1184a17663cSThomas Veerman #define IDENT 9 1194a17663cSThomas Veerman #define EXPECT 10 1204a17663cSThomas Veerman #define EXPECT_RR 11 1214a17663cSThomas Veerman #define PURE_PARSER 12 1224a17663cSThomas Veerman #define PARSE_PARAM 13 1234a17663cSThomas Veerman #define LEX_PARAM 14 1244a17663cSThomas Veerman #define POSIX_YACC 15 125*0a6a1f1dSLionel Sambuc #define TOKEN_TABLE 16 126*0a6a1f1dSLionel Sambuc #define ERROR_VERBOSE 17 127*0a6a1f1dSLionel Sambuc #define XXXDEBUG 18 128*0a6a1f1dSLionel Sambuc 129*0a6a1f1dSLionel Sambuc #if defined(YYBTYACC) 130*0a6a1f1dSLionel Sambuc #define LOCATIONS 19 131*0a6a1f1dSLionel Sambuc #define DESTRUCTOR 20 132*0a6a1f1dSLionel Sambuc #define INITIAL_ACTION 21 133*0a6a1f1dSLionel Sambuc #endif 1344a17663cSThomas Veerman 1354a17663cSThomas Veerman /* symbol classes */ 1364a17663cSThomas Veerman 1374a17663cSThomas Veerman #define UNKNOWN 0 1384a17663cSThomas Veerman #define TERM 1 1394a17663cSThomas Veerman #define NONTERM 2 140*0a6a1f1dSLionel Sambuc #define ACTION 3 141*0a6a1f1dSLionel Sambuc #define ARGUMENT 4 1424a17663cSThomas Veerman 1434a17663cSThomas Veerman /* the undefined value */ 1444a17663cSThomas Veerman 1454a17663cSThomas Veerman #define UNDEFINED (-1) 1464a17663cSThomas Veerman 1474a17663cSThomas Veerman /* action codes */ 1484a17663cSThomas Veerman 1494a17663cSThomas Veerman #define SHIFT 1 1504a17663cSThomas Veerman #define REDUCE 2 1514a17663cSThomas Veerman 1524a17663cSThomas Veerman /* character macros */ 1534a17663cSThomas Veerman 1544a17663cSThomas Veerman #define IS_IDENT(c) (isalnum(c) || (c) == '_' || (c) == '.' || (c) == '$') 1554a17663cSThomas Veerman #define IS_OCTAL(c) ((c) >= '0' && (c) <= '7') 1564a17663cSThomas Veerman #define NUMERIC_VALUE(c) ((c) - '0') 1574a17663cSThomas Veerman 1584a17663cSThomas Veerman /* symbol macros */ 1594a17663cSThomas Veerman 1604a17663cSThomas Veerman #define ISTOKEN(s) ((s) < start_symbol) 1614a17663cSThomas Veerman #define ISVAR(s) ((s) >= start_symbol) 1624a17663cSThomas Veerman 1634a17663cSThomas Veerman /* storage allocation macros */ 1644a17663cSThomas Veerman 1654a17663cSThomas Veerman #define CALLOC(k,n) (calloc((size_t)(k),(size_t)(n))) 1664a17663cSThomas Veerman #define FREE(x) (free((char*)(x))) 1674a17663cSThomas Veerman #define MALLOC(n) (malloc((size_t)(n))) 168*0a6a1f1dSLionel Sambuc #define TCMALLOC(t,n) ((t*) calloc((size_t)(n), sizeof(t))) 16984d9c625SLionel Sambuc #define TMALLOC(t,n) ((t*) malloc((size_t)(n) * sizeof(t))) 1704a17663cSThomas Veerman #define NEW(t) ((t*)allocate(sizeof(t))) 1714a17663cSThomas Veerman #define NEW2(n,t) ((t*)allocate(((size_t)(n)*sizeof(t)))) 1724a17663cSThomas Veerman #define REALLOC(p,n) (realloc((char*)(p),(size_t)(n))) 17384d9c625SLionel Sambuc #define TREALLOC(t,p,n) ((t*)realloc((char*)(p), (size_t)(n) * sizeof(t))) 1744a17663cSThomas Veerman 1754a17663cSThomas Veerman #define DO_FREE(x) if (x) { FREE(x); x = 0; } 1764a17663cSThomas Veerman 1774a17663cSThomas Veerman #define NO_SPACE(p) if (p == 0) no_space(); assert(p != 0) 1784a17663cSThomas Veerman 1794a17663cSThomas Veerman /* messages */ 1804a17663cSThomas Veerman #define PLURAL(n) ((n) > 1 ? "s" : "") 1814a17663cSThomas Veerman 182*0a6a1f1dSLionel Sambuc /* 183*0a6a1f1dSLionel Sambuc * Features which depend indirectly on the btyacc configuration, but are not 184*0a6a1f1dSLionel Sambuc * essential. 185*0a6a1f1dSLionel Sambuc */ 186*0a6a1f1dSLionel Sambuc #if defined(YYBTYACC) 187*0a6a1f1dSLionel Sambuc #define USE_HEADER_GUARDS 1 188*0a6a1f1dSLionel Sambuc #else 189*0a6a1f1dSLionel Sambuc #define USE_HEADER_GUARDS 0 190*0a6a1f1dSLionel Sambuc #endif 191*0a6a1f1dSLionel Sambuc 1924a17663cSThomas Veerman typedef char Assoc_t; 1934a17663cSThomas Veerman typedef char Class_t; 194*0a6a1f1dSLionel Sambuc typedef YYINT Index_t; 195*0a6a1f1dSLionel Sambuc typedef YYINT Value_t; 1964a17663cSThomas Veerman 1974a17663cSThomas Veerman /* the structure of a symbol table entry */ 1984a17663cSThomas Veerman 1994a17663cSThomas Veerman typedef struct bucket bucket; 2004a17663cSThomas Veerman struct bucket 2014a17663cSThomas Veerman { 2024a17663cSThomas Veerman struct bucket *link; 2034a17663cSThomas Veerman struct bucket *next; 2044a17663cSThomas Veerman char *name; 2054a17663cSThomas Veerman char *tag; 206*0a6a1f1dSLionel Sambuc #if defined(YYBTYACC) 207*0a6a1f1dSLionel Sambuc char **argnames; 208*0a6a1f1dSLionel Sambuc char **argtags; 209*0a6a1f1dSLionel Sambuc int args; 210*0a6a1f1dSLionel Sambuc char *destructor; 211*0a6a1f1dSLionel Sambuc #endif 2124a17663cSThomas Veerman Value_t value; 2134a17663cSThomas Veerman Index_t index; 2144a17663cSThomas Veerman Value_t prec; 2154a17663cSThomas Veerman Class_t class; 2164a17663cSThomas Veerman Assoc_t assoc; 2174a17663cSThomas Veerman }; 2184a17663cSThomas Veerman 2194a17663cSThomas Veerman /* the structure of the LR(0) state machine */ 2204a17663cSThomas Veerman 2214a17663cSThomas Veerman typedef struct core core; 2224a17663cSThomas Veerman struct core 2234a17663cSThomas Veerman { 2244a17663cSThomas Veerman struct core *next; 2254a17663cSThomas Veerman struct core *link; 2264a17663cSThomas Veerman Value_t number; 2274a17663cSThomas Veerman Value_t accessing_symbol; 2284a17663cSThomas Veerman Value_t nitems; 2294a17663cSThomas Veerman Value_t items[1]; 2304a17663cSThomas Veerman }; 2314a17663cSThomas Veerman 2324a17663cSThomas Veerman /* the structure used to record shifts */ 2334a17663cSThomas Veerman 2344a17663cSThomas Veerman typedef struct shifts shifts; 2354a17663cSThomas Veerman struct shifts 2364a17663cSThomas Veerman { 2374a17663cSThomas Veerman struct shifts *next; 2384a17663cSThomas Veerman Value_t number; 2394a17663cSThomas Veerman Value_t nshifts; 2404a17663cSThomas Veerman Value_t shift[1]; 2414a17663cSThomas Veerman }; 2424a17663cSThomas Veerman 2434a17663cSThomas Veerman /* the structure used to store reductions */ 2444a17663cSThomas Veerman 2454a17663cSThomas Veerman typedef struct reductions reductions; 2464a17663cSThomas Veerman struct reductions 2474a17663cSThomas Veerman { 2484a17663cSThomas Veerman struct reductions *next; 2494a17663cSThomas Veerman Value_t number; 2504a17663cSThomas Veerman Value_t nreds; 2514a17663cSThomas Veerman Value_t rules[1]; 2524a17663cSThomas Veerman }; 2534a17663cSThomas Veerman 2544a17663cSThomas Veerman /* the structure used to represent parser actions */ 2554a17663cSThomas Veerman 2564a17663cSThomas Veerman typedef struct action action; 2574a17663cSThomas Veerman struct action 2584a17663cSThomas Veerman { 2594a17663cSThomas Veerman struct action *next; 2604a17663cSThomas Veerman Value_t symbol; 2614a17663cSThomas Veerman Value_t number; 2624a17663cSThomas Veerman Value_t prec; 2634a17663cSThomas Veerman char action_code; 2644a17663cSThomas Veerman Assoc_t assoc; 2654a17663cSThomas Veerman char suppressed; 2664a17663cSThomas Veerman }; 2674a17663cSThomas Veerman 2684a17663cSThomas Veerman /* the structure used to store parse/lex parameters */ 2694a17663cSThomas Veerman typedef struct param param; 2704a17663cSThomas Veerman struct param 2714a17663cSThomas Veerman { 2724a17663cSThomas Veerman struct param *next; 2734a17663cSThomas Veerman char *name; /* parameter name */ 2744a17663cSThomas Veerman char *type; /* everything before parameter name */ 2754a17663cSThomas Veerman char *type2; /* everything after parameter name */ 2764a17663cSThomas Veerman }; 2774a17663cSThomas Veerman 2784a17663cSThomas Veerman /* global variables */ 2794a17663cSThomas Veerman 2804a17663cSThomas Veerman extern char dflag; 2814a17663cSThomas Veerman extern char gflag; 2824a17663cSThomas Veerman extern char iflag; 2834a17663cSThomas Veerman extern char lflag; 2844a17663cSThomas Veerman extern char rflag; 28584d9c625SLionel Sambuc extern char sflag; 2864a17663cSThomas Veerman extern char tflag; 2874a17663cSThomas Veerman extern char vflag; 2884a17663cSThomas Veerman extern const char *symbol_prefix; 2894a17663cSThomas Veerman 2904a17663cSThomas Veerman extern const char *myname; 2914a17663cSThomas Veerman extern char *cptr; 2924a17663cSThomas Veerman extern char *line; 2934a17663cSThomas Veerman extern int lineno; 2944a17663cSThomas Veerman extern int outline; 2954a17663cSThomas Veerman extern int exit_code; 2964a17663cSThomas Veerman extern int pure_parser; 297*0a6a1f1dSLionel Sambuc extern int token_table; 298*0a6a1f1dSLionel Sambuc extern int error_verbose; 299*0a6a1f1dSLionel Sambuc #if defined(YYBTYACC) 300*0a6a1f1dSLionel Sambuc extern int locations; 301*0a6a1f1dSLionel Sambuc extern int backtrack; 302*0a6a1f1dSLionel Sambuc extern int destructor; 303*0a6a1f1dSLionel Sambuc extern char *initial_action; 304*0a6a1f1dSLionel Sambuc #endif 3054a17663cSThomas Veerman 3064a17663cSThomas Veerman extern const char *const banner[]; 3074a17663cSThomas Veerman extern const char *const xdecls[]; 3084a17663cSThomas Veerman extern const char *const tables[]; 3094a17663cSThomas Veerman extern const char *const global_vars[]; 3104a17663cSThomas Veerman extern const char *const impure_vars[]; 3114a17663cSThomas Veerman extern const char *const hdr_defs[]; 3124a17663cSThomas Veerman extern const char *const hdr_vars[]; 3134a17663cSThomas Veerman extern const char *const body_1[]; 3144a17663cSThomas Veerman extern const char *const body_vars[]; 3154a17663cSThomas Veerman extern const char *const body_2[]; 3164a17663cSThomas Veerman extern const char *const body_3[]; 3174a17663cSThomas Veerman extern const char *const trailer[]; 3184a17663cSThomas Veerman 3194a17663cSThomas Veerman extern char *code_file_name; 3204a17663cSThomas Veerman extern char *input_file_name; 3214a17663cSThomas Veerman extern char *defines_file_name; 3224a17663cSThomas Veerman extern char *externs_file_name; 3234a17663cSThomas Veerman 3244a17663cSThomas Veerman extern FILE *action_file; 3254a17663cSThomas Veerman extern FILE *code_file; 3264a17663cSThomas Veerman extern FILE *defines_file; 3274a17663cSThomas Veerman extern FILE *externs_file; 3284a17663cSThomas Veerman extern FILE *input_file; 3294a17663cSThomas Veerman extern FILE *output_file; 3304a17663cSThomas Veerman extern FILE *text_file; 3314a17663cSThomas Veerman extern FILE *union_file; 3324a17663cSThomas Veerman extern FILE *verbose_file; 3334a17663cSThomas Veerman extern FILE *graph_file; 3344a17663cSThomas Veerman 335*0a6a1f1dSLionel Sambuc extern Value_t nitems; 336*0a6a1f1dSLionel Sambuc extern Value_t nrules; 337*0a6a1f1dSLionel Sambuc extern Value_t nsyms; 338*0a6a1f1dSLionel Sambuc extern Value_t ntokens; 339*0a6a1f1dSLionel Sambuc extern Value_t nvars; 3404a17663cSThomas Veerman extern int ntags; 3414a17663cSThomas Veerman 3424a17663cSThomas Veerman extern char unionized; 3434a17663cSThomas Veerman extern char line_format[]; 3444a17663cSThomas Veerman 3454a17663cSThomas Veerman extern Value_t start_symbol; 3464a17663cSThomas Veerman extern char **symbol_name; 3474a17663cSThomas Veerman extern char **symbol_pname; 3484a17663cSThomas Veerman extern Value_t *symbol_value; 3494a17663cSThomas Veerman extern Value_t *symbol_prec; 3504a17663cSThomas Veerman extern char *symbol_assoc; 3514a17663cSThomas Veerman 352*0a6a1f1dSLionel Sambuc #if defined(YYBTYACC) 353*0a6a1f1dSLionel Sambuc extern Value_t *symbol_pval; 354*0a6a1f1dSLionel Sambuc extern char **symbol_destructor; 355*0a6a1f1dSLionel Sambuc extern char **symbol_type_tag; 356*0a6a1f1dSLionel Sambuc #endif 357*0a6a1f1dSLionel Sambuc 3584a17663cSThomas Veerman extern Value_t *ritem; 3594a17663cSThomas Veerman extern Value_t *rlhs; 3604a17663cSThomas Veerman extern Value_t *rrhs; 3614a17663cSThomas Veerman extern Value_t *rprec; 3624a17663cSThomas Veerman extern Assoc_t *rassoc; 3634a17663cSThomas Veerman 3644a17663cSThomas Veerman extern Value_t **derives; 3654a17663cSThomas Veerman extern char *nullable; 3664a17663cSThomas Veerman 3674a17663cSThomas Veerman extern bucket *first_symbol; 3684a17663cSThomas Veerman extern bucket *last_symbol; 3694a17663cSThomas Veerman 3704a17663cSThomas Veerman extern int nstates; 3714a17663cSThomas Veerman extern core *first_state; 3724a17663cSThomas Veerman extern shifts *first_shift; 3734a17663cSThomas Veerman extern reductions *first_reduction; 3744a17663cSThomas Veerman extern Value_t *accessing_symbol; 3754a17663cSThomas Veerman extern core **state_table; 3764a17663cSThomas Veerman extern shifts **shift_table; 3774a17663cSThomas Veerman extern reductions **reduction_table; 3784a17663cSThomas Veerman extern unsigned *LA; 3794a17663cSThomas Veerman extern Value_t *LAruleno; 3804a17663cSThomas Veerman extern Value_t *lookaheads; 381*0a6a1f1dSLionel Sambuc extern Value_t *goto_base; 3824a17663cSThomas Veerman extern Value_t *goto_map; 3834a17663cSThomas Veerman extern Value_t *from_state; 3844a17663cSThomas Veerman extern Value_t *to_state; 3854a17663cSThomas Veerman 3864a17663cSThomas Veerman extern action **parser; 3874a17663cSThomas Veerman extern int SRexpect; 3884a17663cSThomas Veerman extern int RRexpect; 3894a17663cSThomas Veerman extern int SRtotal; 3904a17663cSThomas Veerman extern int RRtotal; 3914a17663cSThomas Veerman extern Value_t *SRconflicts; 3924a17663cSThomas Veerman extern Value_t *RRconflicts; 3934a17663cSThomas Veerman extern Value_t *defred; 3944a17663cSThomas Veerman extern Value_t *rules_used; 3954a17663cSThomas Veerman extern Value_t nunused; 3964a17663cSThomas Veerman extern Value_t final_state; 3974a17663cSThomas Veerman 3984a17663cSThomas Veerman extern Value_t *itemset; 3994a17663cSThomas Veerman extern Value_t *itemsetend; 4004a17663cSThomas Veerman extern unsigned *ruleset; 4014a17663cSThomas Veerman 4024a17663cSThomas Veerman extern param *lex_param; 4034a17663cSThomas Veerman extern param *parse_param; 4044a17663cSThomas Veerman 4054a17663cSThomas Veerman /* global functions */ 4064a17663cSThomas Veerman 4074a17663cSThomas Veerman #ifndef GCC_NORETURN 40884d9c625SLionel Sambuc #if defined(__dead2) 40984d9c625SLionel Sambuc #define GCC_NORETURN __dead2 41084d9c625SLionel Sambuc #elif defined(__dead) 41184d9c625SLionel Sambuc #define GCC_NORETURN __dead 41284d9c625SLionel Sambuc #else 4134a17663cSThomas Veerman #define GCC_NORETURN /* nothing */ 4144a17663cSThomas Veerman #endif 41584d9c625SLionel Sambuc #endif 4164a17663cSThomas Veerman 4174a17663cSThomas Veerman #ifndef GCC_UNUSED 41884d9c625SLionel Sambuc #if defined(__unused) 41984d9c625SLionel Sambuc #define GCC_UNUSED __unused 42084d9c625SLionel Sambuc #else 4214a17663cSThomas Veerman #define GCC_UNUSED /* nothing */ 4224a17663cSThomas Veerman #endif 42384d9c625SLionel Sambuc #endif 4244a17663cSThomas Veerman 425*0a6a1f1dSLionel Sambuc #ifndef GCC_PRINTFLIKE 426*0a6a1f1dSLionel Sambuc #define GCC_PRINTFLIKE(fmt,var) /*nothing*/ 427*0a6a1f1dSLionel Sambuc #endif 428*0a6a1f1dSLionel Sambuc 4294a17663cSThomas Veerman /* closure.c */ 4304a17663cSThomas Veerman extern void closure(Value_t * nucleus, int n); 4314a17663cSThomas Veerman extern void finalize_closure(void); 4324a17663cSThomas Veerman extern void set_first_derives(void); 4334a17663cSThomas Veerman 4344a17663cSThomas Veerman /* error.c */ 435*0a6a1f1dSLionel Sambuc extern void arg_number_disagree_warning(int a_lineno, char *a_name); 436*0a6a1f1dSLionel Sambuc extern void arg_type_disagree_warning(int a_lineno, int i, char *a_name); 437*0a6a1f1dSLionel Sambuc extern void at_error(int a_lineno, char *a_line, char *a_cptr) GCC_NORETURN; 438*0a6a1f1dSLionel Sambuc extern void at_warning(int a_lineno, int i); 439*0a6a1f1dSLionel Sambuc extern void bad_formals(void) GCC_NORETURN; 4404a17663cSThomas Veerman extern void default_action_warning(void); 441*0a6a1f1dSLionel Sambuc struct ainfo { 442*0a6a1f1dSLionel Sambuc int a_lineno; 443*0a6a1f1dSLionel Sambuc char *a_line; 444*0a6a1f1dSLionel Sambuc char *a_cptr; 445*0a6a1f1dSLionel Sambuc }; 446*0a6a1f1dSLionel Sambuc extern void destructor_redeclared_warning(const struct ainfo *); 4474a17663cSThomas Veerman extern void dollar_error(int a_lineno, char *a_line, char *a_cptr) GCC_NORETURN; 4484a17663cSThomas Veerman extern void dollar_warning(int a_lineno, int i); 4494a17663cSThomas Veerman extern void fatal(const char *msg) GCC_NORETURN; 4504a17663cSThomas Veerman extern void illegal_character(char *c_cptr) GCC_NORETURN; 4514a17663cSThomas Veerman extern void illegal_tag(int t_lineno, char *t_line, char *t_cptr) GCC_NORETURN; 4524a17663cSThomas Veerman extern void missing_brace(void) GCC_NORETURN; 4534a17663cSThomas Veerman extern void no_grammar(void) GCC_NORETURN; 4544a17663cSThomas Veerman extern void no_space(void) GCC_NORETURN; 4554a17663cSThomas Veerman extern void open_error(const char *filename) GCC_NORETURN; 4564a17663cSThomas Veerman extern void over_unionized(char *u_cptr) GCC_NORETURN; 4574a17663cSThomas Veerman extern void prec_redeclared(void); 4584a17663cSThomas Veerman extern void reprec_warning(char *s); 4594a17663cSThomas Veerman extern void restarted_warning(void); 4604a17663cSThomas Veerman extern void retyped_warning(char *s); 4614a17663cSThomas Veerman extern void revalued_warning(char *s); 462*0a6a1f1dSLionel Sambuc extern void start_requires_args(char *a_name); 4634a17663cSThomas Veerman extern void syntax_error(int st_lineno, char *st_line, char *st_cptr) GCC_NORETURN; 4644a17663cSThomas Veerman extern void terminal_lhs(int s_lineno) GCC_NORETURN; 4654a17663cSThomas Veerman extern void terminal_start(char *s) GCC_NORETURN; 4664a17663cSThomas Veerman extern void tokenized_start(char *s) GCC_NORETURN; 4674a17663cSThomas Veerman extern void undefined_goal(char *s) GCC_NORETURN; 4684a17663cSThomas Veerman extern void undefined_symbol_warning(char *s); 4694a17663cSThomas Veerman extern void unexpected_EOF(void) GCC_NORETURN; 470*0a6a1f1dSLionel Sambuc extern void unknown_arg_warning(int d_lineno, const char *dlr_opt, const char *d_arg, const char *d_line, const char *d_cptr); 4714a17663cSThomas Veerman extern void unknown_rhs(int i) GCC_NORETURN; 472*0a6a1f1dSLionel Sambuc extern void unsupported_flag_warning(const char *flag, const char *details); 473*0a6a1f1dSLionel Sambuc extern void unterminated_action(const struct ainfo *); 474*0a6a1f1dSLionel Sambuc extern void unterminated_comment(const struct ainfo *) GCC_NORETURN; 475*0a6a1f1dSLionel Sambuc extern void unterminated_string(const struct ainfo *) GCC_NORETURN; 476*0a6a1f1dSLionel Sambuc extern void unterminated_text(const struct ainfo *) GCC_NORETURN; 477*0a6a1f1dSLionel Sambuc extern void unterminated_union(const struct ainfo *) GCC_NORETURN; 478*0a6a1f1dSLionel Sambuc extern void untyped_arg_warning(int a_lineno, const char *dlr_opt, const char *a_name); 4794a17663cSThomas Veerman extern void untyped_lhs(void) GCC_NORETURN; 4804a17663cSThomas Veerman extern void untyped_rhs(int i, char *s) GCC_NORETURN; 4814a17663cSThomas Veerman extern void used_reserved(char *s) GCC_NORETURN; 482*0a6a1f1dSLionel Sambuc extern void unterminated_arglist(const struct ainfo *) GCC_NORETURN; 483*0a6a1f1dSLionel Sambuc extern void wrong_number_args_warning(const char *which, const char *a_name); 484*0a6a1f1dSLionel Sambuc extern void wrong_type_for_arg_warning(int i, char *a_name); 4854a17663cSThomas Veerman 4864a17663cSThomas Veerman /* graph.c */ 4874a17663cSThomas Veerman extern void graph(void); 4884a17663cSThomas Veerman 4894a17663cSThomas Veerman /* lalr.c */ 4904a17663cSThomas Veerman extern void lalr(void); 4914a17663cSThomas Veerman 4924a17663cSThomas Veerman /* lr0.c */ 4934a17663cSThomas Veerman extern void lr0(void); 4944a17663cSThomas Veerman extern void show_cores(void); 4954a17663cSThomas Veerman extern void show_ritems(void); 4964a17663cSThomas Veerman extern void show_rrhs(void); 4974a17663cSThomas Veerman extern void show_shifts(void); 4984a17663cSThomas Veerman 4994a17663cSThomas Veerman /* main.c */ 5004a17663cSThomas Veerman extern void *allocate(size_t n); 5014a17663cSThomas Veerman extern void done(int k) GCC_NORETURN; 5024a17663cSThomas Veerman 5034a17663cSThomas Veerman /* mkpar.c */ 5044a17663cSThomas Veerman extern void free_parser(void); 5054a17663cSThomas Veerman extern void make_parser(void); 5064a17663cSThomas Veerman 507*0a6a1f1dSLionel Sambuc /* mstring.c */ 508*0a6a1f1dSLionel Sambuc struct mstring 509*0a6a1f1dSLionel Sambuc { 510*0a6a1f1dSLionel Sambuc char *base, *ptr, *end; 511*0a6a1f1dSLionel Sambuc }; 512*0a6a1f1dSLionel Sambuc 513*0a6a1f1dSLionel Sambuc extern void msprintf(struct mstring *, const char *, ...) GCC_PRINTFLIKE(2,3); 514*0a6a1f1dSLionel Sambuc extern int mputchar(struct mstring *, int); 515*0a6a1f1dSLionel Sambuc extern struct mstring *msnew(void); 516*0a6a1f1dSLionel Sambuc extern char *msdone(struct mstring *); 517*0a6a1f1dSLionel Sambuc extern int strnscmp(const char *, const char *); 518*0a6a1f1dSLionel Sambuc extern unsigned int strnshash(const char *); 519*0a6a1f1dSLionel Sambuc 520*0a6a1f1dSLionel Sambuc #define mputc(m, ch) (((m)->ptr == (m)->end) \ 521*0a6a1f1dSLionel Sambuc ? mputchar(m,ch) \ 522*0a6a1f1dSLionel Sambuc : (*(m)->ptr++ = (char) (ch))) 523*0a6a1f1dSLionel Sambuc 5244a17663cSThomas Veerman /* output.c */ 5254a17663cSThomas Veerman extern void output(void); 5264a17663cSThomas Veerman 5274a17663cSThomas Veerman /* reader.c */ 5284a17663cSThomas Veerman extern void reader(void); 5294a17663cSThomas Veerman 530*0a6a1f1dSLionel Sambuc /* skeleton.c (generated by skel2c) */ 5314a17663cSThomas Veerman extern void write_section(FILE * fp, const char *const section[]); 5324a17663cSThomas Veerman 533*0a6a1f1dSLionel Sambuc /* symtab.c */ 534*0a6a1f1dSLionel Sambuc extern bucket *make_bucket(const char *); 535*0a6a1f1dSLionel Sambuc extern bucket *lookup(const char *); 536*0a6a1f1dSLionel Sambuc extern void create_symbol_table(void); 537*0a6a1f1dSLionel Sambuc extern void free_symbol_table(void); 538*0a6a1f1dSLionel Sambuc extern void free_symbols(void); 539*0a6a1f1dSLionel Sambuc 5404a17663cSThomas Veerman /* verbose.c */ 5414a17663cSThomas Veerman extern void verbose(void); 5424a17663cSThomas Veerman 5434a17663cSThomas Veerman /* warshall.c */ 5444a17663cSThomas Veerman extern void reflexive_transitive_closure(unsigned *R, int n); 5454a17663cSThomas Veerman 546*0a6a1f1dSLionel Sambuc #ifdef DEBUG 547*0a6a1f1dSLionel Sambuc /* closure.c */ 548*0a6a1f1dSLionel Sambuc extern void print_closure(int n); 549*0a6a1f1dSLionel Sambuc extern void print_EFF(void); 550*0a6a1f1dSLionel Sambuc extern void print_first_derives(void); 551*0a6a1f1dSLionel Sambuc /* lr0.c */ 552*0a6a1f1dSLionel Sambuc extern void print_derives(void); 553*0a6a1f1dSLionel Sambuc #endif 554*0a6a1f1dSLionel Sambuc 5554a17663cSThomas Veerman #ifdef NO_LEAKS 5564a17663cSThomas Veerman extern void lr0_leaks(void); 5574a17663cSThomas Veerman extern void lalr_leaks(void); 5584a17663cSThomas Veerman extern void mkpar_leaks(void); 5594a17663cSThomas Veerman extern void output_leaks(void); 560*0a6a1f1dSLionel Sambuc extern void mstring_leaks(void); 5614a17663cSThomas Veerman extern void reader_leaks(void); 5624a17663cSThomas Veerman #endif 563