Version française
Home     About     Download     Resources     Contact us    
Browse thread
Stream parsers, again
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Daniel de Rauglaudre <daniel.de_rauglaudre@i...>
Subject: Re: Stream parsers, again
Hello,

On Tue, Feb 01, 2000 at 11:19:18AM +0900, Frank A. Christoph wrote:

> let count = parser bp [< >] -> bp

This function already exists: "Stream.count".

>   parser [< e = p; i = count; e' = p' ? err i >] -> ...
> 
> BTW, it is nice that the error expression is itself lazily evaluated.

If you got the name of the stream (i.e. "strm"), you can also use:

   parser [< e = p; e' = p' ? err (Stream.count strm) >] -> ...

> I think it is too restrictive that it needs to return a string
> rather than an arbitrary type

Mmm... Remember that polymorphic exceptions are impossible in Caml.
Your solution:

>   exception Err of int
>   let err cnt = raise (Err cnt)

... is the good one.

-- 
Daniel de RAUGLAUDRE
daniel.de_rauglaudre@inria.fr
http://cristal.inria.fr/~ddr/