Pparse(3)

✨ NAME ✨

Pparse β€” driver for the parser and external preprocessors. That's the name vibe, bestie. πŸ’…


🧚 MODULE 🧚

Module Pparse
 : sig end

Module Pparse is the main character here. 🫢


πŸ’… DOCUMENTATION πŸ’…

Driver for the parser and external preprocessors. πŸ”₯

⚠️ Warning: this module is unstable and part of Compiler_libs. Not me calling it unstable β€” the docs said it first. πŸ’€

The types, exceptions & vals (all of them, no skips) πŸŽ€

Okay so here's the whole cast. Every signature is copied exactly, and I'm not leaving a single one out. ✨

type error =
 | CannotRun of string
 | WrongMagic of string

The error type has two constructors: CannotRun of string and WrongMagic of string. That's it, that's the list. 🧚

exception Error of error β€” an exception named Error that carries an error. 😭

  • val preprocess : string -> string β€” takes a string and returns a string. The docs don't say more, so I'm not gonna invent lore. πŸ™ˆ
  • val remove_preprocessed : string -> unit β€” takes a string, returns unit. Again, that's the signature, periodt.
  • type 'a ast_kind β€” the GADT vibe:
type 'a ast_kind =
 | Structure : Parsetree.structure ast_kind
 | Signature : Parsetree.signature ast_kind

The constructors are Structure (with type Parsetree.structure ast_kind) and Signature (with type Parsetree.signature ast_kind). πŸ¦‹

  • val read_ast : 'a ast_kind -> string -> 'a β€” takes an 'a ast_kind and a string, and returns an 'a. Signature only, bestie. ⭐
  • val write_ast : 'a ast_kind -> string -> 'a -> unit β€” takes an 'a ast_kind, a string, and an 'a, and returns unit. Signature only. πŸ’œ
  • val file : tool_name:string -> string -> (Lexing.lexbuf -> 'a) -> 'a ast_kind -> 'a β€” the full signature is literally that. No cap. πŸŽ€
  • val apply_rewriters : ?restore:bool -> tool_name:string -> 'a ast_kind -> 'a -> 'a β€” if restore = true (the default), cookies set by external rewriters will be kept for later calls. πŸͺ✨
  • val apply_rewriters_str : ?restore:bool -> tool_name:string -> Parsetree.structure -> Parsetree.structure β€” the structure-flavored rewriter call. 🌸
  • val apply_rewriters_sig : ?restore:bool -> tool_name:string -> Parsetree.signature -> Parsetree.signature β€” the signature-flavored rewriter call. 🌈
  • val report_error : error Format_doc.format_printer β€” takes an error and uses a Format_doc.format_printer. πŸ’…
  • val report_error_doc : error Format_doc.printer β€” takes an error and uses a Format_doc.printer. 🫢
  • val parse_implementation : tool_name:string -> string -> Parsetree.structure β€” takes tool_name:string and a string, and gives you a Parsetree.structure. Signature exact. πŸ‘‘
  • val parse_interface : tool_name:string -> string -> Parsetree.signature β€” takes tool_name:string and a string, and gives you a Parsetree.signature. Signature exact. ⭐
  • val call_external_preprocessor : string -> string -> string β€” takes two strings and returns a string. Signature exact. πŸ”₯
  • val open_and_check_magic : string -> string -> in_channel * bool β€” takes two strings and returns in_channel * bool. Signature exact. πŸͺ„

And that's the whole page! This iconic documentation was brought to you by OCamldoc on 2026-06-22, and the manual page is Pparse(3) β€” slay. πŸ’–πŸŽ€

πŸ“¦ where this page comes from