garrigue / lablgtk

LablGTK 2 and 3: an interface to the GIMP Tool Kit
https://garrigue.github.io/lablgtk
Other
89 stars 40 forks source link

Replace Camlp5 stream parsing with Ocamllex lexers and PMS #139

Closed vrotaru closed 1 year ago

vrotaru commented 2 years ago

Where PMS stands for Poor-Man Streams, not what you may have thought.

What i did is that I've added lexers for varcc|propcc tools, but I'm accessing them not directly, but through a wrapper struct

type t = {
  mutable lookahead: token option;
  lexbuf: Lexing.lexbuf;
}

This gives us the familiar stream operations, next, and peek and that is enough to port the stream parsing code almost verbatim.

Also something which I learned during that exercise is that writing good error messages is hard and tedious.

garrigue commented 2 years ago

What is the goal of this PR ? propcc.ml is a generated file; we do not want to edit it by hand. Stream and Genlex are going to disappear to the standard library, but a replacement package is already available on opam.

vrotaru commented 2 years ago

Well the goal of this is not to replace propcc.ml but propcc.ml4. Obviously. Very few people know and use Camlp4.

But you are the maintainer, so whatever. I was doing something somewhat related and this was a just bit of a challenge.