From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 53448BBAF for ; Thu, 9 Dec 2010 20:29:23 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlEBAMu8AE2AcIhIe2dsb2JhbACVJ45XFQEBFiIFJLc4iGaFSgSEZIkp X-IronPort-AV: E=Sophos;i="4.59,321,1288566000"; d="scan'208";a="70235781" Received: from redflag.cs.princeton.edu ([128.112.136.72]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 09 Dec 2010 20:29:22 +0100 Received: from [192.168.1.100] (ool-4355b7a4.dyn.optonline.net [67.85.183.164]) (authenticated bits=0) by redflag.CS.Princeton.EDU (8.13.8/8.13.8) with ESMTP id oB9JSvV5027656 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT); Thu, 9 Dec 2010 14:29:00 -0500 Subject: Re: [Caml-list] Define parser and printer consistently Mime-Version: 1.0 (Apple Message framework v1082) Content-Type: text/plain; charset=us-ascii From: Yitzhak Mandelbaum In-Reply-To: <4D005F51.8070701@wp.pl> Date: Thu, 9 Dec 2010 14:28:57 -0500 Cc: caml-list Content-Transfer-Encoding: quoted-printable Message-Id: <6E1697F4-8892-4C01-A975-991AC89D5170@cs.princeton.edu> References: <4D005F51.8070701@wp.pl> To: Dawid Toton X-Mailer: Apple Mail (2.1082) X-Proofpoint-Virus-Version: vendor=nai engine=5400 definitions=6192 signatures=654938 X-Proofpoint-Spam-Reason: safe X-Spam: no; 0.00; parser:01 yitzhak:01 mandelbaum:01 tarball:01 parser:01 ocamllex:01 ocamlyacc:01 cheers:01 yitzhak:01 ocaml:01 minimized:01 beginner's:01 ocaml:01 bug:01 mandelbaum:01 PADS/ML can do that for you, and more. You can find information about = the PADS languages and tools here:=20 http://www.padsproj.org including papers and a manual. The website doesn't have the most recent = release of PADS/ML -- i plan to put it up on Github shortly -- but if = you're interested, i'm happy to send you a tarball. The basic idea is that you specify your grammar as a type-like = declaration. Then, pads/ml generates an AST, parser, printer and some = more stuff for you. The generated parser is like a PEG parser, but with = support context-sensitive parsing. That is, it is deterministic, with = ordered choice; and, it is scannerless. So, the grammars-writing style = has some significant differences from ocamllex and ocamlyacc. PADS/ML has an Eclipse license. Cheers, Yitzhak On Dec 8, 2010, at 11:47 PM, Dawid Toton wrote: > 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? >=20 > 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" >=20 > 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. >=20 > Dawid >=20 > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs ----------------------------- Yitzhak Mandelbaum