From: Jean-Christophe Filliatre <Jean-Christophe.Filliatre@lri.fr>
To: george.russell@clara.co.uk
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Pattern match floats
Date: Mon, 5 Nov 2001 09:27:42 +0100 (MET) [thread overview]
Message-ID: <15334.19838.489926.657755@pc803> (raw)
In-Reply-To: <E15zgO7-000NNA-00@oceanus.uk.clara.net>
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
prev parent reply other threads:[~2001-11-05 8:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-11-02 15:37 George Russell
2001-11-05 8:27 ` Jean-Christophe Filliatre [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=15334.19838.489926.657755@pc803 \
--to=jean-christophe.filliatre@lri.fr \
--cc=caml-list@inria.fr \
--cc=george.russell@clara.co.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox