From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 6D92ABCAE for ; Fri, 15 Jul 2005 10:39:13 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j6F8dChS023861 for ; Fri, 15 Jul 2005 10:39:12 +0200 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id KAA14592 for ; Fri, 15 Jul 2005 10:39:11 +0200 (MET DST) Received: from mail.rsise.anu.edu.au (mail.rsise.anu.edu.au [150.203.208.4]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j6F8d7C4007482 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Fri, 15 Jul 2005 10:39:10 +0200 Received: from localhost (localhost [127.0.0.1]) by mail.rsise.anu.edu.au (Postfix) with ESMTP id DF5F71E2A0 for ; Fri, 15 Jul 2005 18:39:04 +1000 (EST) Received: from mail.rsise.anu.edu.au ([150.203.208.4]) by localhost (mail [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 19577-10 for ; Fri, 15 Jul 2005 18:39:04 +1000 (EST) Received: from pulp.rsise.anu.edu.au (pulp.rsise.anu.edu.au [150.203.208.49]) by mail.rsise.anu.edu.au (Postfix) with ESMTP id CE6C31D5C7 for ; Fri, 15 Jul 2005 18:39:04 +1000 (EST) Received: by pulp.rsise.anu.edu.au (Postfix, from userid 1560) id A317522973C; Fri, 15 Jul 2005 18:39:01 +1000 (EST) Date: Fri, 15 Jul 2005 18:39:01 +1000 From: Pietro Abate To: ocaml ml Subject: camlp4 help Message-ID: <20050715083901.GA24763@pulp.anu.edu.au> Mail-Followup-To: Pietro Abate , ocaml ml Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Operating-System: GNU/Linux X-Organization: Research School of Information Science and Engineering (Australian National University) User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at mail.rsise.anu.edu.au X-Miltered: at concorde with ID 42D77630.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 42D7762B.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; anu:01 ocaml:01 parser:01 parser:01 grammar:01 pcaml:01 grammar:01 pcaml:01 hashtbl:01 clist:01 iter:01 hashtbl:01 clist:01 syntax:01 anu:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: Hi all, I'm having problems (once again) with camlp4... I'd like to parse and produce a bit of ocaml code out of the following description : --------------------- CONNECTIVES "_&_",AssocLeft,And ; "_v_",AssocLeft,Or END TABLEAU RULE "And" { A & B } ---------- A ; B END END --------------- The first time around I used quotes around the "{A & B}" and parsed the expression with a adhoc parser outside camlp4 (and it's all good and working). Now I want to remove the quotes tut-cur and do everything using the pre-processor (quotes make my code quote un-readable). I've started writing this code below, but I don't know how to proceed... The main problem is of course that I've to parse an expression (in rule), with a generic parser built on the top of the connectives that I've just declared. Is there a way to tell campl4 : pass everything in between RULE and END to a function my_parser ? I was looking for inspiration in M. Jambon excellent tutorial, but without much luck... thanks, p -----------------------(not tested) let rule = Grammar.Entry.create Pcaml.gram "rule";; let connective = Grammar.Entry.create Pcaml.gram "connective";; type assoc = |AssocLeft |AssocRight |AssocNone ;; let conntable = Hashtbl.create 15;; EXTEND Pcaml.str_item: [ "CONNECTIVES"; clist = LIST1 connective SEP ";"; "END" -> List.iter Hashtbl.add conntable clist; <:str_item< value version = "connectives declared" >> |"TABLEAU"; LIST1 rule; "END" -> <:str_item< value version = "tableau declared" >> ]; connective: [ s = STRING; ","; a = UIDENT; ","; r = UIDENT -> (s,a,r) ]; (* how can I write a quotation outside the EXTEND syntax ? *) (* how does this quotation looks like ? *) (* Quotation.add my_parser ??? *) rule: [ "RULE"; r = my_parser ??? "END" -> do_something r ]; END ------------------------ -- ++ Blog: http://blog.rsise.anu.edu.au/?q=pietro ++ ++ "All great truths begin as blasphemies." -George Bernard Shaw ++ Please avoid sending me Word or PowerPoint attachments. See http://www.fsf.org/philosophy/no-word-attachments.html