diff options
author | Chimrod <> | 2023-09-29 09:05:45 +0200 |
---|---|---|
committer | Chimrod <> | 2023-09-29 10:00:21 +0200 |
commit | 5e0b521a2ccce4bd19cf5d08176616f760180c11 (patch) | |
tree | 75319ef16d46f02f0e4057cf44f9d97528d1a994 /lib/lexbuf.ml | |
parent | a5ca18d209e3e85c79c38ea0256e68de19fac91f (diff) |
Made the lexer buffer abstract
Diffstat (limited to 'lib/lexbuf.ml')
-rw-r--r-- | lib/lexbuf.ml | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/lexbuf.ml b/lib/lexbuf.ml new file mode 100644 index 0000000..2ed9099 --- /dev/null +++ b/lib/lexbuf.ml @@ -0,0 +1,14 @@ +type t = Sedlexing.lexbuf + +let buffer : t -> Sedlexing.lexbuf = fun t -> t +let start : t -> unit = fun t -> Sedlexing.start t + +let positions : t -> Lexing.position * Lexing.position = + fun t -> Sedlexing.lexing_positions t + +let content : t -> string = fun t -> Sedlexing.Utf8.lexeme t +let from_lexbuf : Sedlexing.lexbuf -> t = fun t -> t + +let tokenize : (t -> 'a) -> t -> unit -> 'a * Lexing.position * Lexing.position + = + fun f lexbuf -> Sedlexing.with_tokenizer f lexbuf |