gagging on GNU bison grammer.
-/* $Id: defs.h,v 1.1.1.1 1995/10/18 08:47:05 deraadt Exp $ */
+/* $Id: defs.h,v 1.2 1996/02/04 08:37:00 etheisen Exp $ */
#include <assert.h>
#include <ctype.h>
#define START 7
#define UNION 8
#define IDENT 9
+#define EXPECT 10
/* symbol classes */
extern action **parser;
extern int SRtotal;
+extern int SRexpect;
extern int RRtotal;
extern short *SRconflicts;
extern short *RRconflicts;
#ifndef lint
-static char rcsid[] = "$Id: mkpar.c,v 1.1.1.1 1995/10/18 08:47:05 deraadt Exp $";
+static char rcsid[] = "$Id: mkpar.c,v 1.2 1996/02/04 08:37:01 etheisen Exp $";
#endif /* not lint */
#include "defs.h"
action **parser;
int SRtotal;
+int SRexpect = 0;
int RRtotal;
short *SRconflicts;
short *RRconflicts;
total_conflicts()
{
- fprintf(stderr, "%s: ", myname);
- if (SRtotal == 1)
- fprintf(stderr, "1 shift/reduce conflict");
- else if (SRtotal > 1)
- fprintf(stderr, "%d shift/reduce conflicts", SRtotal);
-
- if (SRtotal && RRtotal)
- fprintf(stderr, ", ");
+ /* Warn if s/r != expect or if any r/r */
+ if ((SRtotal != SRexpect) || RRtotal)
+ {
+ if (SRtotal == 1)
+ fprintf(stderr, "%s: 1 shift/reduce conflict\n", myname);
+ else if (SRtotal > 1)
+ fprintf(stderr, "%s: %d shift/reduce conflicts\n", myname,
+ SRtotal);
+ }
if (RRtotal == 1)
- fprintf(stderr, "1 reduce/reduce conflict");
+ fprintf(stderr, "%s: 1 reduce/reduce conflict\n", myname);
else if (RRtotal > 1)
- fprintf(stderr, "%d reduce/reduce conflicts", RRtotal);
-
- fprintf(stderr, ".\n");
+ fprintf(stderr, "%s: %d reduce/reduce conflicts\n", myname,
+ RRtotal);
}
#ifndef lint
-static char rcsid[] = "$Id: reader.c,v 1.1.1.1 1995/10/18 08:47:06 deraadt Exp $";
+static char rcsid[] = "$Id: reader.c,v 1.2 1996/02/04 08:37:02 etheisen Exp $";
#endif /* not lint */
#include "defs.h"
return (UNION);
if (strcmp(cache, "ident") == 0)
return (IDENT);
+ if (strcmp(cache, "expect") == 0)
+ return (EXPECT);
}
else
{
}
+/*
+ * %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;
declare_tokens(k);
break;
+ case EXPECT:
+ declare_expect(k);
+ break;
+
case TYPE:
declare_types();
break;