---
name: "Lexer"
section: "3o"
platform: "linux"
package: "ocaml"
version: "5.5.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/Lexer"
---

# Lexer(3o)

The lexical analyzer

## NAME

Lexer - The lexical analyzer

## Module

Module   Lexer

## Documentation

Module **Lexer**\
  :  **sig end**

The lexical analyzer

Warning: this module is unstable and part of **Compiler\_libs** .

*val init* :  **?keyword\_edition:(int \* int) option \* string list -\> unit -\> unit**

*val token* :  **Lexing.lexbuf -\> Parser.token**

*val skip\_hash\_bang* :  **Lexing.lexbuf -\> unit**

*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**

*exception Error* **of** **error \* Location.t**

*val in\_comment* :  **unit -\> bool**

*val in\_string* :  **unit -\> bool**

*val is\_keyword* :  **string -\> bool**

*val print\_warnings* :  **bool ref**

*val handle\_docstrings* :  **bool ref**

*val comments* :  **unit -\> (string \* Location.t) list**

*val token\_with\_comments* :  **Lexing.lexbuf -\> Parser.token**

*val set\_preprocessor* :  **(unit -\> unit) -\>** **((Lexing.lexbuf -\> Parser.token) -\>** **Lexing.lexbuf -\> Parser.token) -\>** **unit**
