English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Partial parsing
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-07-28 (14:01)
From: Markus Mottl <markus.mottl@g...>
Subject: Re: [Caml-list] Partial parsing
On 7/28/06, Jean-Marie Gaillourdet <jm@gaillourdet.net> wrote:
> You could implement such a feature on top of the existing lexer and
> parser technologies by using thread. Dedicate one thread to the lexer
> and parser, make the input buffer blocking and  make every suitable
> intermediate result available to the main thread.

I'd rather not depend on extra threads for parsing.  Besides of them
making things complicated, in my case I also need to be able to deal
with nonblocking / interruptable input functions.

> But I have not much experience with continuations. And I am not sure
> whether that really fits into the framework of ocamllex/ocamlyacc.

I think it would work well: instead of returning a token stream, the
lexer should return a stream of either matched tokens or
continuations.  The parser would consume the recognized tokens, or
return another continuation that would continue lexing/parsing.

> As Fermin Reig pointed out parser combinators provide that feature
> out of the box. AFAIK, they depend on lazy evaluation. I am not sure
> whether those libraries for OCaml are available to hide that or not.

Sure, implementing some parser combinators might be an option, but I'm
otherwise quite happy with the ease of specification and the high
efficiency of ocamllex/ocamlyacc generated parsers.  It's just that
interrupting and resuming parsing is currently not an option.


Markus Mottl        http://www.ocaml.info        markus.mottl@gmail.com