Gen.t in Sedlexing

#1

I’ve been migrating my lexer away from ocamllex to Sedlex (to enable lexing of Utf8 files).
However, I’ve seen the stream interface has been deprecated and replaced by from_gen. According to the docs, from_gens signature is char Gen.t -> lexbuf.
In the source, it’s simply a function returning a char option.

Where is the Gen.t type coming from. What is it exactly? Can I open an in_channel as char Gen.t?

0 Likes

#2

Gen.t is a generic iterator provided by the gen library. The Gen.t type is not abstract and is represented as a function unit -> 'a option. So you can either provide your own byte iterator, or use Gen.IO.with_in function.

1 Like

#3

Alright. Got it. I actually found the library, but didn’t realized I should take a look at the dependencies of sedlex, and check whether it depends on it or no. Thanks!

0 Likes