From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id pBSHNj1T013176 for ; Wed, 28 Dec 2011 18:23:45 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArQCANpP+05KfVK2imdsb2JhbAApGpwCkE8IIgEBAQoJDQcSBiGBcgEBAQQSAiwBGxILAQMMBgULDQ0hIgERAQUBChIGExIQh2AjmDIKi2WCa4RfP4hxAgULg3KIEgSVAo19PYN7 X-IronPort-AV: E=Sophos;i="4.71,422,1320620400"; d="scan'208";a="124915658" Received: from mail-we0-f182.google.com ([74.125.82.182]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 28 Dec 2011 18:23:40 +0100 Received: by mail-we0-f182.google.com with SMTP id b13so10966226wer.27 for ; Wed, 28 Dec 2011 09:23:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=k1m64m2olYEI+aFsvCDB6aFpME78g0pjiIApgTeT640=; b=SAp+J/1f2ae9wpZGYhiKfJHPGsSnT9pBnbIE3RZgXSEVgsE6nSPcipg8/myHq4SgDw ZHD5uYbcRNv7TEb2v4QHsVc55WAQlrrrEvZCU56Hb5TG3avrT+aPy08kWPlBdy26luk4 ZSPWnb6I61OtninLbM1zNR5mEkN7S+1Z7sq2A= Received: by 10.216.137.232 with SMTP id y82mr24387108wei.0.1325093019914; Wed, 28 Dec 2011 09:23:39 -0800 (PST) MIME-Version: 1.0 Received: by 10.227.198.147 with HTTP; Wed, 28 Dec 2011 09:23:18 -0800 (PST) In-Reply-To: <20111228162556.GA2806@annexia.org> References: <20111228162556.GA2806@annexia.org> From: Gabriel Scherer Date: Wed, 28 Dec 2011 18:23:18 +0100 Message-ID: To: "Richard W.M. Jones" Cc: caml-list@inria.fr Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id pBSHNj1T013176 Subject: Re: [Caml-list] Some simple(?) questions about camlp4 <:quotations< ... >> > (1) Is any other syntax available for quotations apart from > <:foo< ... >> and the default quotation expander << ... >>? No. That said, you could implement your own quotations mechanism as a Camlp4 extension (changing the grammar of the language). The benefit of the "official" quotations is that you don't touch the existing OCaml grammar (... of Camlp4). > (2) Is there any way to escape >> inside a quotation. Camlp4 doesn't touch the content of quotations... except that the lexer needs to know when they stop. ">>" is always interpreted as the quotation delimiter, and this is hardcoded in the lexer, so you can't change that. For example escaping with "\>>" would not work. Any non-">>" symbol will be handled by you (that is, the parser you set up for your quotation) and you can do as you wish. For example you could specify to your users that you will always interpret ">\>" as if it was a ">>", providing an escape mechanism. > (3) In a custom-defined quotation expander, does the antiquotation > syntax $bar$ have any special meaning? No, if you have told the lexer that you doesn't want it to lex antiquotations specially. This can be configured through a Camlp4 option.(Camlp4_config.antiquotations). That said, I think antiquotations are very convenient for any DSL (as it allows your users to compose pieces of DSL program using OCaml constructs such let bindings, etc.). If I were you, I would change the DSL syntax to free the $...$ for antiquotations. On Wed, Dec 28, 2011 at 5:25 PM, Richard W.M. Jones wrote: > > I'm writing a mini-DSL that'll use camlp4 quotations.  In general > http://brion.inria.fr/gallium/index.php/Quotation has been very > helpful, but I still have a few questions: > > (1) Is any other syntax available for quotations apart from > <:foo< ... >> and the default quotation expander << ... >>? > > (2) Is there any way to escape >> inside a quotation.  In particular > some of my quotations will contain C code, and >> is a C operator > (right shift).  This is not a show-stopper, but it'd be nice to be > able to offer a way for C code to contain right shifts, in a way that > is easily comprehensible to C programmers. > > (3) In a custom-defined quotation expander, does the antiquotation > syntax $bar$ have any special meaning?  I want to use $variable > substitutions, so if $ is being treated specially this might cause > problems. > > Rich. > > -- > Richard Jones > Red Hat > > -- > Caml-list mailing list.  Subscription management and archives: > https://sympa-roc.inria.fr/wws/info/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs >