From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id F06DCBB9C for ; Mon, 5 Dec 2005 08:08:03 +0100 (CET) Received: from mail.barettadeit.com (h213-255-109-130.albacom.net [213.255.109.130] (may be forged)) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id jB5783ge032385 for ; Mon, 5 Dec 2005 08:08:03 +0100 Received: from [10.0.0.10] (alex.barettalocal.com [10.0.0.10]) by mail.barettadeit.com (Postfix) with ESMTP id C462E40C10A; Mon, 5 Dec 2005 08:08:59 +0100 (CET) Message-ID: <4393E75C.9000608@barettadeit.com> Date: Mon, 05 Dec 2005 08:08:12 +0100 From: Alessandro Baretta User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) X-Accept-Language: en-us, en MIME-Version: 1.0 To: skaller Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Another nasty with ocamlyacc: magic needed? References: <1133760933.8957.125.camel@rosella> In-Reply-To: <1133760933.8957.125.camel@rosella> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 4393E753.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; baretta:01 baretta:01 barettadeit:01 caml-list:01 ocamlyacc:01 showstopper:01 parsers:01 tokens:01 parser:01 parser:01 token:01 non-terminal:01 grammars:01 ocamlyacc:01 ocamlc:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.3 skaller wrote: > I have what looks like a showstopper (meaning black magic > seems to be the only solution). > > I need two *distinct* parsers which use the same set > of tokens. This is currently impossible AFAICS without > magic (distinct -- in a different module entirely) Let's not overstate the problem. Yacc is an imperfect tool. Everybody who used it knows this, but it is usually flexible enough that you can--eventually--get it to do what you have in mind. I would suggest that you consider a couple of tools which might help get out of this /impasse/. Firstly, remember that can define as many parser entry points as your heat desires. Each entry point is virtually a distinct parser, except that the token type is shared and the non-terminal namespace is also shared, which might be a bane or a boon depending on whether the two grammars you wish to impolement share some productions or not. Secondly, after compiling the automaton with ocamlyacc, you can always delete and regenerate the interface with ocamlc -i. My Makefile generator for ocaml, builder, actually handles this pretty nicely, allowing the parser to export anything you put in the header. Alex -- ********************************************************************* http://www.barettadeit.com/ Baretta DE&IT A division of Baretta SRL tel. +39 02 370 111 55 fax. +39 02 370 111 54 Our technology: The Application System/Xcaml (AS/Xcaml) The FreerP Project