From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id B0840BBC1 for ; Tue, 22 Apr 2008 15:56:31 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqcCAMaLDUiBCnQzgWdsb2JhbACRWAEBECaaUw X-IronPort-AV: E=Sophos;i="4.25,693,1199660400"; d="scan'208";a="11266524" Received: from amber.ccs.neu.edu ([129.10.116.51]) by mail1-smtp-roc.national.inria.fr with ESMTP; 22 Apr 2008 15:56:31 +0200 Received: from c-24-60-10-50.hsd1.ma.comcast.net ([24.60.10.50] helo=localhost) by amber.ccs.neu.edu with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.50) id 1JoIyj-0003SE-Dd; Tue, 22 Apr 2008 09:56:14 -0400 Date: Tue, 22 Apr 2008 09:56:12 -0400 From: Richard Cobbe To: caml-list@yquem.inria.fr Subject: Additional exports from ocamlyacc-generated module? Message-ID: <20080422135612.GC405@perdita.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.17 (2007-11-01) X-Spam: no; 0.00; mli:01 parser:01 parser:01 mli:01 ocamlyacc:01 annotations:01 command-line:01 ocamlyacc:01 makefile:01 val:01 ocaml:01 cleanest:98 token:01 ccs:01 defines:01 Is it possible to mark definitions in an .mly file as "public," so that they're listed in the generated .mli file? My parser.mly file has some nontrivial function definitions in its header. While these functions are used only by the parser, I'd like to write some unit tests for them. I've defined the test suite in parser.mly's trailer (after the final %%), but the generated parser.mli file includes only the token definition and the functions corresponding to my grammar's start symbols. Since nobody else can see the test suite, I can't actually run these tests from outside the module. The ocamlyacc manual doesn't describe any way to accomplish this, either with annotations in parser.mly or with command-line args to ocamlyacc. I've thought of various possible work-arounds, none of which are all that pleasant: - parser.mly's trailer defines the test cases and then runs them itself. Not good; this will run the tests every time I load the module. - Have the Makefile append val tests : OUnit.test to the end of parser.mli after calling ocamlyacc. - Move the functions out of parser.mly's header into a separate module, and put the tests cases for those functions there. This is probably the cleanest solution, but I don't like making these functions visible to the rest of the program. Is there a better way to do this? If it matters, I'm using OCaml 3.10.2, packaged by Fink; Mac OS 10.5.2 Intel. I'm using the OUnit test framework, but in the unlikely event that a different testing framework doesn't suffer from these problems, I'm open to alternatives. Thanks, Richard