Questions tagged [camlp4]

CamlP4 is a parsing and pretty-printing framework for Objective Caml, often used as a preprocessor to extend OCaml syntax.

Camlp4 is a set of Objective Caml () libraries and tools for writing parsers and pretty-printers. Its most important use is to write extensions to the OCaml syntax.

The Objective Caml distribution includes CamlP4 since version 3.10.

There is also a separately-distributed CamlP5, which was called CamlP4 up to version 3.09.

65 questions
2
votes
1 answer

The best practice to patch camlp4?

Commit patches and wait for INRIA to merge takes a long time and my work was always delayed. So I made a branch of camlp4.But everytime I made a little change, I need to make the whole compiler, it takes a long time. What's your best practice?…
bobzhang
  • 1,771
  • 3
  • 17
  • 19
2
votes
1 answer

OCamlbuild and camlp4.macro

I have a project where several of the OCaml source files use IFDEF. Is there a simple way to tell OCamlbuild that all .ml files for this project should be preprocessed by camlp4.macro?
Jon Smark
  • 2,528
  • 24
  • 31
1
vote
2 answers

Is it possible to write a camlp4 syntax extension that gives you access to the last let binding as a string?

I've got some code like this: type boolean = T | F type bexp = Const of boolean | Var of variable | Bop of bop * bexp * bexp | Not of bexp and bop = And | Or | Xor and variable = { name: string; mutable value: boolean } Later on…
aneccodeal
  • 8,531
  • 7
  • 45
  • 74
1
vote
1 answer

Cannot use backticks in term names as backtick quotes are being used by camlp5 (OCaml)

I'm using the Yojson library and one of the constructors used is called `Bool (with a backtick). I'm working with OCaml source where camlp5 is used so that text surrounded by backticks is interpreted differently (e.g. the text is converted to an…
maltbar
  • 99
  • 1
  • 5
1
vote
1 answer

In Ocaml Camlp5 is not installing (and it is necessary to use Quotations)

In Ocaml 4, I have to use the Quotation module, on its Quotation.add and Quotation.ExStr functions. It seems I have to install the Camlp5 library (seems to be a preprocessor) to do so. Found lots of info about Camlp, like: Camlp5:…
Theo Deep
  • 666
  • 4
  • 15
1
vote
2 answers

OCaml: returning a function from the function identifier only

I am writing a program which parses scripts written in some made-up language and does some computations using that script. This language has a particular construct which is used to call external OCaml functions of the type 'a -> bool. So, in the…
Surikator
  • 1,463
  • 9
  • 26
1
vote
0 answers

utop no longer supporting camlp4?

I wanted to use a package which has some camlp4 extensions in utop, but I get: utop # #camlp4o;; utop was built without camlp4 support. This is with utop version 2.0.1 and OCaml 4.05.0. I installed utop with opam. Is there a way to rebuild utop…
aneccodeal
  • 8,531
  • 7
  • 45
  • 74
1
vote
3 answers

Lexer/filter for comments

Is there an OCaml tool that allows filtering comments in source files, similar to gcc -E? Ideally, I'm looking for something that will remove everything but comments, but the other way around would also be useful. For instance, if there is a way to…
anol
  • 8,264
  • 3
  • 34
  • 78
1
vote
1 answer

How do I use camlp4 in an OCaml program to parse another OCaml program into an AST?

I'm currently trying to translate OCaml programs (with a fairly standard/limited grammar) into Racket, and I'm trying to see if there is a way to do the parsing to intermediate representation using camlp4. I tried to build a lexer and parser using…
podington
  • 179
  • 1
  • 8
1
vote
2 answers

OCaml overload numeric literal with Camlp4

I am writing a small script with some combinatorics utilities. When I need a numeric literal like 0 or 1 in a different type, I use _0 and _1, but this solution is less than ideal. Is it possible to use Camlp4 to reinterpret numeric literals within…
Greg Nisbet
  • 6,710
  • 3
  • 25
  • 65
1
vote
1 answer

How to review code generated by camlp4

I'm using a syntax extension and would like to know if it's possible to output the generated code in some way. I would rather avoid putting debug traces in the extension since I'm not the developer and doesn't know anything to camlp4.
Antoine
  • 1,782
  • 1
  • 14
  • 32
1
vote
1 answer

Compiling with ocamlbuild and camlp5

I am trying to make a project I am working on compile with ocamlbuild, in order to avoid the use of a regular Makefile, which I find to be slightly more complicated. Specifically, I have a syntax extension file (extend.ml), which I need to be…
michalis-
  • 38
  • 1
  • 7
1
vote
1 answer

replace camlp4 with camlp5 in utop

I'm working with OCaml code that needs camlp5; however, the toplevel (I'm using utop) automatically loads the newer, incompatible camlp4. These are the startup messages: Findlib has been successfully loaded. Additional directives: #require…
jules
  • 1,897
  • 2
  • 16
  • 19
1
vote
2 answers

camlp4o is not a bytecode executable file (error on osx)

I had ocaml 3.12, didn't used for a year and now upgraded to 4.03 from git (compiled myself). I saw some comments on the internet that this version does not include camlp4o, mine is from 2010 when i didn't even had ocaml installed. The problem is…
Cristi Băluță
  • 1,295
  • 15
  • 27
1
vote
2 answers

How can I see the result Camlp4's preprocessing?

I'm using the Sexplib syntax extension in a file called module.ml, and I would like to see the code that is fed into the compiler after the Camlp4 preprocessing. Is there an easy way to do this using ocamlfind or do I have to invoke camlp4 directly…
Jon Smark
  • 2,528
  • 24
  • 31