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 BAA20634; Sat, 7 Sep 2002 01:40:18 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 BAA20459 for ; Sat, 7 Sep 2002 01:40:17 +0200 (MET DST) Received: from hirsch.in-berlin.de (hirsch.in-berlin.de [192.109.42.6]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g86Ne8906382; Sat, 7 Sep 2002 01:40:10 +0200 (MET DST) Received: from hirsch.in-berlin.de (localhost [127.0.0.1]) by hirsch.in-berlin.de (8.12.1/8.12.1/Debian -2) with ESMTP id g86Ne592021021 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NOT); Sat, 7 Sep 2002 01:40:05 +0200 Received: (from uucp@localhost) by hirsch.in-berlin.de (8.12.1/8.12.1/Debian -2) with UUCP id g86Ne2cW021000; Sat, 7 Sep 2002 01:40:02 +0200 X-Envelope-From: oliver@first.in-berlin.de X-Envelope-To: caml-list@inria.fr Received: from localhost (oliver@localhost) by first.in-berlin.de (8.7.6/8.7.3) with SMTP id BAA00373; Sat, 7 Sep 2002 01:10:53 +0200 Date: Sat, 7 Sep 2002 01:10:53 +0200 (MET DST) From: Oliver Bandel To: Daniel de Rauglaudre cc: caml-list@inria.fr Subject: Re: [Caml-list] Camlp4-tutorial-Example In-Reply-To: <20020903090842.B30173@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 Hi, I started again with reading the Camlp4-tutorial. I now see more clear here. On Tue, 3 Sep 2002, Daniel de Rauglaudre wrote: > Hi, > > On Mon, Sep 02, 2002 at 10:52:27PM +0200, Oliver Bandel wrote: > > > What I do not understand: > > This calculator knows that * and / have higher Priority > > than + and -. > > How is this achieved? > > By the order of the rules. The rules with same priority are grouped > together: > [ ... | ... | ... ] > > and there is another level of parentheses (of bracket parentheses) > separated by vertical bars to indicate the priority: > [ > [ ... | ... | ... ] (* lowest priority *) > | [ ... | ... | ... ] ... > | [ ... | ... | ... ] (* highest priority *) > ] If you would add this to the tutorial, this would be very helpful for people, first reading it. Another question: As far as I see, an expression in the Used Grammar/Plexer combination needs to give back *one* certain type. In the examples until page 13 it's always an int, was is returned back after parsing. What, if I need a string? Yes, i've seen that it is possible to get back functions that, if applied, will give the resulting int. But a) it's again int and b) all functions have same type. What if I need a function that returns back a string? Or do I have to look at it in other ways? Well, in Ocaml (it's big plus) it's necessary to have correct types in the program, so if I want to get back int as well as string, I may define a type type myresult = Int of int | String of string Is this a way, you can recommend? Ciao, Oliver P.S.: I looked at the example with List.assoc on page 11 and 12. I think that's a way to implement own variables of a simple language. Very easy, and again surprising. (Here again: how to use string-variables in a language to implement?) ------------------- 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