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 JAA08512; Mon, 5 Nov 2001 09:27:44 +0100 (MET) 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 JAA08547 for ; Mon, 5 Nov 2001 09:27:43 +0100 (MET) Received: from ext.lri.fr (ext.lri.fr [129.175.15.4]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id fA58RgX10389 for ; Mon, 5 Nov 2001 09:27:42 +0100 (MET) Received: from pc803.lri.fr (IDENT:root@pc803 [129.175.8.114]) by ext.lri.fr (8.11.6/jtpda-5.3.2) with ESMTP id fA58Rfb14036 ; Mon, 5 Nov 2001 09:27:42 +0100 (MET) Received: by pc803.lri.fr (8.9.3/feuille) id JAA26698 ; Mon, 5 Nov 2001 09:27:42 +0100 X-Authentication-Warning: localhost.localdomain: filliatr set sender to filliatr@pc803 using -f From: Jean-Christophe Filliatre MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15334.19838.489926.657755@pc803> Date: Mon, 5 Nov 2001 09:27:42 +0100 (MET) To: george.russell@clara.co.uk Cc: caml-list@inria.fr Subject: Re: [Caml-list] Pattern match floats In-Reply-To: References: X-Mailer: VM 6.49 under Emacs 20.4.1 Reply-To: Jean-Christophe.Filliatre@lri.fr (Jean-Christophe Filliatre) Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk George Russell writes: > I am working through the OReilly book and have got as far as working on > the little basic interpreter. I Am adding support for float type > variables, and am trying to modify the lexer. > > I would like to be able to match ('0'..'9')*'.'('0'..'9')* i.e. one or > more digits, a period, followed bt one or more digits. > > I can't see how to do this in OCaml patter matching? Any ideas? In ocamllex, such a regular expression is written ['0'-'9']* '.' ['0'-'9']* { your action, probably using (float_of_string (lexeme lexbuf) } Another remark: you write "one or more digits" but you are using the star operation i.e. "zero, one or more digits". Hope this helps, -- Jean-Christophe Filliatre (http://www.lri.fr/~filliatr) ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr