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 nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id A7756BC6C for ; Mon, 12 Sep 2005 15:27:18 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j8CDRIwU011698 for ; Mon, 12 Sep 2005 15:27:18 +0200 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA32663 for ; Mon, 12 Sep 2005 15:27:17 +0200 (MET DST) Received: from mallaury.nerim.net (smtp-101-monday.noc.nerim.net [62.4.17.101]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j8CDRHtk007385 for ; Mon, 12 Sep 2005 15:27:17 +0200 Received: from karryall.dnsalias.org (karryall.dnsalias.org [213.41.180.99]) by mallaury.nerim.net (Postfix) with ESMTP id 86FB94F3C2; Mon, 12 Sep 2005 15:27:08 +0200 (CEST) Received: by karryall.dnsalias.org (Postfix, from userid 500) id C0481596F3C; Mon, 12 Sep 2005 15:27:16 +0200 (CEST) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <17189.33332.99301.539540@karryall.dnsalias.org> Date: Mon, 12 Sep 2005 15:27:16 +0200 From: Olivier Andrieu To: Christophe Raffalli Cc: caml-list Subject: Re: [Caml-list] camlp4 char stream In-Reply-To: <43251497.1090905@univ-savoie.fr> References: <43249158.4070900@univ-savoie.fr> <43251497.1090905@univ-savoie.fr> X-Mailer: VM 7.19 under Emacs 21.4.1 X-Miltered: at nez-perce with ID 43258236.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 43258235.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; andrieu:01 andrieu:01 ijm:01 caml-list:01 char:01 christophe:01 raffalli:01 grammar:01 parser:01 strm:01 npeek:01 strm:01 char:01 lexer:01 lib:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 Christophe Raffalli [Monday 12 September 2005] : > > OK, I found it (quote from your tutorial): > > let operator_rparen = > Grammar.Entry.of_parser gram "operator_rparen" > (fun strm -> > match Stream.npeek 2 strm with > | [("", s); ("", ")")] when is_operator s -> > begin > Stream.junk strm; > Stream.junk strm; > s > end > | _ -> raise Stream.Failure) > > OK, I read your tutorial, but did not get the point ... thks > > and what is the first member of the tuple ? > Why is the second member a string and not a char ? That's just how the camlp4 lexer works, cf. : http://caml.inria.fr/pub/docs/manual-camlp4/manual005.html#toc13 http://caml.inria.fr/pub/docs/manual-camlp4/lib/Plexer.html If I understand, you'd want to switch to a different lexer (and parser) at some point. As Martin said, quotation expanders let you basically do that. But IIRC camlp4 (the program) only expands quotations in expression or pattern levels, not at the structure item level so that won't work for you. But the ocpp program (installed with camlp4) expands quotation in any file (only quotations returning string of course). -- Olivier