From: etheisen Date: Sun, 31 Mar 1996 04:56:00 +0000 (+0000) Subject: Fix 960317 NetBSD merge error. Merge caused local OpenBSD mod lossage. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=6402e213041a7c03bc842c5740ed9dfbbbe870cc;p=openbsd Fix 960317 NetBSD merge error. Merge caused local OpenBSD mod lossage. NetBSD's byacc %expect mods are buggy and don't handle syntax or semantic errors. Additionally, they do not mimic the BISON behavior they try to emulate. Our local OpenBSD %expect mods are much better. --- diff --git a/usr.bin/yacc/defs.h b/usr.bin/yacc/defs.h index 440f820ba8f..57e2e28151c 100644 --- a/usr.bin/yacc/defs.h +++ b/usr.bin/yacc/defs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: defs.h,v 1.3 1996/03/27 19:33:18 niklas Exp $ */ +/* $OpenBSD: defs.h,v 1.4 1996/03/31 04:56:00 etheisen Exp $ */ #include #include diff --git a/usr.bin/yacc/mkpar.c b/usr.bin/yacc/mkpar.c index b66784be599..34df17afc77 100644 --- a/usr.bin/yacc/mkpar.c +++ b/usr.bin/yacc/mkpar.c @@ -1,5 +1,7 @@ +/* $OpenBSD: mkpar.c,v 1.3 1996/03/31 04:56:02 etheisen Exp $ */ + #ifndef lint -static char rcsid[] = "$Id: mkpar.c,v 1.2 1996/02/04 08:37:01 etheisen Exp $"; +static char rcsid[] = "$Id: mkpar.c,v 1.3 1996/03/31 04:56:02 etheisen Exp $"; #endif /* not lint */ #include "defs.h" diff --git a/usr.bin/yacc/reader.c b/usr.bin/yacc/reader.c index e3367fa6569..f0504e32239 100644 --- a/usr.bin/yacc/reader.c +++ b/usr.bin/yacc/reader.c @@ -1,7 +1,7 @@ -/* $OpenBSD: reader.c,v 1.3 1996/03/27 19:33:19 niklas Exp $ */ +/* $OpenBSD: reader.c,v 1.4 1996/03/31 04:56:01 etheisen Exp $ */ #ifndef lint -static char rcsid[] = "$OpenBSD: reader.c,v 1.3 1996/03/27 19:33:19 niklas Exp $"; +static char rcsid[] = "$Id: reader.c,v 1.4 1996/03/31 04:56:01 etheisen Exp $"; #endif /* not lint */ #include "defs.h" @@ -894,6 +894,50 @@ int assoc; } +/* + * %expect requires special handling + * as it really isn't part of the yacc + * grammar only a flag for yacc proper. + */ +declare_expect(assoc) +int assoc; +{ + register int c; + + if (assoc != EXPECT) ++prec; + + /* + * Stay away from nextc - doesn't + * detect EOL and will read to EOF. + */ + c = *++cptr; + if (c == EOF) unexpected_EOF(); + + for(;;) + { + if (isdigit(c)) + { + SRexpect = get_number(); + break; + } + /* + * Looking for number before EOL. + * Spaces, tabs, and numbers are ok, + * words, punc., etc. are syntax errors. + */ + else if (c == '\n' || isalpha(c) || !isspace(c)) + { + syntax_error(lineno, line, cptr); + } + else + { + c = *++cptr; + if (c == EOF) unexpected_EOF(); + } + } +} + + declare_types() { register int c; @@ -939,23 +983,6 @@ declare_start() goal = bp; } -handle_expect() -{ - register int c; - register int num; - - c = nextc(); - if (c == EOF) unexpected_EOF(); - if (!isdigit(c)) - syntax_error(lineno, line, cptr); - num = get_number(); - if (num == 1) - fprintf (stderr, "%s: Expect 1 shift/reduce conflict.\n", myname); - else - fprintf (stderr, "%s: Expect %d shift/reduce conflicts.\n", myname, - num); -} - read_declarations() { @@ -994,6 +1021,10 @@ read_declarations() declare_tokens(k); break; + case EXPECT: + declare_expect(k); + break; + case TYPE: declare_types(); break; @@ -1001,10 +1032,6 @@ read_declarations() case START: declare_start(); break; - - case EXPECT: - handle_expect(); - break; } } }