From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id UAA24009; Tue, 28 May 2002 20:48:48 +0200 (MET DST) 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 UAA23807 for ; Tue, 28 May 2002 20:48:47 +0200 (MET DST) Received: from cs.bu.edu (cs.bu.edu [128.197.12.2]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g4SImkT09222; Tue, 28 May 2002 20:48:46 +0200 (MET DST) Received: from csa.bu.edu (zhudp@csa [128.197.12.3]) by cs.bu.edu (8.12.2/8.12.2) with ESMTP id g4SImjF2004659; Tue, 28 May 2002 14:48:45 -0400 (EDT) Received: from localhost (zhudp@localhost) by csa.bu.edu (8.10.1/8.10.1) with ESMTP id g4SImg313952; Tue, 28 May 2002 14:48:42 -0400 (EDT) X-Authentication-Warning: csa.bu.edu: zhudp owned process doing -bs Date: Tue, 28 May 2002 14:48:42 -0400 (EDT) From: dengping zhu X-Sender: zhudp@csa.bu.edu To: Daniel de Rauglaudre cc: Ocaml Subject: Re: [Caml-list] infix precedence In-Reply-To: <20020528203212.B21121@verdot.inria.fr> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk I tried camlp4 before. I got the example from the camlp4 tutorial and modified a little bit. The code is as follows: --------------------------------------------- let gram = Grammar.create (Plexer.make());; let expr = Grammar.Entry.create gram "expr";; EXTEND expr: [ "1" LEFTA [] | "2" LEFTA []]; END;; let add_infix lev op = EXTEND GLOBAL: expr; expr: LEVEL $lev$ [ [ x = expr; $op$; y = expr -> <:expr< $lid:op$ $x$ $y$ >> ] ]; END;; ------------------------------------------------------------------- After I compile it in ocaml # #use "foo.ml";; I can use the function 'add_infix': # add_infix "1" "op1";; But how can I use the infix "op1" later? I tried to use as follows: #let op1 x y = x + y;; #Grammar.Entry.parse expr ( Stream.of_string "x op1 y");; But I got an error. Can someboday pass an example for me? Thanks! On Tue, 28 May 2002, Daniel de Rauglaudre wrote: >Hi, > >On Tue, May 28, 2002 at 02:16:12PM -0400, dengping zhu wrote: > >> Hi, John, thanks for your help. Hope I could solve it today. >> Anyway, I think that Ocaml should support infix as SML. > >Camlp4 > >-- >Daniel de RAUGLAUDRE >daniel.de_rauglaudre@inria.fr >http://cristal.inria.fr/~ddr/ >------------------- >To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr >Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ >Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners