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
4
votes
1 answer

Preprocessing error in code comments

I got this error when compiling my code with corebuild: ~/project $ corebuild debug.byte ocamlfind ocamldep -syntax camlp4o -package bin_prot.syntax -package sexplib.syntax,comparelib.syntax,fieldslib.syntax,variantslib.syntax -package core -modules…
Jason Yeo
  • 3,602
  • 3
  • 30
  • 38
4
votes
2 answers

camlp4 syntax extension, parser error

I created a syntax extension that allow the definition of a type as type.yjson type_name { /* type_declaration */ } to be able to build a record value directly from a json file. The syntax extension insert a module and the function necessary to…
Marc Simon
  • 5,415
  • 1
  • 19
  • 21
3
votes
2 answers

combining camlp4 and camlp5 in -pp string for ocamlopt?

I want to combine BOLT, SEXP and ocamlViz for a large project. The problem is, that SEXP and BOLT are using CamlP4 and ocamlviz is using camlp5. But how could I combine the calls to one chain for the -pp argument of ocamlc/ocamlopt? Here is my call…
Andreas Romeyke
  • 333
  • 2
  • 8
3
votes
1 answer

How does Camlp5 (former Camlp4) parse expressions

As far as I could figure it out by searching in the Internet, it looks like that Camlp5 (former Camlp4) uses a recursive-descent parser, while ocamlyacc is an LALR-based parser generator. In an LALR parser generator, priority and associativity is…
Wickoo
  • 6,745
  • 5
  • 32
  • 45
3
votes
1 answer

Code generation for dealing with matches on regular tree-like structures?

I 'm developing a specialized quad tree for doing some bioinformatics. The types for the qtree are: type base = A | C | G | T | ROOT ;; type quad_tree = Nd of bases * quad_tree * quad_tree * quad_tree * quad_tree | Empty …
aneccodeal
  • 8,531
  • 7
  • 45
  • 74
3
votes
1 answer

Passing options to camlp4 with ocamlbuild

I'm using ocamlbuild's native support for ocamlfind to simplify my project's build process. File foo.ml relies on conditional compilation using camlp4's macros. The _tags file contains the following: : package(camlp4.macro),…
Jon Smark
  • 2,528
  • 24
  • 31
2
votes
2 answers

camp4: How to match Ast.TySum to retrieve Ast.TyOr

I'm new with ocamlp4. I'm reading Jake Donham's blog to get started with it. I'm trying to write a small CamlP4 program wich will get a simple type as: type t = Foo | Bar | Baz and generate a t_of_string and a t_to_string function. Following the…
Marc Simon
  • 5,415
  • 1
  • 19
  • 21
2
votes
1 answer

Creating a simple camlp4 grammar extension

Given this type: type 'a variable = { name: string; mutable value: 'a } I'm trying to create a syntax extension that would accept this syntax: var foo = true ...and convert it to: let foo = { name = "foo"; value = true } Here's my attempt: open…
aneccodeal
  • 8,531
  • 7
  • 45
  • 74
2
votes
1 answer

CAML query throwing SoapServerException

This is the exception: Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown. Here's the CAML code:
Fabio Milheiro
  • 8,100
  • 17
  • 57
  • 96
2
votes
0 answers

camlp5: how to nest antiquotations

I am using camlp5 with the MLast module. I would like to know the syntax for antiquotations of nesting depth greater than 1. I'll explain with a mock example. Suppose I have let f1 e = <:expr< 3 * $e$ >> let f2 e = <:expr< $e$ + 1 >> let f3 e =…
kne
  • 1,398
  • 7
  • 12
2
votes
1 answer

Use Camlp4 to parse a string of universal and existential quantifiers

I am using Camlp4 to parse a string of quantifiers in which quantification keywords and variables are separated by comma. One example is like below: exists x,y,z, forall a,b, exists h,k Here, exists and forall are keywords, x,y,z,a,b,h,k are…
Trung Ta
  • 1,582
  • 1
  • 16
  • 25
2
votes
1 answer

making OPAM work with system compiler under MacOS X

I am trying to do a very basic installation of OPAM under MacOS. Using macports I've installed following packages: opam @1.2.0 ocaml-findlib @1.5.5 ocaml-camlp4 @4.02.0.1_1 when I did opam init (not as root, since I only need it for one…
krokodil
  • 1,326
  • 10
  • 18
2
votes
2 answers

OCaml - preprocessing with type information

I want to pre-process an OCaml snippet and make some modifications on the snippet, based on the type of certain expressions. For example, if the snippet has: (f [1;2;3]) I would add another parameter to f like: (f [1;2;3] [[0]]) . But if I see…
Saswat Padhi
  • 6,044
  • 4
  • 20
  • 25
2
votes
1 answer

How do i compile something with Pgocaml

I'm trying to use Pgocaml for database interactions within my application. This is the file I'm trying to compile: let () = let dbh = PGOCaml.connect () in let insert name salary email = PGSQL(dbh) "insert into employees (name, salary,…
Lilluda 5
  • 1,111
  • 3
  • 18
  • 38
2
votes
1 answer

Using OCaml syntax extension in Camlp4 with ocamlbuild

I am having an issue with using the deriving-ocsigen syntax extension in my camlp4 parser. My parser is called pa_debug.ml Here's the tags file: : pp(camlp4orf.opt), package(deriving-ocsigen.syntax), syntax(camlp4o) When compiled…
Jason Yeo
  • 3,602
  • 3
  • 30
  • 38