From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id OAA23454; Fri, 2 Mar 2001 14:21:35 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id OAA23161 for ; Fri, 2 Mar 2001 14:21:34 +0100 (MET) Received: from miss.wu-wien.ac.at (miss.wu-wien.ac.at [137.208.107.17]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f22DLX901333 for ; Fri, 2 Mar 2001 14:21:33 +0100 (MET) Received: (from mottl@localhost) by miss.wu-wien.ac.at (8.9.0/8.9.0) id OAA25471; Fri, 2 Mar 2001 14:21:28 +0100 (MET) Date: Fri, 2 Mar 2001 14:21:28 +0100 From: Markus Mottl To: Laurent Reveillere Cc: caml-list@inria.fr Subject: Re: [Caml-list] Problem when parsing Message-ID: <20010302142128.A23707@miss.wu-wien.ac.at> References: <3A9F79EC.56C757EA@labri.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <3A9F79EC.56C757EA@labri.fr>; from Laurent.Reveillere@labri.u-bordeaux.fr on Fri, Mar 02, 2001 at 11:46:04 +0100 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Fri, 02 Mar 2001, Laurent Reveillere wrote: > I wrote a small parser for iso C which does nothing (for now). > The lexer and parser files are well compiled by ocamllex and ocamlyacc. > But when I run the generated program, I have the following error : > > Fatal error: uncaught exception Failure(lexing: empty token) [snip] The problem is that your parser rules are recursive, and you do not handle EOF (end-of-file) in the lexer. This means that the parser will demand a new token, because the recursive parser rule says that there could be more of them. The lexer, however, doesn't return further ones, because it doesn't know how to handle EOF. There is a special pattern called "eof" (without the double-quotes) that you can use in the lexer to match EOF. You can introduce a new token "EOF" in the parser and return this one from the scanner when required. You'll need parser rules that handle the EOF-token, of course. Then your problem should go away. Regards, Markus Mottl -- Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr