encyclopegia.org

Camlp4

Camlp4 is a software system for writing extensible parsers for programming languages.[src] It provides a set of OCaml libraries that are used to define grammars as well as loadable syntax extensions of such grammars.[src] Camlp4 stands for Caml Preprocessor and Pretty-Printer and one of its most important applications was the definition of domain-specific extensions of the syntax of OCaml.[src] Camlp4 was part of the official OCaml distribution which is developed at the INRIA.[src] Its original author is Daniel de Rauglaudre.[src] OCaml version 3.10.0, released in May 2007, introduced a significantly modified and backward-incompatible version of Camlp4.[src] De Rauglaudre maintains a separate backward-compatible version, which has been renamed Camlp5.[src] All of the examples below are for Camlp5 or the previous version of Camlp4 (versions 3.09 and prior).[src] Version 4.08, released in the summer of 2019, was the last official version of this library.[src] It is currently deprecated; instead, it is recommended to use the PPX (PreProcessor eXtensions) libraries.[src]

Camlp4 is a software system for writing extensible parsers for programming languages.[src] It provides a set of OCaml libraries that are used to define grammars as well as loadable syntax extensions of such grammars.[src] Camlp4 stands for Caml Preprocessor and Pretty-Printer and one of its most important applications was the definition of domain-specific extensions of the syntax of OCaml.[src] Camlp4 was part of the official OCaml distribution which is developed at the INRIA.[src] Its original author is Daniel de Rauglaudre.[src] OCaml version 3.10.0, released in May 2007, introduced a significantly modified and backward-incompatible version of Camlp4.[src] De Rauglaudre maintains a separate backward-compatible version, which has been renamed Camlp5.[src] All of the examples below are for Camlp5 or the previous version of Camlp4 (versions 3.09 and prior).[src] Version 4.08, released in the summer of 2019, was the last official version of this library.[src] It is currently deprecated; instead, it is recommended to use the PPX (PreProcessor eXtensions) libraries.[src] let unique = let n = ref 0 in fun () -> incr n; "__pa_memo" ^ string_of_int !n EXTEND GLOBAL: Pcaml.expr; Pcaml.expr: LEVEL "expr1" [ [ "memo"; OPT "|"; pel = LIST1 match_case SEP "|" -> let tbl = unique () in let x = unique () in let result = unique () in try Hashtbl.find $lid:tbl$ $lid:x$ with [ Not_found -> let $lid:result$ = match $lid:x$ with [ $list:pel$ ] in do { Hashtbl.replace $lid:tbl$ $lid:x$ $lid:result$; $lid:result$ } ] >> ] ]; match_case: [ [ p = Pcaml.patt; w = OPT [ "when"; e = Pcaml.expr -> e ]; "->"; e = Pcaml.expr -> (p, w, e) ] ]; END Example of program using this syntax extension: let counter = ref 0 (* global counter of multiplications *) (* factorial with memoization *) let rec fac = memo 0 -> 1 | n when n > 0 -> (incr counter; n * fac (n - 1)) | _ -> invalid_arg "fac" let run n = let result = fac n in let count = !counter in Printf.printf "%i![src] = %i number of multiplications so far = %i\n" n result count let _ = List.iter run [5; 4; 6] The output of the program is as follows, showing that the fac function (factorial) only computes products that were not computed previously: 5![src] = 120 number of multiplications so far = 5 4![src] = 24 number of multiplications so far = 5 6![src] = 720 number of multiplications so far = 6[src]

25 sentences · 25 cited inline · 0 references stored

References

No reference rows published for this article.

Cite this article

MLA

"Camlp4." encyclopegia.org, 2026, https://encyclopegia.org/wiki/camlp4. Accessed 01 December 2026.

Chicago

"Camlp4." encyclopegia.org. Accessed December 1, 2026. https://encyclopegia.org/wiki/camlp4.

APA

encyclopegia.org. (2026). Camlp4. Retrieved December 1, 2026, from https://encyclopegia.org/wiki/camlp4

Accessed December 1, 2026 · CC BY-SA 4.0 · citation page · JSON

Claims

PredicateValueSource
release date2007Wikipedia
release date2019Wikipedia
CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1372165470 · 0.5 · snapshot enwiki-001372165470

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools
  • Careers — open roles: frontier engineers and sales partners
  • Index — every corpus, paper and record
  • Estate guide — what a public data estate is
  • Founder — Lois-Kleinner Alpasan
  • Records — DOIs and external deposits
  • Documents — one-pagers, PDFs and QR codes
  • Brand kit — logos and share images
  • Papers — plain-language briefs with citations
  • Browser — search engine, PWA and bookmarklet
  • Anticloud — the operator and its projects

As seen in Business Insider · 336 outlets · evidence DOIs · plain-language papers

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.