Imported Upstream version 20101126 upstream/20101126
authorDongHun Kwak <dh0128.kwak@samsung.com>
Fri, 1 Oct 2021 05:46:31 +0000 (14:46 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Fri, 1 Oct 2021 05:46:31 +0000 (14:46 +0900)
24 files changed:
CHANGES
VERSION
defs.h
output.c
package/byacc.spec
package/debian/changelog
reader.c
skeleton.c
test/calc.tab.c
test/calc1.tab.c
test/calc1.tab.h
test/calc1.y
test/calc2.tab.c
test/calc2.y
test/calc3.tab.c
test/calc3.y
test/code_calc.code.c
test/code_error.code.c
test/error.tab.c
test/ftp.tab.c
test/grammar.tab.c
test/pure_calc.tab.c
test/pure_error.tab.c
yacc.1

diff --git a/CHANGES b/CHANGES
index aa6a185..340b7fe 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,52 @@
+2010-11-26  Thomas Dickey  <tom@crayon>
+
+       * skeleton.c: typo
+
+       * output.c:
+       correct line-numbering when "-r" option is used; the 'outline' variable
+       should only be incremented when writing to the code-file.
+
+       * test/code_calc.code.c, test/code_error.code.c: regen
+
+       * yacc.1: bump date
+
+       * yacc.1: comment on -b option vs -r
+
+       * test/calc2.tab.c, test/calc2.y, test/calc3.tab.c, test/calc3.y, test/ftp.tab.c, test/grammar.tab.c, test/pure_calc.tab.c, test/pure_error.tab.c, test/calc.tab.c, test/calc1.tab.c, test/code_calc.code.c, test/code_error.code.c, test/error.tab.c:
+       regen
+
+       * output.c:
+       improve on YYERROR_DECL(), adding dummy params which can be used for the
+       actual function declaration.  Also add YYERROR_CALL().  The two macros
+       simplify maintaining sets of grammars which may/may not be pure.
+
+       * test/calc1.y, test/ftp.tab.c, test/grammar.tab.c, test/pure_calc.tab.c, test/pure_error.tab.c, test/calc.tab.c, test/calc1.tab.c, test/calc2.tab.c, test/calc3.tab.c, test/code_calc.code.c, test/code_error.code.c, test/error.tab.c:
+       regen
+
+       * output.c: generate yyerror() calls in output.c
+       This is for compatibility with bison, which passes the yylval to yyerror
+       when the %parse-param feature is used.
+
+       * skeleton.c, defs.h: generate yyerror() calls in output.c
+
+       * output.c: simplified a little, using putc_code() and putl_code()
+
+       * test/calc1.tab.h: regen
+
+       * reader.c:
+       improve ifdef for YYSTYPE union declaration (report by Clifford Yapp)
+
+       * reader.c:
+       accept underscore as a replacement for dash in command names, e.g.,
+       "%pure_parser" vs "%pure-parser".
+
+       * test/calc1.tab.c: regen
+
+       * output.c, reader.c:
+       also ifdef YYSTYPE declaration in the generated code (report by Clifford Yapp)
+
+       * package/debian/changelog, package/byacc.spec, VERSION: bump
+
 2010-11-24  Thomas Dickey  <tom@crayon>
 
        * main.c, defs.h, symtab.c, error.c: reduce global variables
diff --git a/VERSION b/VERSION
index c3033a0..60c6408 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-20101124
+20101126
diff --git a/defs.h b/defs.h
index 613fbf8..d9c5a8d 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -1,4 +1,4 @@
-/* $Id: defs.h,v 1.29 2010/11/24 15:13:25 tom Exp $ */
+/* $Id: defs.h,v 1.30 2010/11/26 15:19:36 tom Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
@@ -247,7 +247,9 @@ extern const char *hdr_vars[];
 extern const char *body_1[];
 extern const char *body_vars[];
 extern const char *body_2[];
+extern const char *body_3[];
 extern const char *trailer[];
+extern const char *trailer_2[];
 
 extern char *code_file_name;
 extern char *input_file_name;
index 4495917..1d4f771 100644 (file)
--- a/output.c
+++ b/output.c
@@ -1,8 +1,9 @@
-/* $Id: output.c,v 1.31 2010/11/23 01:45:45 tom Exp $ */
+/* $Id: output.c,v 1.36 2010/11/26 16:47:40 tom Exp $ */
 
 #include "defs.h"
 
 #define StaticOrR      (rflag ? "" : "static ")
+#define CountLine(fp)   (!rflag || ((fp) == code_file))
 
 static int nvectors;
 static int nentries;
@@ -21,43 +22,64 @@ static int lowzero;
 static int high;
 
 static void
-write_char(FILE * out, int c)
+putc_code(int c)
 {
     if (c == '\n')
        ++outline;
-    putc(c, out);
+    putc(c, code_file);
 }
 
 static void
-write_code_lineno(FILE * out)
+putl_code(const char *s)
+{
+    ++outline;
+    fputs(s, code_file);
+}
+
+static void
+puts_code(const char *s)
+{
+    fputs(s, code_file);
+}
+
+static void
+write_code_lineno(void)
 {
     if (!lflag)
-       fprintf(out, line_format, (outline++) + 1, code_file_name);
+    {
+       ++outline;
+       fprintf(code_file, line_format, outline, code_file_name);
+    }
 }
 
 static void
-write_input_lineno(FILE * out)
+write_input_lineno(void)
 {
     if (!lflag)
     {
        ++outline;
-       fprintf(out, line_format, lineno, input_file_name);
+       fprintf(code_file, line_format, lineno, input_file_name);
     }
 }
 
 static void
 define_prefixed(FILE * fp, const char *name)
 {
-    ++outline;
+    int bump_line = CountLine(fp);
+    if (bump_line)
+       ++outline;
     fprintf(fp, "\n");
 
-    ++outline;
+    if (bump_line)
+       ++outline;
     fprintf(fp, "#ifndef %s\n", name);
 
-    ++outline;
+    if (bump_line)
+       ++outline;
     fprintf(fp, "#define %-10s %s%s\n", name, symbol_prefix, name + 2);
 
-    ++outline;
+    if (bump_line)
+       ++outline;
     fprintf(fp, "#endif /* %s */\n", name);
 }
 
@@ -91,7 +113,8 @@ output_prefix(FILE * fp)
        define_prefixed(fp, "yyname");
        define_prefixed(fp, "yyrule");
     }
-    ++outline;
+    if (CountLine(fp))
+       ++outline;
     fprintf(fp, "#define YYPREFIX \"%s\"\n", symbol_prefix);
 }
 
@@ -805,7 +828,7 @@ output_defines(void)
        s = symbol_name[i];
        if (is_C_identifier(s))
        {
-           fprintf(code_file, "#define ");
+           puts_code("#define ");
            if (dflag)
                fprintf(defines_file, "#define ");
            c = *s;
@@ -841,12 +864,8 @@ output_defines(void)
     if (dflag && unionized)
     {
        rewind(union_file);
-       fprintf(defines_file,
-               "#if !(defined(YYSTYPE) || defined(YYSTYPE_IS_DECLARED))\n");
        while ((c = getc(union_file)) != EOF)
            putc(c, defines_file);
-       fprintf(defines_file,
-               "#endif /* !(YYSTYPE || YYSTYPE_IS_DECLARED) */\n");
        fprintf(defines_file, "extern YYSTYPE %slval;\n",
                symbol_prefix);
     }
@@ -856,7 +875,7 @@ static void
 output_stored_text(void)
 {
     int c;
-    FILE *in, *out;
+    FILE *in;
 
     rewind(text_file);
     if (text_file == NULL)
@@ -864,13 +883,12 @@ output_stored_text(void)
     in = text_file;
     if ((c = getc(in)) == EOF)
        return;
-    out = code_file;
-    write_char(out, c);
+    putc_code(c);
     while ((c = getc(in)) != EOF)
     {
-       write_char(out, c);
+       putc_code(c);
     }
-    write_code_lineno(out);
+    write_code_lineno();
 }
 
 static void
@@ -883,8 +901,10 @@ output_debug(void)
     ++outline;
     fprintf(code_file, "#define YYFINAL %d\n", final_state);
 
-    outline += 3;
-    fprintf(code_file, "#ifndef YYDEBUG\n#define YYDEBUG %d\n#endif\n", tflag);
+    putl_code("#ifndef YYDEBUG\n");
+    ++outline;
+    fprintf(code_file, "#define YYDEBUG %d\n", tflag);
+    putl_code("#endif\n");
 
     if (rflag)
     {
@@ -1094,8 +1114,12 @@ output_debug(void)
 static void
 output_pure_parser(void)
 {
-    outline += 3;
-    fprintf(code_file, "\n#define YYPURE %d\n\n", pure_parser);
+    putc_code('\n');
+
+    outline += 1;
+    fprintf(code_file, "#define YYPURE %d\n", pure_parser);
+
+    putc_code('\n');
 }
 
 static void
@@ -1103,9 +1127,11 @@ output_stype(void)
 {
     if (!unionized && ntags == 0)
     {
-       outline += 5;
-       fprintf(code_file,
-               "\n#ifndef YYSTYPE\ntypedef int YYSTYPE;\n#endif\n\n");
+       putc_code('\n');
+       putl_code("#ifndef YYSTYPE\n");
+       putl_code("typedef int YYSTYPE;\n");
+       putl_code("#endif\n");
+       putc_code('\n');
     }
 }
 
@@ -1113,102 +1139,88 @@ static void
 output_trailing_text(void)
 {
     int c, last;
-    FILE *in, *out;
+    FILE *in;
 
     if (line == 0)
        return;
 
     in = input_file;
-    out = code_file;
     c = *cptr;
     if (c == '\n')
     {
        ++lineno;
        if ((c = getc(in)) == EOF)
            return;
-       write_input_lineno(out);
-       write_char(out, c);
+       write_input_lineno();
+       putc_code(c);
        last = c;
     }
     else
     {
-       write_input_lineno(out);
+       write_input_lineno();
        do
        {
-           putc(c, out);
+           putc_code(c);
        }
        while ((c = *++cptr) != '\n');
-       write_char(out, c);
+       putc_code(c);
        last = '\n';
     }
 
     while ((c = getc(in)) != EOF)
     {
-       write_char(out, c);
+       putc_code(c);
        last = c;
     }
 
     if (last != '\n')
     {
-       write_char(out, '\n');
+       putc_code('\n');
     }
-    write_code_lineno(out);
+    write_code_lineno();
 }
 
 static void
 output_semantic_actions(void)
 {
     int c, last;
-    FILE *out;
 
     rewind(action_file);
     if ((c = getc(action_file)) == EOF)
        return;
 
-    out = code_file;
     last = c;
-    write_char(out, c);
+    putc_code(c);
     while ((c = getc(action_file)) != EOF)
     {
-       write_char(out, c);
+       putc_code(c);
        last = c;
     }
 
     if (last != '\n')
     {
-       write_char(out, '\n');
+       putc_code('\n');
     }
 
-    write_code_lineno(out);
+    write_code_lineno();
 }
 
 static void
 output_parse_decl(void)
 {
-    ++outline;
-    fprintf(code_file, "/* compatibility with bison */\n");
-    ++outline;
-    fprintf(code_file, "#ifdef YYPARSE_PARAM\n");
-    ++outline;
-    fprintf(code_file, "/* compatibility with FreeBSD */\n");
-    ++outline;
-    fprintf(code_file, "# ifdef YYPARSE_PARAM_TYPE\n");
-    ++outline;
-    fprintf(code_file, "#  define YYPARSE_DECL() "
-           "yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)\n");
-    ++outline;
-    fprintf(code_file, "# else\n");
-    ++outline;
-    fprintf(code_file, "#  define YYPARSE_DECL() "
-           "yyparse(void *YYPARSE_PARAM)\n");
-    ++outline;
-    fprintf(code_file, "# endif\n");
-    ++outline;
-    fprintf(code_file, "#else\n");
-    ++outline;
-    fprintf(code_file, "# define YYPARSE_DECL() yyparse(");
+    putl_code("/* compatibility with bison */\n");
+    putl_code("#ifdef YYPARSE_PARAM\n");
+    putl_code("/* compatibility with FreeBSD */\n");
+    putl_code("# ifdef YYPARSE_PARAM_TYPE\n");
+    putl_code("#  define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)\n");
+    putl_code("# else\n");
+    putl_code("#  define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)\n");
+    putl_code("# endif\n");
+    putl_code("#else\n");
+
+    puts_code("# define YYPARSE_DECL() yyparse(");
     if (!parse_param)
-       fprintf(code_file, "void");
+       puts_code("void");
     else
     {
        param *p;
@@ -1216,86 +1228,86 @@ output_parse_decl(void)
            fprintf(code_file, "%s %s%s%s", p->type, p->name, p->type2,
                    p->next ? ", " : "");
     }
-    fprintf(code_file, ")\n");
-    outline += 2;
-    fprintf(code_file, "#endif\n\n");
+    putl_code(")\n");
+
+    putl_code("#endif\n");
+    putl_code("\n");
 }
 
 static void
 output_lex_decl(void)
 {
-    ++outline;
-    fprintf(code_file, "/* Parameters sent to lex. */\n");
-    ++outline;
-    fprintf(code_file, "#ifdef YYLEX_PARAM\n");
+    putl_code("/* Parameters sent to lex. */\n");
+    putl_code("#ifdef YYLEX_PARAM\n");
     if (pure_parser)
     {
-       ++outline;
-       fprintf(code_file, "# define YYLEX_DECL() yylex(YYSTYPE *yylval, "
-               "void *YYLEX_PARAM)\n");
-       ++outline;
-       fprintf(code_file, "# define YYLEX yylex(&yylval, YYLEX_PARAM)\n");
+       putl_code("# define YYLEX_DECL() yylex(YYSTYPE *yylval, "
+                 "void *YYLEX_PARAM)\n");
+       putl_code("# define YYLEX yylex(&yylval, YYLEX_PARAM)\n");
     }
     else
     {
-       ++outline;
-       fprintf(code_file,
-               "# define YYLEX_DECL() yylex(void *YYLEX_PARAM)\n");
-       ++outline;
-       fprintf(code_file, "# define YYLEX yylex(YYLEX_PARAM)\n");
+       putl_code("# define YYLEX_DECL() yylex(void *YYLEX_PARAM)\n");
+       putl_code("# define YYLEX yylex(YYLEX_PARAM)\n");
     }
-    ++outline;
-    fprintf(code_file, "#else\n");
+    putl_code("#else\n");
     if (pure_parser && lex_param)
     {
        param *p;
-       fprintf(code_file, "# define YYLEX_DECL() yylex(YYSTYPE *yylval, ");
+       puts_code("# define YYLEX_DECL() yylex(YYSTYPE *yylval, ");
        for (p = lex_param; p; p = p->next)
            fprintf(code_file, "%s %s%s%s", p->type, p->name, p->type2,
                    p->next ? ", " : "");
-       ++outline;
-       fprintf(code_file, ")\n");
+       putl_code(")\n");
 
-       fprintf(code_file, "# define YYLEX yylex(&yylval, ");
+       puts_code("# define YYLEX yylex(&yylval, ");
        for (p = lex_param; p; p = p->next)
            fprintf(code_file, "%s%s", p->name, p->next ? ", " : "");
-       ++outline;
-       fprintf(code_file, ")\n");
+       putl_code(")\n");
     }
     else if (pure_parser)
     {
-       ++outline;
-       fprintf(code_file, "# define YYLEX_DECL() yylex(YYSTYPE *yylval)\n");
-
-       ++outline;
-       fprintf(code_file, "# define YYLEX yylex(&yylval)\n");
+       putl_code("# define YYLEX_DECL() yylex(YYSTYPE *yylval)\n");
+       putl_code("# define YYLEX yylex(&yylval)\n");
     }
     else if (lex_param)
     {
        param *p;
-       fprintf(code_file, "# define YYLEX_DECL() yylex(");
+       puts_code("# define YYLEX_DECL() yylex(");
        for (p = lex_param; p; p = p->next)
            fprintf(code_file, "%s %s%s%s", p->type, p->name, p->type2,
                    p->next ? ", " : "");
-       ++outline;
-       fprintf(code_file, ")\n");
+       putl_code(")\n");
 
-       fprintf(code_file, "# define YYLEX yylex(");
+       puts_code("# define YYLEX yylex(");
        for (p = lex_param; p; p = p->next)
            fprintf(code_file, "%s%s", p->name, p->next ? ", " : "");
-       ++outline;
-       fprintf(code_file, ")\n");
+       putl_code(")\n");
     }
     else
     {
-       ++outline;
-       fprintf(code_file, "# define YYLEX_DECL() yylex(void)\n");
+       putl_code("# define YYLEX_DECL() yylex(void)\n");
+       putl_code("# define YYLEX yylex()\n");
+    }
+    putl_code("#endif\n");
+    putl_code("\n");
+}
 
-       ++outline;
-       fprintf(code_file, "# define YYLEX yylex()\n");
+static void
+output_error_decl(void)
+{
+    putl_code("/* Parameters sent to yyerror. */\n");
+    if (parse_param)
+    {
+       putl_code("#define YYERROR_DECL() yyerror(YYSTYPE *v, const char *s)\n");
+       putl_code("#define YYERROR_CALL(msg) yyerror(&yylval, msg)\n");
+    }
+    else
+    {
+       putl_code("#define YYERROR_DECL() yyerror(const char *s)\n");
+       putl_code("#define YYERROR_CALL(msg) yyerror(msg)\n");
     }
-    outline += 2;
-    fprintf(code_file, "#endif\n\n");
+    putl_code("\n");
 }
 
 static void
@@ -1337,6 +1349,19 @@ free_reductions(void)
     }
 }
 
+static void
+output_yyerror_call(const char *msg)
+{
+    puts_code("    yyerror(");
+    if (parse_param)
+    {
+       puts_code("&yylval, ");
+    }
+    puts_code("\"");
+    puts_code(msg);
+    putl_code("\");\n");
+}
+
 void
 output(void)
 {
@@ -1349,6 +1374,7 @@ output(void)
     output_stype();
     output_parse_decl();
     output_lex_decl();
+    output_error_decl();
     write_section(xdecls);
     output_defines();
     output_rule_data();
@@ -1374,8 +1400,12 @@ output(void)
        write_section(body_vars);
     }
     write_section(body_2);
+    output_yyerror_call("syntax error");
+    write_section(body_3);
     output_semantic_actions();
     write_section(trailer);
+    output_yyerror_call("yacc stack overflow");
+    write_section(trailer_2);
 }
 
 #ifdef NO_LEAKS
index 0c0c03e..e2c9183 100644 (file)
@@ -1,8 +1,8 @@
 Summary: byacc - public domain Berkeley LALR Yacc parser generator
 %define AppProgram byacc
-%define AppVersion 20101124
+%define AppVersion 20101126
 %define UseProgram yacc
-# $XTermId: byacc.spec,v 1.4 2010/11/24 14:55:39 tom Exp $
+# $XTermId: byacc.spec,v 1.5 2010/11/26 09:22:40 tom Exp $
 Name: %{AppProgram}
 Version: %{AppVersion}
 Release: 1
index 46d65c7..2ae7dd9 100644 (file)
@@ -1,3 +1,9 @@
+byacc (20101126) unstable; urgency=low
+
+  * additional fix to generated code to avoid symbol conflict
+
+ -- Thomas E. Dickey <dickey@invisible-island.net>  Fri, 26 Nov 2010 04:23:08 -0500
+
 byacc (20101124) unstable; urgency=low
 
   * amend fix for Red Hat #112617 to restore warning message.
index 8b084cc..3ea784c 100644 (file)
--- a/reader.c
+++ b/reader.c
@@ -1,4 +1,4 @@
-/* $Id: reader.c,v 1.28 2010/11/24 14:49:38 tom Exp $ */
+/* $Id: reader.c,v 1.31 2010/11/26 12:30:40 tom Exp $ */
 
 #include "defs.h"
 
@@ -227,6 +227,36 @@ nextc(void)
     }
 }
 
+/*
+ * Compare keyword to cached token, treating '_' and '-' the same.  Some
+ * grammars rely upon this misfeature.
+ */
+static int
+matchec(const char *name)
+{
+    const char *p = cache;
+    const char *q = name;
+    int code = 0;      /* assume mismatch */
+
+    while (*p != '\0' && *q != '\0')
+    {
+       char a = *p++;
+       char b = *q++;
+       if (a == '_')
+           a = '-';
+       if (b == '_')
+           b = '-';
+       if (a != b)
+           break;
+       if (*p == '\0' && *q == '\0')
+       {
+           code = 1;
+           break;
+       }
+    }
+    return code;
+}
+
 static int
 keyword(void)
 {
@@ -245,41 +275,49 @@ keyword(void)
                    c = tolower(c);
                cachec(c);
            }
-           else if (isdigit(c) || c == '-' || c == '_' || c == '.' || c == '$')
+           else if (isdigit(c)
+                    || c == '-'
+                    || c == '_'
+                    || c == '.'
+                    || c == '$')
+           {
                cachec(c);
+           }
            else
+           {
                break;
+           }
            c = *++cptr;
        }
        cachec(NUL);
 
-       if (strcmp(cache, "token") == 0 || strcmp(cache, "term") == 0)
+       if (matchec("token") || matchec("term"))
            return (TOKEN);
-       if (strcmp(cache, "type") == 0)
+       if (matchec("type"))
            return (TYPE);
-       if (strcmp(cache, "left") == 0)
+       if (matchec("left"))
            return (LEFT);
-       if (strcmp(cache, "right") == 0)
+       if (matchec("right"))
            return (RIGHT);
-       if (strcmp(cache, "nonassoc") == 0 || strcmp(cache, "binary") == 0)
+       if (matchec("nonassoc") || matchec("binary"))
            return (NONASSOC);
-       if (strcmp(cache, "start") == 0)
+       if (matchec("start"))
            return (START);
-       if (strcmp(cache, "union") == 0)
+       if (matchec("union"))
            return (UNION);
-       if (strcmp(cache, "ident") == 0)
+       if (matchec("ident"))
            return (IDENT);
-       if (strcmp(cache, "expect") == 0)
+       if (matchec("expect"))
            return (EXPECT);
-       if (strcmp(cache, "expect-rr") == 0)
+       if (matchec("expect-rr"))
            return (EXPECT_RR);
-       if (strcmp(cache, "pure-parser") == 0)
+       if (matchec("pure-parser"))
            return (PURE_PARSER);
-       if (strcmp(cache, "parse-param") == 0)
+       if (matchec("parse-param"))
            return (PARSE_PARAM);
-       if (strcmp(cache, "lex-param") == 0)
+       if (matchec("lex-param"))
            return (LEX_PARAM);
-       if (strcmp(cache, "yacc") == 0)
+       if (matchec("yacc"))
            return (POSIX_YACC);
     }
     else
@@ -500,6 +538,12 @@ copy_union(void)
     if (!lflag)
        fprintf(text_file, line_format, lineno, input_file_name);
 
+    puts_both("#ifdef YYSTYPE\n");
+    puts_both("#undef  YYSTYPE_IS_DECLARED\n");
+    puts_both("#define YYSTYPE_IS_DECLARED 1\n");
+    puts_both("#endif\n");
+    puts_both("#ifndef YYSTYPE_IS_DECLARED\n");
+    puts_both("#define YYSTYPE_IS_DECLARED 1\n");
     puts_both("typedef union");
 
     depth = 0;
@@ -523,6 +567,7 @@ copy_union(void)
        if (--depth == 0)
        {
            puts_both(" YYSTYPE;\n");
+           puts_both("#endif /* !YYSTYPE_IS_DECLARED */\n");
            FREE(u_line);
            return;
        }
index 4ea3b56..dc86e3c 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: skeleton.c,v 1.25 2010/06/07 21:24:58 Andres.Mejia Exp $ */
+/* $Id: skeleton.c,v 1.27 2010/11/26 17:24:00 tom Exp $ */
 
 #include "defs.h"
 
@@ -260,7 +260,11 @@ const char *body_2[] =
     "    }",
     "    if (yyerrflag) goto yyinrecovery;",
     "",
-    "    yyerror(\"syntax error\");",
+    0
+};
+
+const char *body_3[] =
+{
     "",
     "    goto yyerrlab;",
     "",
@@ -391,7 +395,11 @@ const char *trailer[] =
     "    goto yyloop;",
     "",
     "yyoverflow:",
-    "    yyerror(\"yacc stack overflow\");",
+    0
+};
+
+const char *trailer_2[] =
+{
     "",
     "yyabort:",
     "    yyfreestack(&yystack);",
index 3d8f198..bd98caa 100644 (file)
@@ -129,6 +129,10 @@ typedef int YYSTYPE;
 # define YYLEX yylex()
 #endif
 
+/* Parameters sent to yyerror. */
+#define YYERROR_DECL() yyerror(const char *s)
+#define YYERROR_CALL(msg) yyerror(msg)
+
 extern int YYPARSE_DECL();
 extern int YYLEX_DECL();
 
@@ -332,7 +336,7 @@ yylex(void)
     }
     return( c );
 }
-#line 336 "calc.tab.c"
+#line 340 "calc.tab.c"
 
 #if YYDEBUG
 #include <stdio.h>             /* needed for printf */
@@ -602,7 +606,7 @@ case 18:
 #line 60 "calc.y"
        {  yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
 break;
-#line 606 "calc.tab.c"
+#line 610 "calc.tab.c"
     }
     yystack.s_mark -= yym;
     yystate = *yystack.s_mark;
index 28b45cc..0597b94 100644 (file)
@@ -118,13 +118,20 @@ double dreg[26];
 INTERVAL vreg[26];
 
 #line 27 "calc1.y"
+#ifdef YYSTYPE
+#undef  YYSTYPE_IS_DECLARED
+#define YYSTYPE_IS_DECLARED 1
+#endif
+#ifndef YYSTYPE_IS_DECLARED
+#define YYSTYPE_IS_DECLARED 1
 typedef union
 {
        int ival;
        double dval;
        INTERVAL vval;
 } YYSTYPE;
-#line 128 "calc1.tab.c"
+#endif /* !YYSTYPE_IS_DECLARED */
+#line 135 "calc1.tab.c"
 /* compatibility with bison */
 #ifdef YYPARSE_PARAM
 /* compatibility with FreeBSD */
@@ -146,6 +153,10 @@ typedef union
 # define YYLEX yylex()
 #endif
 
+/* Parameters sent to yyerror. */
+#define YYERROR_DECL() yyerror(const char *s)
+#define YYERROR_CALL(msg) yyerror(msg)
+
 extern int YYPARSE_DECL();
 extern int YYLEX_DECL();
 
@@ -368,7 +379,7 @@ yylex(void)
     {
        /* gobble up digits, points, exponents */
        char buf[BSZ + 1], *cp = buf;
-       int dot = 0, exp = 0;
+       int dot = 0, expr = 0;
 
        for (; (cp - buf) < BSZ; ++cp, c = getchar())
        {
@@ -378,14 +389,14 @@ yylex(void)
                continue;
            if (c == '.')
            {
-               if (dot++ || exp)
+               if (dot++ || expr)
                    return ('.');       /* will cause syntax error */
                continue;
            }
 
            if (c == 'e')
            {
-               if (exp++)
+               if (expr++)
                    return ('e');       /*  will  cause  syntax  error  */
                continue;
            }
@@ -462,7 +473,7 @@ vdiv(double a, double b, INTERVAL v)
 {
     return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo));
 }
-#line 466 "calc1.tab.c"
+#line 477 "calc1.tab.c"
 
 #if YYDEBUG
 #include <stdio.h>             /* needed for printf */
@@ -835,7 +846,7 @@ case 28:
                yyval.vval = yystack.l_mark[-1].vval;
        }
 break;
-#line 839 "calc1.tab.c"
+#line 850 "calc1.tab.c"
     }
     yystack.s_mark -= yym;
     yystate = *yystack.s_mark;
index 38927d5..c0633e3 100644 (file)
@@ -2,12 +2,17 @@
 #define VREG 258
 #define CONST 259
 #define UMINUS 260
-#if !(defined(YYSTYPE) || defined(YYSTYPE_IS_DECLARED))
+#ifdef YYSTYPE
+#undef  YYSTYPE_IS_DECLARED
+#define YYSTYPE_IS_DECLARED 1
+#endif
+#ifndef YYSTYPE_IS_DECLARED
+#define YYSTYPE_IS_DECLARED 1
 typedef union
 {
        int ival;
        double dval;
        INTERVAL vval;
 } YYSTYPE;
-#endif /* !(YYSTYPE || YYSTYPE_IS_DECLARED) */
+#endif /* !YYSTYPE_IS_DECLARED */
 extern YYSTYPE calc1_lval;
index 2c0e55d..d99dd2d 100644 (file)
@@ -205,7 +205,7 @@ yylex(void)
     {
        /* gobble up digits, points, exponents */
        char buf[BSZ + 1], *cp = buf;
-       int dot = 0, exp = 0;
+       int dot = 0, expr = 0;
 
        for (; (cp - buf) < BSZ; ++cp, c = getchar())
        {
@@ -215,14 +215,14 @@ yylex(void)
                continue;
            if (c == '.')
            {
-               if (dot++ || exp)
+               if (dot++ || expr)
                    return ('.');       /* will cause syntax error */
                continue;
            }
 
            if (c == 'e')
            {
-               if (exp++)
+               if (expr++)
                    return ('e');       /*  will  cause  syntax  error  */
                continue;
            }
index 8a33361..5d863a5 100644 (file)
@@ -126,6 +126,10 @@ typedef int YYSTYPE;
 # define YYLEX yylex(base)
 #endif
 
+/* Parameters sent to yyerror. */
+#define YYERROR_DECL() yyerror(YYSTYPE *v, const char *s)
+#define YYERROR_CALL(msg) yyerror(&yylval, msg)
+
 extern int YYPARSE_DECL();
 extern int YYLEX_DECL();
 
@@ -303,7 +307,7 @@ main (void)
 }
 
 static void
-yyerror(const char *s)
+YYERROR_DECL()
 {
     fprintf(stderr, "%s\n", s);
 }
@@ -332,7 +336,7 @@ yylex(int *base)
     }
     return( c );
 }
-#line 336 "calc2.tab.c"
+#line 340 "calc2.tab.c"
 
 #if YYDEBUG
 #include <stdio.h>             /* needed for printf */
@@ -469,7 +473,7 @@ yyloop:
     }
     if (yyerrflag) goto yyinrecovery;
 
-    yyerror("syntax error");
+    yyerror(&yylval, "syntax error");
 
     goto yyerrlab;
 
@@ -602,7 +606,7 @@ case 18:
 #line 62 "calc2.y"
        {  yyval = (*base) * yystack.l_mark[-1] + yystack.l_mark[0]; }
 break;
-#line 606 "calc2.tab.c"
+#line 610 "calc2.tab.c"
     }
     yystack.s_mark -= yym;
     yystate = *yystack.s_mark;
@@ -654,7 +658,7 @@ to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
     goto yyloop;
 
 yyoverflow:
-    yyerror("yacc stack overflow");
+    yyerror(&yylval, "yacc stack overflow");
 
 yyabort:
     yyfreestack(&yystack);
index 9bce132..ca6b74a 100644 (file)
@@ -77,7 +77,7 @@ main (void)
 }
 
 static void
-yyerror(const char *s)
+YYERROR_DECL()
 {
     fprintf(stderr, "%s\n", s);
 }
index b0a6b56..50b9009 100644 (file)
@@ -126,6 +126,10 @@ typedef int YYSTYPE;
 # define YYLEX yylex(&yylval, base)
 #endif
 
+/* Parameters sent to yyerror. */
+#define YYERROR_DECL() yyerror(YYSTYPE *v, const char *s)
+#define YYERROR_CALL(msg) yyerror(&yylval, msg)
+
 extern int YYPARSE_DECL();
 extern int YYLEX_DECL();
 
@@ -296,7 +300,7 @@ main (void)
 }
 
 static void
-yyerror(const char *s)
+YYERROR_DECL()
 {
     fprintf(stderr, "%s\n", s);
 }
@@ -325,7 +329,7 @@ YYLEX_DECL()
     }
     return( c );
 }
-#line 329 "calc3.tab.c"
+#line 333 "calc3.tab.c"
 
 #if YYDEBUG
 #include <stdio.h>             /* needed for printf */
@@ -469,7 +473,7 @@ yyloop:
     }
     if (yyerrflag) goto yyinrecovery;
 
-    yyerror("syntax error");
+    yyerror(&yylval, "syntax error");
 
     goto yyerrlab;
 
@@ -602,7 +606,7 @@ case 18:
 #line 64 "calc3.y"
        {  yyval = (*base) * yystack.l_mark[-1] + yystack.l_mark[0]; }
 break;
-#line 606 "calc3.tab.c"
+#line 610 "calc3.tab.c"
     }
     yystack.s_mark -= yym;
     yystate = *yystack.s_mark;
@@ -654,7 +658,7 @@ to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
     goto yyloop;
 
 yyoverflow:
-    yyerror("yacc stack overflow");
+    yyerror(&yylval, "yacc stack overflow");
 
 yyabort:
     yyfreestack(&yystack);
index efca5eb..ce55a9c 100644 (file)
@@ -79,7 +79,7 @@ main (void)
 }
 
 static void
-yyerror(const char *s)
+YYERROR_DECL()
 {
     fprintf(stderr, "%s\n", s);
 }
index 38a45b5..6833def 100644 (file)
@@ -21,7 +21,7 @@ static const char yysccsid[] = "@(#)yaccpar   1.9 (Berkeley) 02/21/93";
 int regs[26];
 int base;
 
-#line 106 "code_calc.code.c"
+#line 25 "code_calc.code.c"
 
 #ifndef YYSTYPE
 typedef int YYSTYPE;
@@ -48,6 +48,10 @@ typedef int YYSTYPE;
 # define YYLEX yylex()
 #endif
 
+/* Parameters sent to yyerror. */
+#define YYERROR_DECL() yyerror(const char *s)
+#define YYERROR_CALL(msg) yyerror(msg)
+
 extern int YYPARSE_DECL();
 extern int YYLEX_DECL();
 
@@ -233,7 +237,7 @@ yylex(void) {
     }
     return( c );
 }
-#line 318 "code_calc.code.c"
+#line 241 "code_calc.code.c"
 
 #if YYDEBUG
 #include <stdio.h>             /* needed for printf */
@@ -503,7 +507,7 @@ case 18:
 #line 60 "code_calc.y"
        {  yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
 break;
-#line 588 "code_calc.code.c"
+#line 511 "code_calc.code.c"
     }
     yystack.s_mark -= yym;
     yystate = *yystack.s_mark;
index d45b8a4..35050b5 100644 (file)
@@ -40,6 +40,10 @@ typedef int YYSTYPE;
 # define YYLEX yylex()
 #endif
 
+/* Parameters sent to yyerror. */
+#define YYERROR_DECL() yyerror(const char *s)
+#define YYERROR_CALL(msg) yyerror(msg)
+
 extern int YYPARSE_DECL();
 extern int YYLEX_DECL();
 
@@ -203,7 +207,7 @@ yyerror(const char* s)
 {
     printf("%s\n", s);
 }
-#line 288 "code_error.code.c"
+#line 211 "code_error.code.c"
 
 #if YYDEBUG
 #include <stdio.h>             /* needed for printf */
index fd80e4e..66487ac 100644 (file)
@@ -121,6 +121,10 @@ typedef int YYSTYPE;
 # define YYLEX yylex()
 #endif
 
+/* Parameters sent to yyerror. */
+#define YYERROR_DECL() yyerror(const char *s)
+#define YYERROR_CALL(msg) yyerror(msg)
+
 extern int YYPARSE_DECL();
 extern int YYLEX_DECL();
 
@@ -220,7 +224,7 @@ yyerror(const char* s)
 {
     printf("%s\n", s);
 }
-#line 224 "error.tab.c"
+#line 228 "error.tab.c"
 
 #if YYDEBUG
 #include <stdio.h>             /* needed for printf */
index 93be71a..55f7de0 100644 (file)
@@ -203,6 +203,10 @@ typedef int YYSTYPE;
 # define YYLEX yylex()
 #endif
 
+/* Parameters sent to yyerror. */
+#define YYERROR_DECL() yyerror(const char *s)
+#define YYERROR_CALL(msg) yyerror(msg)
+
 extern int YYPARSE_DECL();
 extern int YYLEX_DECL();
 
@@ -1062,7 +1066,7 @@ sizecmd(char *filename)
                reply(504, "SIZE not implemented for Type %c.", "?AEIL"[type]);
        }
 }
-#line 1066 "ftp.tab.c"
+#line 1070 "ftp.tab.c"
 
 #if YYDEBUG
 #include <stdio.h>             /* needed for printf */
@@ -1908,7 +1912,7 @@ case 73:
                }
        }
 break;
-#line 1912 "ftp.tab.c"
+#line 1916 "ftp.tab.c"
     }
     yystack.s_mark -= yym;
     yystate = *yystack.s_mark;
index f2d8b15..b8b16f6 100644 (file)
@@ -396,6 +396,10 @@ haveAnsiParam (void)
 # define YYLEX yylex()
 #endif
 
+/* Parameters sent to yyerror. */
+#define YYERROR_DECL() yyerror(const char *s)
+#define YYERROR_CALL(msg) yyerror(msg)
+
 extern int YYPARSE_DECL();
 extern int YYLEX_DECL();
 
@@ -1064,7 +1068,7 @@ free_parser(void)
 #endif
 }
 #endif
-#line 1068 "grammar.tab.c"
+#line 1072 "grammar.tab.c"
 
 #if YYDEBUG
 #include <stdio.h>             /* needed for printf */
@@ -1948,7 +1952,7 @@ case 114:
            yyval.declarator->func_def = FUNC_ANSI;
        }
 break;
-#line 1952 "grammar.tab.c"
+#line 1956 "grammar.tab.c"
     }
     yystack.s_mark -= yym;
     yystate = *yystack.s_mark;
index 41c8e0f..5d10ba8 100644 (file)
@@ -129,6 +129,10 @@ typedef int YYSTYPE;
 # define YYLEX yylex(&yylval)
 #endif
 
+/* Parameters sent to yyerror. */
+#define YYERROR_DECL() yyerror(const char *s)
+#define YYERROR_CALL(msg) yyerror(msg)
+
 extern int YYPARSE_DECL();
 extern int YYLEX_DECL();
 
@@ -325,7 +329,7 @@ yylex(YYSTYPE *value)
     }
     return( c );
 }
-#line 329 "pure_calc.tab.c"
+#line 333 "pure_calc.tab.c"
 
 #if YYDEBUG
 #include <stdio.h>             /* needed for printf */
@@ -602,7 +606,7 @@ case 18:
 #line 60 "pure_calc.y"
        {  yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
 break;
-#line 606 "pure_calc.tab.c"
+#line 610 "pure_calc.tab.c"
     }
     yystack.s_mark -= yym;
     yystate = *yystack.s_mark;
index 9076dd0..4bce3c8 100644 (file)
@@ -121,6 +121,10 @@ typedef int YYSTYPE;
 # define YYLEX yylex(&yylval)
 #endif
 
+/* Parameters sent to yyerror. */
+#define YYERROR_DECL() yyerror(const char *s)
+#define YYERROR_CALL(msg) yyerror(msg)
+
 extern int YYPARSE_DECL();
 extern int YYLEX_DECL();
 
@@ -213,7 +217,7 @@ yyerror(const char* s)
 {
     printf("%s\n", s);
 }
-#line 217 "pure_error.tab.c"
+#line 221 "pure_error.tab.c"
 
 #if YYDEBUG
 #include <stdio.h>             /* needed for printf */
diff --git a/yacc.1 b/yacc.1
index 3ee0d3d..bbcc9cb 100644 (file)
--- a/yacc.1
+++ b/yacc.1
@@ -1,8 +1,8 @@
-.\" $Id: yacc.1,v 1.9 2010/06/10 20:50:08 tom Exp $
+.\" $Id: yacc.1,v 1.11 2010/11/26 16:27:11 tom Exp $
 .\"
 .\" .TH YACC 1 "July\ 15,\ 1990"
 .\" .UC 6
-.TH YACC 1 "June 10, 2010" "Berkeley Yacc" "User Commands"
+.TH YACC 1 "November 26, 2010" "Berkeley Yacc" "User Commands"
 .SH NAME
 Yacc \- an LALR(1) parser generator
 .SH SYNOPSIS
@@ -88,6 +88,7 @@ is named
 .IR y.code.c,
 and the tables file is named
 .IR y.tab.c.
+The prefix "\fIy.\fP" can be overridden using the \fB\-b\fP option.
 .TP
 .B \-t
 The