Parser(3)

πŸ’– NAME πŸ’–

okay so bestie, this is the manual page for Parser(3) from the OCaml library β€” manual name folded in right here so we can get straight to the tea. The source literally says no description, which is giving mysterious main character energy, but don't worry: the rest of the page is right below and it has everything. πŸ’…


πŸŽ€ Module πŸŽ€

Module Parser


✨ Documentation ✨

🧚 Module Parser 🧚

The module is declared as Module Parser : sig end. Short, sweet, and very β€œI contain multitudes but my signature is a little mysterious.” 🫢

πŸ¦‹ The token type πŸ¦‹

Here’s the full token guest list β€” every single constructor, no cap, nothing skipped:

type token =
 | WITH
 | WHILE
 | WHEN
 | VIRTUAL
 | VAL
 | UNDERSCORE
 | UIDENT of string
 | TYPE
 | TRY
 | TRUE
 | TO
 | TILDE
 | THEN
 | STRUCT
 | STRING of (string * Location.t * string option)
 | STAR
 | SIG
 | SEMISEMI
 | SEMI
 | RPAREN
 | REC
 | RBRACKET
 | RBRACE
 | QUOTED_STRING_ITEM of (string * Location.t * string * Location.t *
string option)
 | QUOTED_STRING_EXPR of (string * Location.t * string * Location.t *
string option)
 | QUOTE
 | QUESTION
 | PRIVATE
 | PREFIXOP of string
 | PLUSEQ
 | PLUSDOT
 | PLUS
 | PERCENT
 | OR
 | OPTLABEL of string
 | OPEN
 | OF
 | OBJECT
 | NONREC
 | NEW
 | MUTABLE
 | MODULE
 | MINUSGREATER
 | MINUSDOT
 | MINUS
 | METHOD
 | METAOCAML_ESCAPE
 | METAOCAML_BRACKET_OPEN
 | METAOCAML_BRACKET_CLOSE
 | MATCH
 | LPAREN
 | LIDENT of string
 | LETOP of string
 | LET
 | LESSMINUS
 | LESS
 | LBRACKETPERCENTPERCENT
 | LBRACKETPERCENT
 | LBRACKETLESS
 | LBRACKETGREATER
 | LBRACKETBAR
 | LBRACKETATATAT
 | LBRACKETATAT
 | LBRACKETAT
 | LBRACKET
 | LBRACELESS
 | LBRACE
 | LAZY
 | LABEL of string
 | INT of (string * char option)
 | INITIALIZER
 | INHERIT
 | INFIXOP4 of string
 | INFIXOP3 of string
 | INFIXOP2 of string
 | INFIXOP1 of string
 | INFIXOP0 of string
 | INCLUDE
 | IN
 | IF
 | HASHOP of string
 | HASH
 | GREATERRBRACKET
 | GREATERRBRACE
 | GREATER
 | FUNCTOR
 | FUNCTION
 | FUN
 | FOR
 | FLOAT of (string * char option)
 | FALSE
 | EXTERNAL
 | EXCEPTION
 | EQUAL
 | EOL
 | EOF
 | END
 | ELSE
 | EFFECT
 | DOWNTO
 | DOTOP of string
 | DOTDOT
 | DOT
 | DONE
 | DOCSTRING of Docstrings.docstring
 | DO
 | CONSTRAINT
 | COMMENT of (string * Location.t)
 | COMMA
 | COLONGREATER
 | COLONEQUAL
 | COLONCOLON
 | COLON
 | CLASS
 | CHAR of char
 | BEGIN
 | BARRBRACKET
 | BARBAR
 | BAR
 | BANG
 | BACKQUOTE
 | ASSERT
 | AS
 | ANDOP of string
 | AND
 | AMPERSAND
 | AMPERAMPER

πŸ’€ exception Error πŸ’€

Yep, there is an exception, and it is exactly exception Error. The source gives us no extra lore, no dramatic backstory, just the exception itself. Respect. πŸ™ˆ

🌸 Parser functions 🌸

Every one of these takes a lexer function of type (Lexing.lexbuf -> token) plus a Lexing.lexbuf. Here they all are, with their exact return types:

  • use_file β€” gives you back a Parsetree.toplevel_phrase list. Signature: val use_file : (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Parsetree.toplevel_phrase list
  • toplevel_phrase β€” gives you back a single Parsetree.toplevel_phrase. Signature: val toplevel_phrase : (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Parsetree.toplevel_phrase
  • parse_val_longident β€” gives you back a Longident.t. Signature: val parse_val_longident : (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Longident.t
  • parse_pattern β€” gives you back a Parsetree.pattern. Signature: val parse_pattern : (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Parsetree.pattern
  • parse_mty_longident β€” gives you back a Longident.t. Signature: val parse_mty_longident : (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Longident.t
  • parse_module_type β€” gives you back a Parsetree.module_type. Signature: val parse_module_type : (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Parsetree.module_type
  • parse_module_expr β€” gives you back a Parsetree.module_expr. Signature: val parse_module_expr : (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Parsetree.module_expr
  • parse_mod_longident β€” gives you back a Longident.t. Signature: val parse_mod_longident : (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Longident.t
  • parse_mod_ext_longident β€” gives you back a Longident.t. Signature: val parse_mod_ext_longident : (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Longident.t
  • parse_expression β€” gives you back a Parsetree.expression. Signature: val parse_expression : (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Parsetree.expression
  • parse_core_type β€” gives you back a Parsetree.core_type. Signature: val parse_core_type : (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Parsetree.core_type
  • parse_constr_longident β€” gives you back a Longident.t. Signature: val parse_constr_longident : (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Longident.t
  • parse_any_longident β€” gives you back a Longident.t. Signature: val parse_any_longident : (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Longident.t
  • interface β€” gives you back a Parsetree.signature. Signature: val interface : (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Parsetree.signature
  • implementation β€” gives you back a Parsetree.structure. Signature: val implementation : (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Parsetree.structure

🌈 Modules 🌈

  • MenhirInterpreter β€” module MenhirInterpreter : sig end
  • Incremental β€” module Incremental : sig end

and that’s literally the whole page, bestie β€” every token, every signature, every tiny sig end accounted for. πŸŽ€βœ¨

Signed off by OCamldoc, dated 2026-06-22, and this is Parser(3). Slay. πŸ’…πŸ‘‘

πŸ“¦ where this page comes from