1319349Sjkim/* $Id: defs.h,v 1.56 2017/02/02 00:44:38 tom Exp $ */ 2234949Sbapt 3234949Sbapt#ifdef HAVE_CONFIG_H 4234949Sbapt#include <config.h> 5234949Sbapt#endif 6234949Sbapt 7264803Sbapt#include <limits.h> 8234949Sbapt#include <stdlib.h> 9234949Sbapt#include <string.h> 10234949Sbapt#include <errno.h> 11234949Sbapt#include <assert.h> 12234949Sbapt#include <ctype.h> 13234949Sbapt#include <stdio.h> 14234949Sbapt 15240517Sbapt#if defined(__cplusplus) /* __cplusplus, etc. */ 16240517Sbapt#define class myClass 17240517Sbapt#endif 18240517Sbapt 19234949Sbapt#define YYMAJOR 1 20234949Sbapt#define YYMINOR 9 21234949Sbapt 22234949Sbapt#define CONCAT(first,second) first #second 23234949Sbapt#define CONCAT1(string,number) CONCAT(string, number) 24234949Sbapt#define CONCAT2(first,second) #first "." #second 25234949Sbapt 26234949Sbapt#ifdef YYPATCH 27234949Sbapt#define VSTRING(a,b) CONCAT2(a,b) CONCAT1(" ",YYPATCH) 28234949Sbapt#else 29234949Sbapt#define VSTRING(a,b) CONCAT2(a,b) 30234949Sbapt#endif 31234949Sbapt 32234949Sbapt#define VERSION VSTRING(YYMAJOR, YYMINOR) 33234949Sbapt 34264803Sbapt/* machine-dependent definitions: */ 35234949Sbapt 36234949Sbapt/* MAXCHAR is the largest unsigned character value */ 37234949Sbapt/* MAXTABLE is the maximum table size */ 38264803Sbapt/* YYINT is the smallest C integer type that can be */ 39264803Sbapt/* used to address a table of size MAXTABLE */ 40264803Sbapt/* MAXYYINT is the largest value of a YYINT */ 41264803Sbapt/* MINYYINT is the most negative value of a YYINT */ 42234949Sbapt/* BITS_PER_WORD is the number of bits in a C unsigned */ 43234949Sbapt/* WORDSIZE computes the number of words needed to */ 44234949Sbapt/* store n bits */ 45234949Sbapt/* BIT returns the value of the n-th bit starting */ 46234949Sbapt/* from r (0-indexed) */ 47234949Sbapt/* SETBIT sets the n-th bit starting from r */ 48234949Sbapt 49264803Sbapt#define MAXCHAR UCHAR_MAX 50264803Sbapt#ifndef MAXTABLE 51234949Sbapt#define MAXTABLE 32500 52264803Sbapt#endif 53264803Sbapt#if MAXTABLE <= SHRT_MAX 54264803Sbapt#define YYINT short 55264803Sbapt#define MAXYYINT SHRT_MAX 56264803Sbapt#define MINYYINT SHRT_MIN 57264803Sbapt#elif MAXTABLE <= INT_MAX 58264803Sbapt#define YYINT int 59264803Sbapt#define MAXYYINT INT_MAX 60264803Sbapt#define MINYYINT INT_MIN 61264803Sbapt#else 62264803Sbapt#error "MAXTABLE is too large for this machine architecture!" 63264803Sbapt#endif 64234949Sbapt 65264803Sbapt#define BITS_PER_WORD ((int) sizeof (unsigned) * CHAR_BIT) 66264803Sbapt#define WORDSIZE(n) (((n)+(BITS_PER_WORD-1))/BITS_PER_WORD) 67264803Sbapt#define BIT(r, n) ((((r)[(n)/BITS_PER_WORD])>>((n)&(BITS_PER_WORD-1)))&1) 68264803Sbapt#define SETBIT(r, n) ((r)[(n)/BITS_PER_WORD]|=((unsigned)1<<((n)&(BITS_PER_WORD-1)))) 69264803Sbapt 70234949Sbapt/* character names */ 71234949Sbapt 72234949Sbapt#define NUL '\0' /* the null character */ 73234949Sbapt#define NEWLINE '\n' /* line feed */ 74234949Sbapt#define SP ' ' /* space */ 75234949Sbapt#define BS '\b' /* backspace */ 76234949Sbapt#define HT '\t' /* horizontal tab */ 77234949Sbapt#define VT '\013' /* vertical tab */ 78234949Sbapt#define CR '\r' /* carriage return */ 79234949Sbapt#define FF '\f' /* form feed */ 80234949Sbapt#define QUOTE '\'' /* single quote */ 81234949Sbapt#define DOUBLE_QUOTE '\"' /* double quote */ 82234949Sbapt#define BACKSLASH '\\' /* backslash */ 83234949Sbapt 84234949Sbapt#define UCH(c) (unsigned char)(c) 85234949Sbapt 86234949Sbapt/* defines for constructing filenames */ 87234949Sbapt 88234949Sbapt#if defined(VMS) 89234949Sbapt#define CODE_SUFFIX "_code.c" 90234949Sbapt#define DEFINES_SUFFIX "_tab.h" 91234949Sbapt#define EXTERNS_SUFFIX "_tab.i" 92234949Sbapt#define OUTPUT_SUFFIX "_tab.c" 93234949Sbapt#else 94234949Sbapt#define CODE_SUFFIX ".code.c" 95234949Sbapt#define DEFINES_SUFFIX ".tab.h" 96234949Sbapt#define EXTERNS_SUFFIX ".tab.i" 97234949Sbapt#define OUTPUT_SUFFIX ".tab.c" 98234949Sbapt#endif 99234949Sbapt#define VERBOSE_SUFFIX ".output" 100234949Sbapt#define GRAPH_SUFFIX ".dot" 101234949Sbapt 102234949Sbapt/* keyword codes */ 103234949Sbapt 104234949Sbapt#define TOKEN 0 105234949Sbapt#define LEFT 1 106234949Sbapt#define RIGHT 2 107234949Sbapt#define NONASSOC 3 108234949Sbapt#define MARK 4 109234949Sbapt#define TEXT 5 110234949Sbapt#define TYPE 6 111234949Sbapt#define START 7 112234949Sbapt#define UNION 8 113234949Sbapt#define IDENT 9 114234949Sbapt#define EXPECT 10 115234949Sbapt#define EXPECT_RR 11 116234949Sbapt#define PURE_PARSER 12 117234949Sbapt#define PARSE_PARAM 13 118234949Sbapt#define LEX_PARAM 14 119234949Sbapt#define POSIX_YACC 15 120260445Sbapt#define TOKEN_TABLE 16 121319297Sdelphij#define ERROR_VERBOSE 17 122319297Sdelphij#define XXXDEBUG 18 123234949Sbapt 124264803Sbapt#if defined(YYBTYACC) 125319297Sdelphij#define LOCATIONS 19 126319297Sdelphij#define DESTRUCTOR 20 127319297Sdelphij#define INITIAL_ACTION 21 128264803Sbapt#endif 129264803Sbapt 130234949Sbapt/* symbol classes */ 131234949Sbapt 132234949Sbapt#define UNKNOWN 0 133234949Sbapt#define TERM 1 134234949Sbapt#define NONTERM 2 135264803Sbapt#define ACTION 3 136264803Sbapt#define ARGUMENT 4 137234949Sbapt 138234949Sbapt/* the undefined value */ 139234949Sbapt 140234949Sbapt#define UNDEFINED (-1) 141234949Sbapt 142234949Sbapt/* action codes */ 143234949Sbapt 144234949Sbapt#define SHIFT 1 145234949Sbapt#define REDUCE 2 146234949Sbapt 147234949Sbapt/* character macros */ 148234949Sbapt 149234949Sbapt#define IS_IDENT(c) (isalnum(c) || (c) == '_' || (c) == '.' || (c) == '$') 150234949Sbapt#define IS_OCTAL(c) ((c) >= '0' && (c) <= '7') 151234949Sbapt#define NUMERIC_VALUE(c) ((c) - '0') 152234949Sbapt 153234949Sbapt/* symbol macros */ 154234949Sbapt 155234949Sbapt#define ISTOKEN(s) ((s) < start_symbol) 156234949Sbapt#define ISVAR(s) ((s) >= start_symbol) 157234949Sbapt 158234949Sbapt/* storage allocation macros */ 159234949Sbapt 160234949Sbapt#define CALLOC(k,n) (calloc((size_t)(k),(size_t)(n))) 161234949Sbapt#define FREE(x) (free((char*)(x))) 162234949Sbapt#define MALLOC(n) (malloc((size_t)(n))) 163272649Srodrigc#define TCMALLOC(t,n) ((t*) calloc((size_t)(n), sizeof(t))) 164240517Sbapt#define TMALLOC(t,n) ((t*) malloc((size_t)(n) * sizeof(t))) 165234949Sbapt#define NEW(t) ((t*)allocate(sizeof(t))) 166234949Sbapt#define NEW2(n,t) ((t*)allocate(((size_t)(n)*sizeof(t)))) 167234949Sbapt#define REALLOC(p,n) (realloc((char*)(p),(size_t)(n))) 168240517Sbapt#define TREALLOC(t,p,n) ((t*)realloc((char*)(p), (size_t)(n) * sizeof(t))) 169234949Sbapt 170234949Sbapt#define DO_FREE(x) if (x) { FREE(x); x = 0; } 171234949Sbapt 172234949Sbapt#define NO_SPACE(p) if (p == 0) no_space(); assert(p != 0) 173234949Sbapt 174234949Sbapt/* messages */ 175234949Sbapt#define PLURAL(n) ((n) > 1 ? "s" : "") 176234949Sbapt 177264803Sbapt/* 178264803Sbapt * Features which depend indirectly on the btyacc configuration, but are not 179264803Sbapt * essential. 180264803Sbapt */ 181264803Sbapt#if defined(YYBTYACC) 182264803Sbapt#define USE_HEADER_GUARDS 1 183264803Sbapt#else 184264803Sbapt#define USE_HEADER_GUARDS 0 185264803Sbapt#endif 186264803Sbapt 187234949Sbapttypedef char Assoc_t; 188234949Sbapttypedef char Class_t; 189264803Sbapttypedef YYINT Index_t; 190264803Sbapttypedef YYINT Value_t; 191234949Sbapt 192234949Sbapt/* the structure of a symbol table entry */ 193234949Sbapt 194234949Sbapttypedef struct bucket bucket; 195234949Sbaptstruct bucket 196234949Sbapt{ 197234949Sbapt struct bucket *link; 198234949Sbapt struct bucket *next; 199234949Sbapt char *name; 200234949Sbapt char *tag; 201264803Sbapt#if defined(YYBTYACC) 202264803Sbapt char **argnames; 203264803Sbapt char **argtags; 204319297Sdelphij int args; 205264803Sbapt char *destructor; 206264803Sbapt#endif 207234949Sbapt Value_t value; 208234949Sbapt Index_t index; 209234949Sbapt Value_t prec; 210234949Sbapt Class_t class; 211234949Sbapt Assoc_t assoc; 212234949Sbapt}; 213234949Sbapt 214234949Sbapt/* the structure of the LR(0) state machine */ 215234949Sbapt 216234949Sbapttypedef struct core core; 217234949Sbaptstruct core 218234949Sbapt{ 219234949Sbapt struct core *next; 220234949Sbapt struct core *link; 221234949Sbapt Value_t number; 222234949Sbapt Value_t accessing_symbol; 223234949Sbapt Value_t nitems; 224234949Sbapt Value_t items[1]; 225234949Sbapt}; 226234949Sbapt 227234949Sbapt/* the structure used to record shifts */ 228234949Sbapt 229234949Sbapttypedef struct shifts shifts; 230234949Sbaptstruct shifts 231234949Sbapt{ 232234949Sbapt struct shifts *next; 233234949Sbapt Value_t number; 234234949Sbapt Value_t nshifts; 235234949Sbapt Value_t shift[1]; 236234949Sbapt}; 237234949Sbapt 238234949Sbapt/* the structure used to store reductions */ 239234949Sbapt 240234949Sbapttypedef struct reductions reductions; 241234949Sbaptstruct reductions 242234949Sbapt{ 243234949Sbapt struct reductions *next; 244234949Sbapt Value_t number; 245234949Sbapt Value_t nreds; 246234949Sbapt Value_t rules[1]; 247234949Sbapt}; 248234949Sbapt 249234949Sbapt/* the structure used to represent parser actions */ 250234949Sbapt 251234949Sbapttypedef struct action action; 252234949Sbaptstruct action 253234949Sbapt{ 254234949Sbapt struct action *next; 255234949Sbapt Value_t symbol; 256234949Sbapt Value_t number; 257234949Sbapt Value_t prec; 258234949Sbapt char action_code; 259234949Sbapt Assoc_t assoc; 260234949Sbapt char suppressed; 261234949Sbapt}; 262234949Sbapt 263234949Sbapt/* the structure used to store parse/lex parameters */ 264234949Sbapttypedef struct param param; 265234949Sbaptstruct param 266234949Sbapt{ 267234949Sbapt struct param *next; 268234949Sbapt char *name; /* parameter name */ 269234949Sbapt char *type; /* everything before parameter name */ 270234949Sbapt char *type2; /* everything after parameter name */ 271234949Sbapt}; 272234949Sbapt 273234949Sbapt/* global variables */ 274234949Sbapt 275234949Sbaptextern char dflag; 276234949Sbaptextern char gflag; 277234949Sbaptextern char iflag; 278234949Sbaptextern char lflag; 279234949Sbaptextern char rflag; 280234949Sbaptextern char sflag; 281234949Sbaptextern char tflag; 282234949Sbaptextern char vflag; 283234949Sbaptextern const char *symbol_prefix; 284234949Sbapt 285234949Sbaptextern const char *myname; 286234949Sbaptextern char *cptr; 287234949Sbaptextern char *line; 288234949Sbaptextern int lineno; 289234949Sbaptextern int outline; 290234949Sbaptextern int exit_code; 291240517Sbaptextern int pure_parser; 292260445Sbaptextern int token_table; 293319297Sdelphijextern int error_verbose; 294264803Sbapt#if defined(YYBTYACC) 295264803Sbaptextern int locations; 296264803Sbaptextern int backtrack; 297264803Sbaptextern int destructor; 298319297Sdelphijextern char *initial_action; 299264803Sbapt#endif 300234949Sbapt 301234949Sbaptextern const char *const banner[]; 302234949Sbaptextern const char *const xdecls[]; 303234949Sbaptextern const char *const tables[]; 304234949Sbaptextern const char *const global_vars[]; 305234949Sbaptextern const char *const impure_vars[]; 306234949Sbaptextern const char *const hdr_defs[]; 307234949Sbaptextern const char *const hdr_vars[]; 308234949Sbaptextern const char *const body_1[]; 309234949Sbaptextern const char *const body_vars[]; 310234949Sbaptextern const char *const body_2[]; 311319297Sdelphijextern const char *const body_3[]; 312234949Sbaptextern const char *const trailer[]; 313234949Sbapt 314234949Sbaptextern char *code_file_name; 315234949Sbaptextern char *input_file_name; 316319349Sjkimextern size_t input_file_name_len; 317234949Sbaptextern char *defines_file_name; 318234949Sbaptextern char *externs_file_name; 319234949Sbapt 320234949Sbaptextern FILE *action_file; 321234949Sbaptextern FILE *code_file; 322234949Sbaptextern FILE *defines_file; 323234949Sbaptextern FILE *externs_file; 324234949Sbaptextern FILE *input_file; 325234949Sbaptextern FILE *output_file; 326234949Sbaptextern FILE *text_file; 327234949Sbaptextern FILE *union_file; 328234949Sbaptextern FILE *verbose_file; 329234949Sbaptextern FILE *graph_file; 330234949Sbapt 331264803Sbaptextern Value_t nitems; 332264803Sbaptextern Value_t nrules; 333264803Sbaptextern Value_t nsyms; 334264803Sbaptextern Value_t ntokens; 335264803Sbaptextern Value_t nvars; 336234949Sbaptextern int ntags; 337234949Sbapt 338234949Sbaptextern char unionized; 339234949Sbaptextern char line_format[]; 340234949Sbapt 341234949Sbaptextern Value_t start_symbol; 342234949Sbaptextern char **symbol_name; 343234949Sbaptextern char **symbol_pname; 344234949Sbaptextern Value_t *symbol_value; 345234949Sbaptextern Value_t *symbol_prec; 346234949Sbaptextern char *symbol_assoc; 347234949Sbapt 348264803Sbapt#if defined(YYBTYACC) 349264803Sbaptextern Value_t *symbol_pval; 350264803Sbaptextern char **symbol_destructor; 351264803Sbaptextern char **symbol_type_tag; 352264803Sbapt#endif 353264803Sbapt 354234949Sbaptextern Value_t *ritem; 355234949Sbaptextern Value_t *rlhs; 356234949Sbaptextern Value_t *rrhs; 357234949Sbaptextern Value_t *rprec; 358234949Sbaptextern Assoc_t *rassoc; 359234949Sbapt 360234949Sbaptextern Value_t **derives; 361234949Sbaptextern char *nullable; 362234949Sbapt 363234949Sbaptextern bucket *first_symbol; 364234949Sbaptextern bucket *last_symbol; 365234949Sbapt 366234949Sbaptextern int nstates; 367234949Sbaptextern core *first_state; 368234949Sbaptextern shifts *first_shift; 369234949Sbaptextern reductions *first_reduction; 370234949Sbaptextern Value_t *accessing_symbol; 371234949Sbaptextern core **state_table; 372234949Sbaptextern shifts **shift_table; 373234949Sbaptextern reductions **reduction_table; 374234949Sbaptextern unsigned *LA; 375234949Sbaptextern Value_t *LAruleno; 376234949Sbaptextern Value_t *lookaheads; 377272655Sbaptextern Value_t *goto_base; 378234949Sbaptextern Value_t *goto_map; 379234949Sbaptextern Value_t *from_state; 380234949Sbaptextern Value_t *to_state; 381234949Sbapt 382234949Sbaptextern action **parser; 383234949Sbaptextern int SRexpect; 384234949Sbaptextern int RRexpect; 385234949Sbaptextern int SRtotal; 386234949Sbaptextern int RRtotal; 387234949Sbaptextern Value_t *SRconflicts; 388234949Sbaptextern Value_t *RRconflicts; 389234949Sbaptextern Value_t *defred; 390234949Sbaptextern Value_t *rules_used; 391234949Sbaptextern Value_t nunused; 392234949Sbaptextern Value_t final_state; 393234949Sbapt 394234949Sbaptextern Value_t *itemset; 395234949Sbaptextern Value_t *itemsetend; 396234949Sbaptextern unsigned *ruleset; 397234949Sbapt 398234949Sbaptextern param *lex_param; 399234949Sbaptextern param *parse_param; 400234949Sbapt 401234949Sbapt/* global functions */ 402234949Sbapt 403234949Sbapt#ifndef GCC_NORETURN 404240517Sbapt#if defined(__dead2) 405240517Sbapt#define GCC_NORETURN __dead2 406240517Sbapt#elif defined(__dead) 407240517Sbapt#define GCC_NORETURN __dead 408240517Sbapt#else 409234949Sbapt#define GCC_NORETURN /* nothing */ 410234949Sbapt#endif 411240517Sbapt#endif 412234949Sbapt 413234949Sbapt#ifndef GCC_UNUSED 414240517Sbapt#if defined(__unused) 415240517Sbapt#define GCC_UNUSED __unused 416240517Sbapt#else 417234949Sbapt#define GCC_UNUSED /* nothing */ 418234949Sbapt#endif 419240517Sbapt#endif 420234949Sbapt 421266639Sbapt#ifndef GCC_PRINTFLIKE 422319297Sdelphij#define GCC_PRINTFLIKE(fmt,var) /*nothing */ 423266639Sbapt#endif 424266639Sbapt 425234949Sbapt/* closure.c */ 426319297Sdelphijextern void closure(Value_t *nucleus, int n); 427234949Sbaptextern void finalize_closure(void); 428234949Sbaptextern void set_first_derives(void); 429234949Sbapt 430234949Sbapt/* error.c */ 431319297Sdelphijstruct ainfo 432319297Sdelphij{ 433319297Sdelphij int a_lineno; 434319297Sdelphij char *a_line; 435319297Sdelphij char *a_cptr; 436319297Sdelphij}; 437319297Sdelphij 438264803Sbaptextern void arg_number_disagree_warning(int a_lineno, char *a_name); 439264803Sbaptextern void arg_type_disagree_warning(int a_lineno, int i, char *a_name); 440264803Sbaptextern void at_error(int a_lineno, char *a_line, char *a_cptr) GCC_NORETURN; 441264803Sbaptextern void at_warning(int a_lineno, int i); 442264803Sbaptextern void bad_formals(void) GCC_NORETURN; 443319297Sdelphijextern void default_action_warning(char *s); 444319297Sdelphijextern void destructor_redeclared_warning(const struct ainfo *); 445234949Sbaptextern void dollar_error(int a_lineno, char *a_line, char *a_cptr) GCC_NORETURN; 446234949Sbaptextern void dollar_warning(int a_lineno, int i); 447234949Sbaptextern void fatal(const char *msg) GCC_NORETURN; 448234949Sbaptextern void illegal_character(char *c_cptr) GCC_NORETURN; 449234949Sbaptextern void illegal_tag(int t_lineno, char *t_line, char *t_cptr) GCC_NORETURN; 450234949Sbaptextern void missing_brace(void) GCC_NORETURN; 451234949Sbaptextern void no_grammar(void) GCC_NORETURN; 452234949Sbaptextern void no_space(void) GCC_NORETURN; 453234949Sbaptextern void open_error(const char *filename) GCC_NORETURN; 454234949Sbaptextern void over_unionized(char *u_cptr) GCC_NORETURN; 455234949Sbaptextern void prec_redeclared(void); 456234949Sbaptextern void reprec_warning(char *s); 457234949Sbaptextern void restarted_warning(void); 458234949Sbaptextern void retyped_warning(char *s); 459234949Sbaptextern void revalued_warning(char *s); 460264803Sbaptextern void start_requires_args(char *a_name); 461234949Sbaptextern void syntax_error(int st_lineno, char *st_line, char *st_cptr) GCC_NORETURN; 462234949Sbaptextern void terminal_lhs(int s_lineno) GCC_NORETURN; 463234949Sbaptextern void terminal_start(char *s) GCC_NORETURN; 464234949Sbaptextern void tokenized_start(char *s) GCC_NORETURN; 465234949Sbaptextern void undefined_goal(char *s) GCC_NORETURN; 466234949Sbaptextern void undefined_symbol_warning(char *s); 467234949Sbaptextern void unexpected_EOF(void) GCC_NORETURN; 468264803Sbaptextern void unknown_arg_warning(int d_lineno, const char *dlr_opt, const char *d_arg, const char *d_line, const char *d_cptr); 469234949Sbaptextern void unknown_rhs(int i) GCC_NORETURN; 470264803Sbaptextern void unsupported_flag_warning(const char *flag, const char *details); 471319297Sdelphijextern void unterminated_action(const struct ainfo *) GCC_NORETURN; 472319297Sdelphijextern void unterminated_comment(const struct ainfo *) GCC_NORETURN; 473319297Sdelphijextern void unterminated_string(const struct ainfo *) GCC_NORETURN; 474319297Sdelphijextern void unterminated_text(const struct ainfo *) GCC_NORETURN; 475319297Sdelphijextern void unterminated_union(const struct ainfo *) GCC_NORETURN; 476264803Sbaptextern void untyped_arg_warning(int a_lineno, const char *dlr_opt, const char *a_name); 477234949Sbaptextern void untyped_lhs(void) GCC_NORETURN; 478234949Sbaptextern void untyped_rhs(int i, char *s) GCC_NORETURN; 479234949Sbaptextern void used_reserved(char *s) GCC_NORETURN; 480319297Sdelphijextern void unterminated_arglist(const struct ainfo *) GCC_NORETURN; 481264803Sbaptextern void wrong_number_args_warning(const char *which, const char *a_name); 482264803Sbaptextern void wrong_type_for_arg_warning(int i, char *a_name); 483234949Sbapt 484234949Sbapt/* graph.c */ 485234949Sbaptextern void graph(void); 486234949Sbapt 487234949Sbapt/* lalr.c */ 488234949Sbaptextern void lalr(void); 489234949Sbapt 490234949Sbapt/* lr0.c */ 491234949Sbaptextern void lr0(void); 492234949Sbaptextern void show_cores(void); 493234949Sbaptextern void show_ritems(void); 494234949Sbaptextern void show_rrhs(void); 495234949Sbaptextern void show_shifts(void); 496234949Sbapt 497234949Sbapt/* main.c */ 498234949Sbaptextern void *allocate(size_t n); 499234949Sbaptextern void done(int k) GCC_NORETURN; 500234949Sbapt 501234949Sbapt/* mkpar.c */ 502234949Sbaptextern void free_parser(void); 503234949Sbaptextern void make_parser(void); 504234949Sbapt 505264803Sbapt/* mstring.c */ 506264803Sbaptstruct mstring 507264803Sbapt{ 508264803Sbapt char *base, *ptr, *end; 509264803Sbapt}; 510264803Sbapt 511266639Sbaptextern void msprintf(struct mstring *, const char *, ...) GCC_PRINTFLIKE(2,3); 512264803Sbaptextern int mputchar(struct mstring *, int); 513264803Sbaptextern struct mstring *msnew(void); 514264803Sbaptextern char *msdone(struct mstring *); 515264803Sbaptextern int strnscmp(const char *, const char *); 516264803Sbaptextern unsigned int strnshash(const char *); 517264803Sbapt 518264803Sbapt#define mputc(m, ch) (((m)->ptr == (m)->end) \ 519264803Sbapt ? mputchar(m,ch) \ 520264803Sbapt : (*(m)->ptr++ = (char) (ch))) 521264803Sbapt 522234949Sbapt/* output.c */ 523234949Sbaptextern void output(void); 524234949Sbapt 525234949Sbapt/* reader.c */ 526234949Sbaptextern void reader(void); 527234949Sbapt 528264803Sbapt/* skeleton.c (generated by skel2c) */ 529240517Sbaptextern void write_section(FILE * fp, const char *const section[]); 530234949Sbapt 531264803Sbapt/* symtab.c */ 532264803Sbaptextern bucket *make_bucket(const char *); 533264803Sbaptextern bucket *lookup(const char *); 534264803Sbaptextern void create_symbol_table(void); 535264803Sbaptextern void free_symbol_table(void); 536264803Sbaptextern void free_symbols(void); 537264803Sbapt 538234949Sbapt/* verbose.c */ 539234949Sbaptextern void verbose(void); 540234949Sbapt 541234949Sbapt/* warshall.c */ 542234949Sbaptextern void reflexive_transitive_closure(unsigned *R, int n); 543234949Sbapt 544264803Sbapt#ifdef DEBUG 545264803Sbapt /* closure.c */ 546264803Sbaptextern void print_closure(int n); 547264803Sbaptextern void print_EFF(void); 548264803Sbaptextern void print_first_derives(void); 549264803Sbapt /* lr0.c */ 550264803Sbaptextern void print_derives(void); 551264803Sbapt#endif 552264803Sbapt 553234949Sbapt#ifdef NO_LEAKS 554234949Sbaptextern void lr0_leaks(void); 555234949Sbaptextern void lalr_leaks(void); 556234949Sbaptextern void mkpar_leaks(void); 557234949Sbaptextern void output_leaks(void); 558266639Sbaptextern void mstring_leaks(void); 559234949Sbaptextern void reader_leaks(void); 560234949Sbapt#endif 561