diff options
Diffstat (limited to 'usr.bin/yacc/reader.c')
-rw-r--r-- | usr.bin/yacc/reader.c | 73 |
1 files changed, 24 insertions, 49 deletions
diff --git a/usr.bin/yacc/reader.c b/usr.bin/yacc/reader.c index f4c0de4df35..e3367fa6569 100644 --- a/usr.bin/yacc/reader.c +++ b/usr.bin/yacc/reader.c @@ -1,5 +1,7 @@ +/* $OpenBSD: reader.c,v 1.3 1996/03/27 19:33:19 niklas Exp $ */ + #ifndef lint -static char rcsid[] = "$Id: reader.c,v 1.2 1996/02/04 08:37:02 etheisen Exp $"; +static char rcsid[] = "$OpenBSD: reader.c,v 1.3 1996/03/27 19:33:19 niklas Exp $"; #endif /* not lint */ #include "defs.h" @@ -892,50 +894,6 @@ 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; @@ -981,6 +939,23 @@ 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() { @@ -1019,10 +994,6 @@ read_declarations() declare_tokens(k); break; - case EXPECT: - declare_expect(k); - break; - case TYPE: declare_types(); break; @@ -1030,6 +1001,10 @@ read_declarations() case START: declare_start(); break; + + case EXPECT: + handle_expect(); + break; } } } |