caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Pattern match floats
@ 2001-11-02 15:37 George Russell
  2001-11-05  8:27 ` Jean-Christophe Filliatre
  0 siblings, 1 reply; 2+ messages in thread
From: George Russell @ 2001-11-02 15:37 UTC (permalink / raw)
  To: caml-list

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?

Thanks
George

-- 
-------------------
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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] Pattern match floats
  2001-11-02 15:37 [Caml-list] Pattern match floats George Russell
@ 2001-11-05  8:27 ` Jean-Christophe Filliatre
  0 siblings, 0 replies; 2+ messages in thread
From: Jean-Christophe Filliatre @ 2001-11-05  8:27 UTC (permalink / raw)
  To: george.russell; +Cc: caml-list


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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-11-05  8:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-02 15:37 [Caml-list] Pattern match floats George Russell
2001-11-05  8:27 ` Jean-Christophe Filliatre

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).