Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!cmcl2!brl-adm!umd5!uvaarpa!mcnc!rti!xyzzy!meissner From: meissner@xyzzy.UUCP (Michael Meissner) Newsgroups: comp.lang.c Subject: Re: pcc misfeature Message-ID: <415@xyzzy.UUCP> Date: Wed, 2-Dec-87 17:26:11 EST Article-I.D.: xyzzy.415 Posted: Wed Dec 2 17:26:11 1987 Date-Received: Sun, 6-Dec-87 04:26:04 EST References: <3125@psuvax1.psu.edu> Reply-To: meissner@xyzzy.UUCP (Michael Meissner) Organization: Data General (Languages @ Research Triangle Park, NC.) Lines: 36 In article <3125@psuvax1.psu.edu> schwartz@gondor.psu.edu (Scott E. Schwartz) writes: | | If you compile the following program with 4.3BSD cc or lint | | main() | { | while aaa()) { | bbb("\n"); | } | } | | you get | | "snoob.c", line 4: syntax error | "snoob.c", line 5: illegal character: 134 (octal) | "snoob.c", line 5: cannot recover from earlier errors: goodbye! In general, error recovery is hard for LALR passed compilers. Yacc in general, barely tries. In the Data General C compiler (which does not use Yacc or pcc) I put in code that tries local error recovery, by checking what the effect of adding, deleting, or changing a single token in case of an error, and correcting it on the spot. Before accepting the change, the compiler checks the next two tokens to make sure the parse won't run into more errors down the pike. In general, this works well for single token errors, but doesn't handle real badly formed programs. For example, heres the output of the Data General compiler with the same program: Error 502 severity 2 beginning on line 2 (Line 2 of file test_error.c) while aaa()) { ^ Syntax Error. A symbol of type "(" has been inserted before this symbol. -- Michael Meissner, Data General. Uucp: ...!mcnc!rti!xyzzy!meissner Arpa/Csnet: meissner@dg-rtp.DG.COM