Re: Stream parsers, again

From: Daniel de Rauglaudre (daniel.de_rauglaudre@inria.fr)
Date: Wed Feb 02 2000 - 16:46:32 MET

  • Next message: Walid Taha: "Re: Partial Evaluation"

    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/
    



    This archive was generated by hypermail 2b29 : Wed Feb 02 2000 - 23:07:21 MET