Module Name: src Committed By: christos Date: Mon Dec 30 19:08:55 UTC 2013
Modified Files: src/external/bsd/byacc/dist: defs.h main.c output.c reader.c skeleton.c Log Message: Add support for %token-table, yytname[] and YYTRANSLATE(). ntpd(8) needs them. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/external/bsd/byacc/dist/defs.h cvs rdiff -u -r1.8 -r1.9 src/external/bsd/byacc/dist/main.c \ src/external/bsd/byacc/dist/reader.c cvs rdiff -u -r1.9 -r1.10 src/external/bsd/byacc/dist/output.c cvs rdiff -u -r1.13 -r1.14 src/external/bsd/byacc/dist/skeleton.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/external/bsd/byacc/dist/defs.h diff -u src/external/bsd/byacc/dist/defs.h:1.6 src/external/bsd/byacc/dist/defs.h:1.7 --- src/external/bsd/byacc/dist/defs.h:1.6 Sat Apr 6 10:52:24 2013 +++ src/external/bsd/byacc/dist/defs.h Mon Dec 30 14:08:55 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: defs.h,v 1.6 2013/04/06 14:52:24 christos Exp $ */ +/* $NetBSD: defs.h,v 1.7 2013/12/30 19:08:55 christos Exp $ */ #if HAVE_NBTOOL_CONFIG_H #include "nbtool_config.h" @@ -109,6 +109,7 @@ #define PARSE_PARAM 13 #define LEX_PARAM 14 #define POSIX_YACC 15 +#define TOKEN_TABLE 16 /* symbol classes */ @@ -253,6 +254,7 @@ extern int lineno; extern int outline; extern int exit_code; extern int pure_parser; +extern int token_table; extern const char *const banner[]; extern const char *const xdecls[]; Index: src/external/bsd/byacc/dist/main.c diff -u src/external/bsd/byacc/dist/main.c:1.8 src/external/bsd/byacc/dist/main.c:1.9 --- src/external/bsd/byacc/dist/main.c:1.8 Sat Apr 6 10:52:24 2013 +++ src/external/bsd/byacc/dist/main.c Mon Dec 30 14:08:55 2013 @@ -1,9 +1,9 @@ -/* $NetBSD: main.c,v 1.8 2013/04/06 14:52:24 christos Exp $ */ +/* $NetBSD: main.c,v 1.9 2013/12/30 19:08:55 christos Exp $ */ #include "defs.h" #include <sys/cdefs.h> -__RCSID("$NetBSD: main.c,v 1.8 2013/04/06 14:52:24 christos Exp $"); +__RCSID("$NetBSD: main.c,v 1.9 2013/12/30 19:08:55 christos Exp $"); /* Id: main.c,v 1.40 2012/09/29 13:11:00 Adrian.Bunk Exp */ #include <signal.h> @@ -93,6 +93,7 @@ short *symbol_prec; char *symbol_assoc; int pure_parser; +int token_table; int exit_code; Value_t *ritem; Index: src/external/bsd/byacc/dist/reader.c diff -u src/external/bsd/byacc/dist/reader.c:1.8 src/external/bsd/byacc/dist/reader.c:1.9 --- src/external/bsd/byacc/dist/reader.c:1.8 Sat Apr 6 10:52:24 2013 +++ src/external/bsd/byacc/dist/reader.c Mon Dec 30 14:08:55 2013 @@ -1,11 +1,11 @@ -/* $NetBSD: reader.c,v 1.8 2013/04/06 14:52:24 christos Exp $ */ +/* $NetBSD: reader.c,v 1.9 2013/12/30 19:08:55 christos Exp $ */ /* Id: reader.c,v 1.36 2012/05/26 16:05:41 tom Exp */ #include "defs.h" #include <sys/cdefs.h> -__RCSID("$NetBSD: reader.c,v 1.8 2013/04/06 14:52:24 christos Exp $"); +__RCSID("$NetBSD: reader.c,v 1.9 2013/12/30 19:08:55 christos Exp $"); /* The line size must be a positive integer. One hundred was chosen */ /* because few lines in Yacc input grammars exceed 100 characters. */ @@ -322,6 +322,8 @@ keyword(void) return (PARSE_PARAM); if (matchec("lex-param")) return (LEX_PARAM); + if (matchec("token-table")) + return (TOKEN_TABLE); if (matchec("yacc")) return (POSIX_YACC); } @@ -1307,6 +1309,10 @@ read_declarations(void) copy_param(k); break; + case TOKEN_TABLE: + token_table = 1; + break; + case POSIX_YACC: /* noop for bison compatibility. byacc is already designed to be posix * yacc compatible. */ Index: src/external/bsd/byacc/dist/output.c diff -u src/external/bsd/byacc/dist/output.c:1.9 src/external/bsd/byacc/dist/output.c:1.10 --- src/external/bsd/byacc/dist/output.c:1.9 Sat Apr 6 10:52:24 2013 +++ src/external/bsd/byacc/dist/output.c Mon Dec 30 14:08:55 2013 @@ -1,11 +1,11 @@ -/* $NetBSD: output.c,v 1.9 2013/04/06 14:52:24 christos Exp $ */ +/* $NetBSD: output.c,v 1.10 2013/12/30 19:08:55 christos Exp $ */ /* Id: output.c,v 1.45 2013/03/05 00:29:17 tom Exp */ #include "defs.h" #include <sys/cdefs.h> -__RCSID("$NetBSD: output.c,v 1.9 2013/04/06 14:52:24 christos Exp $"); +__RCSID("$NetBSD: output.c,v 1.10 2013/12/30 19:08:55 christos Exp $"); #define StaticOrR (rflag ? "" : "static ") #define CountLine(fp) (!rflag || ((fp) == code_file)) @@ -116,7 +116,7 @@ output_prefix(FILE * fp) define_prefixed(fp, "yygindex"); define_prefixed(fp, "yytable"); define_prefixed(fp, "yycheck"); - define_prefixed(fp, "yyname"); + define_prefixed(fp, "yytname"); define_prefixed(fp, "yyrule"); } if (CountLine(fp)) @@ -926,23 +926,27 @@ output_debug(void) ++outline; fprintf(code_file, "#define YYMAXTOKEN %d\n", max); + fprintf(code_file, "#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? " + "(YYMAXTOKEN + 1) : (a))\n"); - symnam = TMALLOC(const char *, max + 1); + symnam = TMALLOC(const char *, max + 2); NO_SPACE(symnam); /* Note that it is not necessary to initialize the element */ /* symnam[max]. */ - for (i = 0; i < max; ++i) + for (i = 0; i <= max; ++i) symnam[i] = 0; for (i = ntokens - 1; i >= 2; --i) symnam[symbol_value[i]] = symbol_name[i]; symnam[0] = "end-of-file"; + symnam[max + 1] = "illegal-token"; - output_line("#if YYDEBUG"); + if (!token_table) + output_line("#if YYDEBUG"); - start_str_table("name"); + start_str_table("tname"); j = 80; - for (i = 0; i <= max; ++i) + for (i = 0; i <= max + 1; ++i) { if ((s = symnam[i]) != 0) { @@ -1063,6 +1067,8 @@ output_debug(void) end_table(); FREE(symnam); + if (token_table) + output_line("#if YYDEBUG"); start_str_table("rule"); for (i = 2; i < nrules; ++i) { Index: src/external/bsd/byacc/dist/skeleton.c diff -u src/external/bsd/byacc/dist/skeleton.c:1.13 src/external/bsd/byacc/dist/skeleton.c:1.14 --- src/external/bsd/byacc/dist/skeleton.c:1.13 Fri Sep 13 14:53:29 2013 +++ src/external/bsd/byacc/dist/skeleton.c Mon Dec 30 14:08:55 2013 @@ -1,11 +1,11 @@ -/* $NetBSD: skeleton.c,v 1.13 2013/09/13 18:53:29 joerg Exp $ */ +/* $NetBSD: skeleton.c,v 1.14 2013/12/30 19:08:55 christos Exp $ */ /* Id: skeleton.c,v 1.32 2013/03/04 23:19:39 tom Exp */ #include "defs.h" #include <sys/cdefs.h> -__RCSID("$NetBSD: skeleton.c,v 1.13 2013/09/13 18:53:29 joerg Exp $"); +__RCSID("$NetBSD: skeleton.c,v 1.14 2013/12/30 19:08:55 christos Exp $"); /* The definition of yysccsid in the banner should be replaced with */ /* a #pragma ident directive if the target C compiler supports */ @@ -73,7 +73,7 @@ const char *const tables[] = "extern short yycheck[];", "", "#if YYDEBUG", - "extern char *yyname[];", + "extern char *yytname[];", "extern char *yyrule[];", "#endif", 0 @@ -249,9 +249,7 @@ const char *const body_2[] = "#if YYDEBUG", " if (yydebug)", " {", - " yys = 0;", - " if (yychar <= YYMAXTOKEN) yys = yyname[yychar];", - " if (!yys) yys = \"illegal-symbol\";", + " yys = yytname[YYTRANSLATE(yychar)];", " printf(\"%sdebug: state %d, reading %d (%s)\\n\",", " YYPREFIX, yystate, yychar, yys);", " }", @@ -338,9 +336,7 @@ const char *const body_3[] = "#if YYDEBUG", " if (yydebug)", " {", - " yys = 0;", - " if (yychar <= YYMAXTOKEN) yys = yyname[yychar];", - " if (!yys) yys = \"illegal-symbol\";", + " yys = yytname[YYTRANSLATE(yychar)];", " printf(\"%sdebug: state %d, error recovery discards token %d\ (%s)\\n\",", " YYPREFIX, yystate, yychar, yys);", @@ -389,9 +385,7 @@ const char *const trailer[] = "#if YYDEBUG", " if (yydebug)", " {", - " yys = 0;", - " if (yychar <= YYMAXTOKEN) yys = yyname[yychar];", - " if (!yys) yys = \"illegal-symbol\";", + " yys = yytname[YYTRANSLATE(yychar)];", " printf(\"%sdebug: state %d, reading %d (%s)\\n\",", " YYPREFIX, YYFINAL, yychar, yys);", " }",