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=1.1 required=5.0 tests=AWL,SPF_NEUTRAL 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 80469BC6C for ; Wed, 24 Oct 2007 15:24:14 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAABPkHkfAXQImh2dsb2JhbACOWQEBAQgKKQ X-IronPort-AV: E=Sophos;i="4.21,324,1188770400"; d="scan'208";a="3592246" Received: from discorde.inria.fr ([192.93.2.38]) by mail1-smtp-roc.national.inria.fr with ESMTP; 24 Oct 2007 15:24:14 +0200 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l9ODO9db021044 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Wed, 24 Oct 2007 15:24:14 +0200 X-IronPort-AV: E=Sophos;i="4.21,324,1188770400"; d="scan'208";a="3592245" Received: from peray.inria.fr (HELO ausone.inria.fr) ([128.93.8.98]) by mail1-relais-roc.national.inria.fr with SMTP; 24 Oct 2007 15:24:14 +0200 Received: by ausone.inria.fr (sSMTP sendmail emulation); Wed, _d Oct 2007 15:23:36 +0200 From: "Nicolas Pouillard" Cc: caml-list Subject: Re: [Caml-list] Camlp4 as a universal pre-processor ? To: David Teller References: <1193118873.7228.10.camel@Blefuscu> <1193131952-sup-5002@ausone.inria.fr> <1193135655.6327.2.camel@Blefuscu> In-Reply-To: <1193135655.6327.2.camel@Blefuscu> Date: Wed, 24 Oct 2007 15:23:36 +0200 Message-Id: <1193231889-sup-1511@port-ext2.ensta.fr> User-Agent: Sup/0.1 Content-Type: text/plain; charset=UTF-8 X-j-chkmail-Score: MSGID : 471F4779.000 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 471F4779.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; camlp:01 lambda:01 syntax:01 ocaml:01 expr:01 lambda:01 lexer:01 parser:01 camlp:01 ocpp:01 lexer:01 lexing:01 ocaml:01 parser:01 tokens:01 Excerpts from David Teller's message of Tue Oct 23 12:34:15 +0200 2007: > I've read the Lambda example, but it looked to me like it was a syntax > extension for OCaml and no other language, unless I completely > misunderstand the meaning of, say, <:expr<...>> . You're right the lambda example is not adapted. > Now, do you suggest I should write a full lexer and parser with Camlp4 > just in order to write simple macros ? Hum, in fact that's because ocpp is no longer supported in Camlp4 3.10 (another (external) tool that can replace it is in preparation). However writing a small lexer that catch some quotation of yours is quite simple; but since you where talking about menhir and dypgen they certainly have lexing conventions quite close to OCaml, so the default lexer should suffice. It's mainly about writing a parser that search for some QUOTATION tokens and expand them, in fact it will be even simpler to directly use a stream parser. (* pseudo untested code *) let rec go = parse | [< '(QUOTATION q, _loc); strm >] -> expand q; go strm | [< '(token, _loc); strm >] -> Token. tok; go strm | [< >] -> () > On Tue, 2007-10-23 at 11:39 +0200, Nicolas Pouillard wrote: > > A way to start this is to just keep the lexer and provide a new grammar > > including quotations [2] and antiquotations. On the wiki [1] there is also a > > small but complete example of a grammar for the untyped lambda calculus with > > antiquotations [3], and also a tutorial of making a full parser with Camlp4 [4]. > > > > [1]: http://brion.inria.fr/gallium/index.php/Camlp4 > > [2]: http://brion.inria.fr/gallium/index.php/Quotation > > [3]: http://brion.inria.fr/gallium/index.php/Lambda_calculus_quotations > > [4]: http://brion.inria.fr/gallium/index.php/Full_parser_tutorial -- Nicolas Pouillard aka Ertai