Lexer(3)
π Lexer(3) π
okay so bestie, welcome to Lexer(3) from the OCaml library β the page for the lexical analyzer. Yes, the manual name is literally Lexer(3), and we are reading it together like the iconic little docs nerds we are. π«Άβ¨
πΈ NAME πΈ
Lexer β the lexical analyzer. That's the name, that's the vibe, periodt. π
π§ Module π§
Module Lexer β and the signature is right here:
Module Lexer
: sig end
β¨ Documentation β¨
Module Lexer : sig end shows up again in the docs, because of course it does. Then comes the sentence The lexical analyzer β main character energy, honestly. π
Warning: this module is unstable and part of Compiler_libs .
Not me being dramatic β that's literally the warning. π
Here are the values, in order, no skipping:
val init : ?keyword_edition:(int * int) option * string list -> unit -> unitβ theinitsignature, exactly as written. Keep the?keyword_editionbits and the double-> unit -> unitenergy. β¨val token : Lexing.lexbuf -> Parser.tokenβ takes aLexing.lexbuf, gives you aParser.token.val skip_hash_bang : Lexing.lexbuf -> unitβ takes aLexing.lexbufand returnsunit. The name saysskip_hash_bang, and we are respectfully not adding extra lore. π
Then we hit type error =, and every single constructor is here, bestie:
type error =
| Illegal_character of char
| Illegal_escape of string * string option
| Reserved_sequence of string * string option
| Unterminated_comment of Location.t
| Unterminated_string
| Unterminated_string_in_comment of Location.t * Location.t
| Empty_character_literal
| Keyword_as_label of string
| Capitalized_label of string
| Invalid_literal of string
| Invalid_directive of string * string option
| Invalid_encoding of string
| Invalid_char_in_ident of Uchar.t
| Non_lowercase_delimiter of string
| Capitalized_raw_identifier of string
| Unknown_keyword of string
And it comes with this exception, exactly:
exception Error of error * Location.t
More values, keep scrolling bestie:
val in_comment : unit -> boolβ takesunit, returns abool, so it's giving yes/no energy. πval in_string : unit -> boolβ same shape:unit -> bool. Literally namedin_string, no notes. π¦val is_keyword : string -> boolβ string goes in,boolcomes out.val print_warnings : bool refβ abool ref, so it's a mutable flag moment. π₯val handle_docstrings : bool refβ anotherbool ref, same exact shape. πΈval comments : unit -> (string * Location.t) listβ returns a list of(string * Location.t), exactly. πval token_with_comments : Lexing.lexbuf -> Parser.tokenβLexing.lexbuftoParser.token, with the exacttoken_with_commentssignature. βval set_preprocessor : (unit -> unit) -> ((Lexing.lexbuf -> Parser.token) -> Lexing.lexbuf -> Parser.token) -> unitβ the long iconic one, with those exact function types andunitat the end. Slay. π
okay that's the whole page, bestie. Footer cuteness, signed off: OCamldoc, 2026-06-22, Lexer(3). Mwah πβ¨
π¦ where this page comes from
- arch rolling: ocaml 5.5.0-1 Β· LGPL2.1 AND custom: QPL-1.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms