On Fri, Dec 30, 2005 at 08:54:14PM +0100, Remi Vanicat wrote: > 2005/12/30, Sven Luther <[EMAIL PROTECTED]>: > > 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. > > Well, camlp4 is an official part to ocaml, and will only be used at > compile time, Their is no real reson to avoid it. Furthermore the > stream parser are the lighter
yeah. > > > 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. > > Mmm ? the stream parser (and not the camlp4 Grammar) have a syntaxic > suggar, given by camlp4 : > > [EMAIL PROTECTED]:~$ ocaml > Objective Caml version 3.09.0 > > Findlib has been successfully loaded. Additional directives: > #require "package";; to load a package > #list;; to list the available packages > #camlp4o;; to load camlp4 (standard syntax) > #camlp4r;; to load camlp4 (revised syntax) > #predicates "p,q,...";; to set these predicates > Topfind.reset();; to force that packages will be reloaded > #thread;; to enable threads > > # let p = parser [< ''e' >] -> `E;; > Syntax error > # #camlp4o;; > /usr/lib/ocaml/3.09.0/camlp4: added to search path > /usr/lib/ocaml/3.09.0/camlp4/camlp4o.cma: loaded > Camlp4 Parsing version 3.09.0 > > # let p = parser [< ''e' >] -> `E;; > val p : char Stream.t -> [> `E ] = <fun> > # > > The documentation can be found in the camlp4 documentation I believe: > http://caml.inria.fr/pub/docs/manual-camlp4/manual003.html Oh, that's why i didn't find it in the ocaml manual. Friendly, Sven Luther -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

