caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Norman Davis <ndavis@ti.com>
To: caml-list@inria.fr
Subject: Stream parsing - caml light vs. ocaml
Date: Sun, 31 May 1998 22:22:26 -0700	[thread overview]
Message-ID: <BMSMTP8966713870a0384552@dpcmail.itg.ti.com> (raw)

Hello,

I am reading "Functional programming using Caml Light" by Michel Mauny, chapter
10 on Streams and Parsers. The "spaces" function (used to remove the next
continuous segment of whitespace) shown there is : 

# let rec spaces = function 
#   [< '' '|'\t'|'\n'; spaces _ >] -> ()
#|  [< >] -> ();;

I tried converting it to Objective Caml :

# let rec spaces = parser
  [< '' '|'\t'|'\n'; spaces >] -> ()
  | [< >] -> ();;
val spaces : char Stream.t -> unit = <fun>
# let s = Stream.of_string "  ;";;
val s : char Stream.t = <abstr>
# spaces s;;
- : unit = ()
# Stream.next s;;
- : char = ' '
# Stream.next s;;
- : char = ';'

The stream s had two space characters followed by a semicolon.
After "spaces s", I expected "Stream.next s" to return
a semicolon.  What is the correct way to write "spaces" so that it removes all
whitespace from the front of the stream, not just a single whitespace
character.

Thanks.

Norman Davis
ndavis@ti.com





             reply	other threads:[~1998-06-01  9:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-06-01  5:22 Norman Davis [this message]
1998-06-01 10:48 ` Toby Moth

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=BMSMTP8966713870a0384552@dpcmail.itg.ti.com \
    --to=ndavis@ti.com \
    --cc=caml-list@inria.fr \
    /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;
as well as URLs for NNTP newsgroup(s).