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 mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 15BC7BBAF for ; Thu, 9 Dec 2010 05:47:18 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsAABPu/0zUTWUIi2dsb2JhbACDV6ASFgEBCgsKBw8GJa8/kGKBIYM1cwSNeQ X-IronPort-AV: E=Sophos;i="4.59,319,1288566000"; d="scan'208";a="91865187" Received: from mx4.wp.pl ([212.77.101.8]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 09 Dec 2010 05:47:16 +0100 Received: (wp-smtpd smtp.wp.pl 6118 invoked from network); 9 Dec 2010 05:47:15 +0100 Received: from 18-161.2-0.pl (HELO [192.168.1.100]) (d0@[91.189.18.161]) (envelope-sender ) by smtp.wp.pl (WP-SMTPD) with AES256-SHA encrypted SMTP for ; 9 Dec 2010 05:47:15 +0100 Message-ID: <4D005F51.8070701@wp.pl> Date: Thu, 09 Dec 2010 05:47:13 +0100 From: Dawid Toton User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.15) Gecko/20101027 Thunderbird/3.0.10 MIME-Version: 1.0 To: caml-list Subject: Define parser and printer consistently Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-WP-AV: skaner antywirusowy poczty Wirtualnej Polski S. A. X-WP-SPAM: NO 0000000 [sTOk] X-Spam: no; 0.00; parser:01 parser:01 ocaml:01 minimized:01 grammar:02 define:02 define:02 construct:02 inconsistent:05 usual:06 function:08 function:08 i'm:09 i'm:09 avoiding:10 I'm going to define a parser and a printer for a simple grammar. Is there a way to define both of them in a single construct using some existing OCaml tool? For example, I have a keyword "function". The usual parser would contain a mapping like: "function" -> `Function and the straightforward printer would do: `Function -> "function" What is the best way to combine these definitions, so that duplication would be minimized? To be precise, avoiding duplication is not exactly what I need. I'm looking for something that would prevent making inconsistent changes to the parser and the printer. Dawid