From owner-freebsd-bugs Sun Apr 27 22:20:06 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id WAA22870 for bugs-outgoing; Sun, 27 Apr 1997 22:20:06 -0700 (PDT) Received: (from gnats@localhost) by hub.freebsd.org (8.8.5/8.8.5) id WAA22852; Sun, 27 Apr 1997 22:20:03 -0700 (PDT) Resent-Date: Sun, 27 Apr 1997 22:20:03 -0700 (PDT) Resent-Message-Id: <199704280520.WAA22852@hub.freebsd.org> Resent-From: gnats (GNATS Management) Resent-To: freebsd-bugs Resent-Reply-To: FreeBSD-gnats@freefall.FreeBSD.ORG, ac199@hwcn.org Received: from X2296 (ppp1558.on.sympatico.ca [206.172.249.22]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id WAA22625 for ; Sun, 27 Apr 1997 22:12:45 -0700 (PDT) Received: (from tim@localhost) by X2296 (8.7.6/8.7.3) id BAA00878; Mon, 28 Apr 1997 01:06:47 -0400 (EDT) Message-Id: <199704280506.BAA00878@X2296> Date: Mon, 28 Apr 1997 01:06:47 -0400 (EDT) From: Tim.Vanderhoek@X2296 Reply-To: ac199@hwcn.org To: FreeBSD-gnats-submit@freebsd.org Cc: robert.corbett@eng.Sun.COM X-Send-Pr-Version: 3.2 Subject: bin/3403: yacc doesn't well parse recursivish errors Sender: owner-bugs@freebsd.org X-Loop: FreeBSD.org Precedence: bulk >Number: 3403 >Category: bin >Synopsis: yacc doesn't well parse recursivish errors >Confidential: no >Severity: serious >Priority: low >Responsible: freebsd-bugs >State: open >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun Apr 27 22:20:01 PDT 1997 >Last-Modified: >Originator: Tim Vanderhoek >Organization: The league of those who hack with yacc when they should be studying for their upcoming Bible test... >Release: FreeBSD 2.2-961006-SNAP i386 >Environment: Reasonably current yacc from FreeBSD-current... The yacc is more current than the Release line of this pr would suggest... >Description: It would seem that yacc doesn't properly handle rules along the lines of a: a error when multiple errors occur. Cc'd to robert.corbett@eng.Sun.COM (although I don't know if send-pr will strip that or not...) >How-To-Repeat: The following program should print out have the following output: -- Parsed #1 Parsed #0 -- However, it does not. Rather, only the first line ("Parsed #1") is printed... This is not what I want the program to do. It works correctly when one uses Bison (--version: GNU Bison version 1.25) to generate the parser. (If you try this, don't forget to give the -t argument to bison). Follows brief explanation of what goes wrong... It correctly shifts into state 1 (a : X . a error) for the first X, and then shifts into state 1 again for the second X. The Y token is returned and it correctly reduces an `a', and then an error, and finally reduces from state 5 (X a error .) all the way back to state 4 (X a . error) to finish off the first X statement. The error recovery correctly generates an error, however, this time it _DOES NOT_ shift from state 4 to state 5 on the error. Bison does exactly the same thing, except for the fact that it does shift on the second error the way it is supposed to... :) -- %{ #include %} %union { int exp; } %token X %token Y %token NOSUCHTOKEN %token ERROR %% a: Y {} /* Hmm... can't use a simple "empty" here... */ | X a NOSUCHTOKEN {} | X a error { fprintf (stderr, "Parsed #%d\n", $1); } ; %% main () { yydebug = atoi(getenv("YYDEBUG") ? getenv("YYDEBUG") : ""); /* Bison */ yyparse (); } yylex () { static p = 0; const int tok[] = {X, X, Y, ERROR, ERROR, ERROR, 0}; if (tok[p] == X) yylval.exp = p; return tok[p++]; } yyerror() {} -- >Fix: Heh. My head's still spinning after spending most of today tracing this one down... >Audit-Trail: >Unformatted: