I am in a beginner’s bind. Indeed, while a beginner, many tools, each unique, have to be learned due to mutual dependencies of the environment. At times, I wish I had a lil’ of help
Right now I can’t compile this program https://github.com/milvi/llc-exemple-ch12. I understand stream parsers where removed from Stdlib/Pervasives. Hence the learning exemple is not self-contained in a fresh install of ocaml.
I am at loss as how to compile with ocamlbuild as “ocamlbuild demo.byte” or using make, since both fail. Can anyone do a PR with the correct packaging, _tags, annotations, dependencies which enables back [< 'Ident s >] syntax ?
In my opinion, it is better not to learn “dead” technologies like camlp4. It is better to focus on the extension points (see the links from this issue: RWO Book - #2852), and sedlex.
Oh, c’mon. Stream parsers and expressions are wonderful, wonderful stuff. Sure I know how to write menhir grammars (and I do when I must) but LL(1) grammars using stream-parsers are 100% sweetness and light! And sure, camlp4 is moribund if not dead; camlp5 is very much alive, and I use
it all the time. Even if we grant that extension-points are great for many uses, they clearly aren’t going to replace stream-parsers/expressions – at least, I’ve seen nobody who can show how they’ll pull that off.
It’s late so I won’t start now, but I’ll have a crack at porting this forward to a modern version of ocaml and camlp5 tomorrow. I doubt it’ll take much work.
You don’t really need the stream parser syntax sugar to write a recursive descent parser by hand.
Also, I don’t see any major difficulty in writing a ppx for the stream parser syntax (with some adjustment). Which kind of obstruction did you have in mind?
On my side (student), the book builds this example on the abstraction alone (of stream parsers). The syntax [< ’ >] is magical in my read yet “I will understand later” if need be. All I care is the syntax sugar that hides the hairy details beyond the scope of a closed and themed exercise. I don’t know of anything else at all, but it is so simple and elegant to use I can follow. At the time it was perhaps embedded with Ocaml compiler and seemed natural to use without further ado. This syntax is actually very light and powerful.
I followed the links but it’s way beyond my level to port the dependencies of this pedagogical example.
Don’t you think it’s cool to revert/travel back in time with git and opam to a state it works ? It’s a time machine . I see old compiler Caml light as an educational compiler with a minimal grammar. While Caml’s history itself is akin to school grades.
If Opam switch 3.10.0 time machine had failed I would have said it is dead technology indeed.
Note 1: Wow, at this moment, to each question containing the magic word camlp4 (on discord, so, #caml …) the answer is, more or less, f *** you. Hard times …
Anyway, if it helps, we can use OCaml 4.08.0 and camlp5
$ opam install camlp5
As suggested by @nojb, create a _tags file containing the only line
Note 2: Je voudrais simplement dire que ce livre est un modèle du genre, l’un des meilleurs en français sans doute. Difficilement critiquable techniquement (on a affaire au Big Boss XL, là) et superbement écrit (merci Pierre Weis je suppose).
Lire un bouquin technique comme on lit un roman est un plaisir extrêmement rare.
Un autre livre grandiose est “Programmation fonctionnelle, générique et objet” de Philippe Narbel (épuisé - dispo sur libgen). Les seuls Modules/Foncteurs occupent 164 pages… Et le livre date de 2005 !
Imaginons des versions récentes de ces deux livres!
Very true. But I’ve written parsers for decades using the stream-parser syntax, and it is clear to me that it makes writing them much, much, much more labor-efficient
I’m not trying to argue against this PPX stuff, and sure, if somebody produces something as usable as stream-parsers, I’ll try it out. But I haven’t seen it yet, and I’ve been using stream-parsers since long before camlp4 (used to be called “chamau”) existed.
OK, it wasn’t very hard to write a bare makefile and modify the sources (b/c String and Bytes are no longer the same) to get it working (I tested with “A=>A”). Here’s a git repo; let me know when I can delete it?
Oh, forgot:I replaced an accented “Equialen” with the US-ASCII version. I’ve never messed-around with non-ascii code. Maybe it works, and sure I guess I could look it up, but … easier to just switch to ASCII.
@nojb , @spop true: pp(camlp5o), unsafe_string
it works like a charm.
@Chet_Murthy, I cloned the repo, it works seamlessly, like anew.
Thanks for the patches everyone
@spop Mais carrément ! Quelle lecture facile, du moins, tant qu’il nous tient la main ! Et il nous emmène partout partout.
Je n’aurais pas découvert Narbel sans cette mention, merci.