[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 1998-06-01 (09:42) |
From: | Norman Davis <ndavis@t...> |
Subject: | Stream parsing - caml light vs. ocaml |
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