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=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 7E129BB84 for ; Sun, 21 Sep 2008 20:47:19 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Al0BAAoz1kiGhogYmmdsb2JhbACTHQEBAQEBCAsKBxGhEIFm X-IronPort-AV: E=Sophos;i="4.32,441,1217800800"; d="scan'208";a="15194530" Received: from mga09.intel.com ([134.134.136.24]) by mail2-smtp-roc.national.inria.fr with ESMTP; 21 Sep 2008 20:47:18 +0200 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 21 Sep 2008 11:43:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.32,441,1217833200"; d="scan'208";a="338841825" Received: from unknown (HELO azsmsx001.amr.corp.intel.com) ([10.2.167.98]) by orsmga002.jf.intel.com with ESMTP; 21 Sep 2008 11:47:07 -0700 Received: from azsmsx501.amr.corp.intel.com ([10.2.167.99]) by azsmsx001.amr.corp.intel.com ([10.2.167.98]) with mapi; Sun, 21 Sep 2008 11:47:16 -0700 From: "Harrison, John R" To: OCaml Cc: "Harrison, John R" Date: Sun, 21 Sep 2008 11:47:15 -0700 Subject: More problems with simple quotation parser Thread-Topic: More problems with simple quotation parser Thread-Index: AckcGndm38FRaa5LTouEhFG9wIY09w== Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Spam: no; 0.00; parser:01 parser:01 camlp:01 camlp:01 expr:01 expr:01 syntax:01 syntax:01 lexical:01 parsing:01 patt:01 patt:01 cma:01 cma:01 variant:02 I've hit another problem with the simple string transformation quotation parser (see my previous message). For the sake of this example, here is a somewhat simplified variant, which I turn into "Quotexpander.cma": open Camlp4.PreCast;; module Caml =3D Camlp4OCamlParser.Make (Camlp4OCamlRevisedParser.Make (Camlp4.OCamlInitSyntax.Make(Ast)(Gram)(Quotation)));; let quotexpander s =3D "\"" ^ String.escaped s ^ "\"";; let patt_quotexpander loc _loc_name_opt str =3D Gram.parse_string Caml.patt loc (quotexpander str);; let expr_quotexpander loc _loc_name_opt str =3D Gram.parse_string Caml.expr loc (quotexpander str);; let str_item_quotexpander loc loc_name_opt str =3D <:str_item@loc< $exp: expr_quotexpander loc loc_name_opt str$ >>;; let () =3D Syntax.Quotation.add "" Syntax.Quotation.DynAst.expr_tag expr_quotexpan= der; Syntax.Quotation.add "" Syntax.Quotation.DynAst.str_item_tag str_item_quotexpander; Syntax.Quotation.add "" Syntax.Quotation.DynAst.patt_tag patt_quotexpan= der;; This doesn't always seem to work properly when quotations are subexpressions of larger expressions. Some of the issues seem to be lexical: Objective Caml version 3.10.0 # #load "camlp4o.cma";; Camlp4 Parsing version 3.10.0 # #load "Quotexpander.cma";; # <>;; - : string =3D "ok" # (<>);; - : string =3D "ok" # [<>];; Parse error: illegal begin of top_phrase # [ <> ];; - : string list =3D ["not ok"] Others I'm not so sure about: # <> ^ <>;; # Parse error: illegal begin of top_phrase # (<>) ^ (<>);; - : string =3D "notok" Any idea what's going on? Do I need to put some kind of wrapping round the transformed phrase? John.