[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: comments searched on bit of ocaml code ...



On Fri, Dec 30, 2005 at 06:48:24PM +0100, Stefano Zacchiroli wrote:
> On Thu, Dec 29, 2005 at 03:32:13PM +0100, Sven Luther wrote:
> > Anyway, it has been a long time since i wrote serious ocaml code, and i have
> > some doubts about the best way to parse strings, preferably using the less
> > non-ocaml stuff, so i post my snipplet here for comments.
> 
> Looking at what you need to do the best way to parse string I can
> suggest you is the combo:
> 
>   Stream.of_string + camlp4's stream parsers

since i use it as ocamlrun ocaml script, i wanted to avoid camlp4, i avoid
camlp4 when i can anyway.

> It is all in the standard ocaml distribution, no need of non-ocaml code,
> no need of extra libraries. Using that kind of streams you basically get
> recursive descendent parsers with backtracking inside the same "parser"
> structure (IIRC).

I found the Stream module, but there is with very very little documentation on
them, and from what i understand they are not compatible with the camlp4
stream parser, and there is no syntactic sugar for them.

I was thinking of replacing my match by a match on the Stream.npeek result,
but i don't think i will gain all that much by it, at least for this part of
the code.

> They are well documented in the ocaml manual. For samples you can look
> at some Gerd's code which uses them to parse configuration files (e.g.
> the findlib one).

Well documented, not in the 3.09 manual i think, but i may have missed
something.

Anyway, linux-2.6 2.6.15-rc7 will be uploaded this night, and it build-depends
on ocaml-interp, and includes a more advanced version of this script :)

Friendly,

Sven Luther





Reply to: