diff options
author | bapt <bapt@FreeBSD.org> | 2014-07-20 00:21:38 +0000 |
---|---|---|
committer | bapt <bapt@FreeBSD.org> | 2014-07-20 00:21:38 +0000 |
commit | 73fb3c280598036462af67b72879afe5bb731dc1 (patch) | |
tree | 1314cbb2d3f2de38cae32eefb37ba87c8f4e4a4e /contrib/byacc/defs.h | |
parent | 6f718e3669e9ecc1b1ca407a465d6ee20571a2b8 (diff) | |
download | FreeBSD-src-73fb3c280598036462af67b72879afe5bb731dc1.zip FreeBSD-src-73fb3c280598036462af67b72879afe5bb731dc1.tar.gz |
MFC: r257315, r260445, r264803
Update byacc to 20140422
Diffstat (limited to 'contrib/byacc/defs.h')
-rw-r--r-- | contrib/byacc/defs.h | 152 |
1 files changed, 121 insertions, 31 deletions
diff --git a/contrib/byacc/defs.h b/contrib/byacc/defs.h index 4d1a407..58ebc8d 100644 --- a/contrib/byacc/defs.h +++ b/contrib/byacc/defs.h @@ -1,9 +1,10 @@ -/* $Id: defs.h,v 1.37 2012/05/26 15:23:00 tom Exp $ */ +/* $Id: defs.h,v 1.49 2014/04/22 23:34:34 tom Exp $ */ #ifdef HAVE_CONFIG_H #include <config.h> #endif +#include <limits.h> #include <stdlib.h> #include <string.h> #include <errno.h> @@ -30,14 +31,14 @@ #define VERSION VSTRING(YYMAJOR, YYMINOR) -/* machine-dependent definitions */ -/* the following definitions are for the Tahoe */ -/* they might have to be changed for other machines */ +/* machine-dependent definitions: */ /* MAXCHAR is the largest unsigned character value */ -/* MAXSHORT is the largest value of a C short */ -/* MINSHORT is the most negative value of a C short */ /* MAXTABLE is the maximum table size */ +/* YYINT is the smallest C integer type that can be */ +/* used to address a table of size MAXTABLE */ +/* MAXYYINT is the largest value of a YYINT */ +/* MINYYINT is the most negative value of a YYINT */ /* BITS_PER_WORD is the number of bits in a C unsigned */ /* WORDSIZE computes the number of words needed to */ /* store n bits */ @@ -45,14 +46,26 @@ /* from r (0-indexed) */ /* SETBIT sets the n-th bit starting from r */ -#define MAXCHAR 255 -#define MAXSHORT 32767 -#define MINSHORT -32768 +#define MAXCHAR UCHAR_MAX +#ifndef MAXTABLE #define MAXTABLE 32500 -#define BITS_PER_WORD 32 -#define WORDSIZE(n) (((n)+(BITS_PER_WORD-1))/BITS_PER_WORD) -#define BIT(r, n) ((((r)[(n)>>5])>>((n)&31))&1) -#define SETBIT(r, n) ((r)[(n)>>5]|=((unsigned)1<<((n)&31))) +#endif +#if MAXTABLE <= SHRT_MAX +#define YYINT short +#define MAXYYINT SHRT_MAX +#define MINYYINT SHRT_MIN +#elif MAXTABLE <= INT_MAX +#define YYINT int +#define MAXYYINT INT_MAX +#define MINYYINT INT_MIN +#else +#error "MAXTABLE is too large for this machine architecture!" +#endif + +#define BITS_PER_WORD ((int) sizeof (unsigned) * CHAR_BIT) +#define WORDSIZE(n) (((n)+(BITS_PER_WORD-1))/BITS_PER_WORD) +#define BIT(r, n) ((((r)[(n)/BITS_PER_WORD])>>((n)&(BITS_PER_WORD-1)))&1) +#define SETBIT(r, n) ((r)[(n)/BITS_PER_WORD]|=((unsigned)1<<((n)&(BITS_PER_WORD-1)))) /* character names */ @@ -104,12 +117,20 @@ #define PARSE_PARAM 13 #define LEX_PARAM 14 #define POSIX_YACC 15 +#define TOKEN_TABLE 16 + +#if defined(YYBTYACC) +#define LOCATIONS 17 +#define DESTRUCTOR 18 +#endif /* symbol classes */ #define UNKNOWN 0 #define TERM 1 #define NONTERM 2 +#define ACTION 3 +#define ARGUMENT 4 /* the undefined value */ @@ -149,10 +170,20 @@ /* messages */ #define PLURAL(n) ((n) > 1 ? "s" : "") +/* + * Features which depend indirectly on the btyacc configuration, but are not + * essential. + */ +#if defined(YYBTYACC) +#define USE_HEADER_GUARDS 1 +#else +#define USE_HEADER_GUARDS 0 +#endif + typedef char Assoc_t; typedef char Class_t; -typedef short Index_t; -typedef short Value_t; +typedef YYINT Index_t; +typedef YYINT Value_t; /* the structure of a symbol table entry */ @@ -163,6 +194,12 @@ struct bucket struct bucket *next; char *name; char *tag; +#if defined(YYBTYACC) + char **argnames; + char **argtags; + int args; + char *destructor; +#endif Value_t value; Index_t index; Value_t prec; @@ -248,6 +285,12 @@ extern int lineno; extern int outline; extern int exit_code; extern int pure_parser; +extern int token_table; +#if defined(YYBTYACC) +extern int locations; +extern int backtrack; +extern int destructor; +#endif extern const char *const banner[]; extern const char *const xdecls[]; @@ -259,9 +302,7 @@ extern const char *const hdr_vars[]; extern const char *const body_1[]; extern const char *const body_vars[]; extern const char *const body_2[]; -extern const char *const body_3[]; extern const char *const trailer[]; -extern const char *const trailer_2[]; extern char *code_file_name; extern char *input_file_name; @@ -279,11 +320,11 @@ extern FILE *union_file; extern FILE *verbose_file; extern FILE *graph_file; -extern int nitems; -extern int nrules; -extern int nsyms; -extern int ntokens; -extern int nvars; +extern Value_t nitems; +extern Value_t nrules; +extern Value_t nsyms; +extern Value_t ntokens; +extern Value_t nvars; extern int ntags; extern char unionized; @@ -296,6 +337,12 @@ extern Value_t *symbol_value; extern Value_t *symbol_prec; extern char *symbol_assoc; +#if defined(YYBTYACC) +extern Value_t *symbol_pval; +extern char **symbol_destructor; +extern char **symbol_type_tag; +#endif + extern Value_t *ritem; extern Value_t *rlhs; extern Value_t *rrhs; @@ -344,9 +391,6 @@ extern param *parse_param; /* global functions */ -extern bucket *lookup(const char *); -extern bucket *make_bucket(const char *); - #ifndef GCC_NORETURN #if defined(__dead2) #define GCC_NORETURN __dead2 @@ -365,13 +409,23 @@ extern bucket *make_bucket(const char *); #endif #endif +#ifndef GCC_PRINTFLIKE +#define GCC_PRINTFLIKE(fmt,var) /*nothing*/ +#endif + /* closure.c */ extern void closure(Value_t * nucleus, int n); extern void finalize_closure(void); extern void set_first_derives(void); /* error.c */ +extern void arg_number_disagree_warning(int a_lineno, char *a_name); +extern void arg_type_disagree_warning(int a_lineno, int i, char *a_name); +extern void at_error(int a_lineno, char *a_line, char *a_cptr) GCC_NORETURN; +extern void at_warning(int a_lineno, int i); +extern void bad_formals(void) GCC_NORETURN; extern void default_action_warning(void); +extern void destructor_redeclared_warning(int a_lineno, char *a_line, char *a_cptr); extern void dollar_error(int a_lineno, char *a_line, char *a_cptr) GCC_NORETURN; extern void dollar_warning(int a_lineno, int i); extern void fatal(const char *msg) GCC_NORETURN; @@ -387,6 +441,7 @@ extern void reprec_warning(char *s); extern void restarted_warning(void); extern void retyped_warning(char *s); extern void revalued_warning(char *s); +extern void start_requires_args(char *a_name); extern void syntax_error(int st_lineno, char *st_line, char *st_cptr) GCC_NORETURN; extern void terminal_lhs(int s_lineno) GCC_NORETURN; extern void terminal_start(char *s) GCC_NORETURN; @@ -394,25 +449,26 @@ extern void tokenized_start(char *s) GCC_NORETURN; extern void undefined_goal(char *s) GCC_NORETURN; extern void undefined_symbol_warning(char *s); extern void unexpected_EOF(void) GCC_NORETURN; +extern void unknown_arg_warning(int d_lineno, const char *dlr_opt, const char *d_arg, const char *d_line, const char *d_cptr); extern void unknown_rhs(int i) GCC_NORETURN; +extern void unsupported_flag_warning(const char *flag, const char *details); extern void unterminated_action(int a_lineno, char *a_line, char *a_cptr) GCC_NORETURN; extern void unterminated_comment(int c_lineno, char *c_line, char *c_cptr) GCC_NORETURN; extern void unterminated_string(int s_lineno, char *s_line, char *s_cptr) GCC_NORETURN; extern void unterminated_text(int t_lineno, char *t_line, char *t_cptr) GCC_NORETURN; extern void unterminated_union(int u_lineno, char *u_line, char *u_cptr) GCC_NORETURN; +extern void untyped_arg_warning(int a_lineno, const char *dlr_opt, const char *a_name); extern void untyped_lhs(void) GCC_NORETURN; extern void untyped_rhs(int i, char *s) GCC_NORETURN; extern void used_reserved(char *s) GCC_NORETURN; +extern void unterminated_arglist(int a_lineno, char *a_line, char *a_cptr) GCC_NORETURN; +extern void wrong_number_args_warning(const char *which, const char *a_name); +extern void wrong_type_for_arg_warning(int i, char *a_name); /* graph.c */ extern void graph(void); /* lalr.c */ -extern void create_symbol_table(void); -extern void free_symbol_table(void); -extern void free_symbols(void); - -/* lalr.c */ extern void lalr(void); /* lr0.c */ @@ -430,25 +486,59 @@ extern void done(int k) GCC_NORETURN; extern void free_parser(void); extern void make_parser(void); +/* mstring.c */ +struct mstring +{ + char *base, *ptr, *end; +}; + +extern void msprintf(struct mstring *, const char *, ...) GCC_PRINTFLIKE(2,3); +extern int mputchar(struct mstring *, int); +extern struct mstring *msnew(void); +extern char *msdone(struct mstring *); +extern int strnscmp(const char *, const char *); +extern unsigned int strnshash(const char *); + +#define mputc(m, ch) (((m)->ptr == (m)->end) \ + ? mputchar(m,ch) \ + : (*(m)->ptr++ = (char) (ch))) + /* output.c */ extern void output(void); /* reader.c */ extern void reader(void); -/* skeleton.c */ +/* skeleton.c (generated by skel2c) */ extern void write_section(FILE * fp, const char *const section[]); +/* symtab.c */ +extern bucket *make_bucket(const char *); +extern bucket *lookup(const char *); +extern void create_symbol_table(void); +extern void free_symbol_table(void); +extern void free_symbols(void); + /* verbose.c */ extern void verbose(void); /* warshall.c */ extern void reflexive_transitive_closure(unsigned *R, int n); +#ifdef DEBUG + /* closure.c */ +extern void print_closure(int n); +extern void print_EFF(void); +extern void print_first_derives(void); + /* lr0.c */ +extern void print_derives(void); +#endif + #ifdef NO_LEAKS extern void lr0_leaks(void); extern void lalr_leaks(void); extern void mkpar_leaks(void); extern void output_leaks(void); +extern void mstring_leaks(void); extern void reader_leaks(void); #endif |