GithubHelp home page GithubHelp logo

camlp4's Introduction

camlp4

Camlp4 was a software system for writing extensible parsers for programming languages. Since August 2019, Camlp4 is no longer actively maintained and the last release to support all OCaml language features was 4.08.

Later releases will try to keep camlp4 buildable, by supporting new OCaml AST but not new syntax constructions, which means camlp4 will be able to parse only OCaml language up to 4.08. Rationale: existing code using camlp4 will still be buildable, but no new code should be written with camlp4.

Maintainers of Camlp4-using projects are encouraged to switch to other systems:

  • For new projects or actively-moving projects, we recommend adopting ppx attributes and extensions, which is now the preferred way to perform AST transformations on OCaml programs.

  • For slow-moving projects or users of other Camlp4 features (extensible grammars), switching to the (maintained) Camlp5 variant of the preprocessor should be easy.

Building from git

Camlp4 branches try to follow OCaml ones. To build with the trunk of OCaml, you need to use the trunk branch of Camlp4. To build for a specific version, for instance 4.02.1, use the 4.02 branch of Camlp4.

Updating to new OCaml version checklist

  1. Update code :)
  2. Update camlp4_version in configure
  3. Update version field in opam file
  4. Update CI to use new version (TBD currently there is travis but it is not working)
  5. Branch and tag to match previous versions

camlp4's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

camlp4's Issues

Packages don't know about camlp4 dependency in 4.02

I think this is a general issue, though I hit the issue when trying to build core_kernel. Basically, every package that uses camlp4 now needs a camlp4 dependency when building on 4.02, but they don't seem to have it. So, you get errors like "# ocamlfind: Package `camlp4.extend' not found".

For 4.02 the dependency is necessary, and for 4.01 and earlier, it's automatically satisfied. Maybe we should have a virtual camlp4 package that's always there for 4.01 and earlier, and then we can just have all these libraries add an explicit camlp4 dependency.

Cannot compile camlp4

With ocaml version 4.02.0+dev3-2013-12-19, I cannot compile the current head of camlp4.
The error in make all is the following:
File "camlp4/boot/Camlp4.ml", line 15824, characters 24-204:
Error: Some record fields are undefined: pmd_loc

segfault with camlp4 on 4.02dev+trunk

On Ubuntu Trusty (but not MacOS X), I get this reproducibly on two machines with camlp4/ocaml 4.02 trunk as of this morning:

$ ocamlc.opt -version
4.02.0+dev5-2014-04-29
$ ocamlc.opt -c -pp 'camlp4o' t.ml 
Segmentation fault
$ cat t.ml 
let fn s = parser [< >] -> l
$ camlp4o -printer o t.ml > t2.ml
$ ocamlc.opt -c t2.ml 
File "t2.ml", line 1, characters 33-34:
Error: Unbound value l

(You can also grep for 'Segmentation fault' in https://github.com/avsm/opam-bulk-logs to find more instances, but this is the smallest repro case I could get.

Camlp4_config.ml should depend on arguments given to ./configure

It seems that camlp4 libraries cannot be installed in a non standard location.

Using ./configure --libdir โ€ฆ enables to install the various camlp4 libraries in a non standard directory. However, running camlp4 to compile some programs results in dynamic loading errors (e.g., file Camlp4OCamlRevisedParser.cmo not found in path).

Indeed the path in wrong: stdlib/camlp4 rather than the actual location of the library (the one given to ./configure).

Loc.to_string: bad support for multiple lines (Mantis 4598)

Transferred from http://caml.inria.fr/mantis/view.php?id=4598

When the location extends several lines, the format used by Loc.to_string is not compatible with the way Emacs parses locations, it should be of the form

  File "xxx", line 12-13, characters 34-23:

The following code maybe shows better what I mean

  let (fname, line0, bol0, off0, line1, bol1, off1, _) = Loc.to_tuple loc in
  let line =
    if line0 = line1 then sprintf "%i" line0
    else sprintf "%i-%i" line0 line1 in
  sprintf "File \"%s\", line %s, characters %i-%i"
    fname line (off0 - bol0) (off1 - bol1)

is the camlp4 Make parallel-clean?

It wasn't previously in the compiler tree, and manual tests seem to indicate that it's ok, but I thought I'd check to see if it's intended to be used with make -j 12 or similar

./check-camlp4.sh: line 3: camlp4orf: command not found

Installed ocaml 4.02.1 from homebrew, no camlp4orf found.

objective-caml: stable 4.02.1 (bottled), HEAD
http://ocaml.org
/usr/local/Cellar/objective-caml/4.02.1 (788 files, 75M) *
  Poured from bottle
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/objective-caml.rb
==> Options
--without-x11
    Build without x11 support
--HEAD
    install HEAD version

There are only

ocaml             ocamlbuild.native ocamlcp           ocamldep.opt      ocamllex          ocamlmktop        ocamlopt.opt      ocamlrun
ocamlbuild        ocamlc            ocamldebug        ocamldoc          ocamllex.opt      ocamlobjinfo      ocamloptp         ocamlrund
ocamlbuild.byte   ocamlc.opt        ocamldep          ocamldoc.opt      ocamlmklib        ocamlopt          ocamlprof         ocamlyacc

-no-ocamlfind should be used automatically

The camlp4 Makefile should not assume that ocamlfind is present.
I think the configure script should detect if ocamlfind is present, and if not, cause the Makefile to pass -no-ocamlfind to ocamlbuild.

camlp4's broken after the open_types merge

/cc @lpw25

# Error: This expression has type
#          (string Location.loc option * Asttypes.variance) list
#        but an expression was expected of type
#          (Parsetree.core_type * Asttypes.variance) list
#        Type string Location.loc option is not compatible with type
#          Parsetree.core_type 
# Command exited with code 2.

ocplib-endian doesnt build with 4.02 camlp4

===== ERROR while installing ocplib-endian.0.4 =====
# opam-version         1.1.1
# os                   linux
# command              ocaml setup.ml -build
# path                 /home/opam/.opam/4.02.0dev+trunk/build/ocplib-endian.0.4
# compiler             4.02.0dev+trunk
# exit-code            1
# env-file             /home/opam/.opam/4.02.0dev+trunk/build/ocplib-endian.0.4/ocplib-endian-2694-d8a4ae.env
# stdout-file          /home/opam/.opam/4.02.0dev+trunk/build/ocplib-endian.0.4/ocplib-endian-2694-d8a4ae.out
# stderr-file          /home/opam/.opam/4.02.0dev+trunk/build/ocplib-endian.0.4/ocplib-endian-2694-d8a4ae.err
### stdout ###
# ...[truncated]
# ocamlfind ocamlc -c -package optcomp -package bigarray -I src -o src/endianString.cmi src/endianString.mli
# ocamlfind ocamldep -package optcomp -package camlp4 -package bigarray -syntax camlp4o -modules src/endianString.ml > src/endianString.ml.depends
# + ocamlfind ocamldep -package optcomp -package camlp4 -package bigarray -syntax camlp4o -modules src/endianString.ml > src/endianString.ml.depends
# File "src/common.ml", line 19, characters 35-36:
# Parse error: [semi] expected after [str_item] (in [implem])
# File "src/endianString.ml", line 1:
# Error: Error while running external preprocessor
# Command line: camlp4 '-I' '/home/opam/.opam/4.02.0dev+trunk/lib/ocaml/camlp4' '-I' '/home/opam/.opam/4.02.0dev+trunk/lib/optcomp' '-parser' 'o' '-parser' 'op' '-printer' 'p' 'optcomp.cma'  'src/endianString.ml' > /tmp/ocamlpp0876b7
#

FreeVars module treats a record field name as a variable.

Camlp4.Struct.FreeVars module treats a record field name as a variable name.
For example, FreeVars reports that <:expr<r.name>> has free variables "r" and "name"; <:expr> has free variable "r".

$ ocaml -I +camlp4
        OCaml version 4.01.0

# #load "dynlink.cma";;
# #load "camlp4orf.cma";;
    Camlp4 Parsing version 4.01.0

# open Camlp4.PreCast;;
# let _loc = Loc.ghost;;
val _loc : Camlp4.PreCast.Loc.t = <abstr>
# let fv e = let module FV = Camlp4.Struct.FreeVars.Make(Ast) in
     FV.S.elements (FV.free_vars FV.S.empty e);;
val fv : Camlp4.PreCast.Ast.expr -> string list = <fun>
# fv <:expr<r.name>>;;
- : string list = ["name"; "r"]

camlp4 / toplevel bug

I checked out the fix for #48 (thanks!), and the fix mostly works but seems to introduce a new bug.

In plain ocaml, I can type 2 declarations at once and send them to the top-level with 1 single ";;". This is useful in e.g. emacs where I can send a block containing multiple declarations to ocaml at once.

~:> ocaml 
        OCaml version 4.02.1

# let f = 3
  let g = 5;;
val f : int = 3
val g : int = 5
# 

However, as soon as I add camlp4, I can now only send 1 at a time:

:~> ocaml
        OCaml version 4.02.1

# #load "dynlink.cma";;
# #load "camlp4o.cma";;
        Camlp4 Parsing version 4.02.1

# let f = 3
  let g = 5;;
Error: Parse error: ";;" expected after [str_item] (in [top_phrase])
# 

camlp4.macro fails to parse

I just tried to compile ocamlnet with the latest 4.02 branch and the latest camlp4 and the build failed with the following error:

ocamlfind ocamldep -syntax camlp4o -package camlp4.macro  *.ml *.mli >depend
File "rpc_auth_gssapi_aux.ml", line 25, characters 25-26:
Parse error: [poly_type] expected after ":" (in [label_declaration])
File "rpc_auth_gssapi_aux.ml", line 1:
Error: Error while running external preprocessor
Command line: camlp4 '-I' '/home/deplai_j/.opam/4.02.0+trunk/lib/ocaml/camlp4' '-I' '/home/deplai_j/.opam/4.02.0+trunk/lib/ocaml/camlp4' '-parser' 'o' '-parser' 'op' '-printer' 'p' '-parser' 'Camlp4MacroParser'  'rpc_auth_gssapi_aux.ml' > /tmp/ocamlpp4db8af

File "rpc_portmapper_aux.ml", line 10, characters 20-21:
Parse error: [poly_type] expected after ":" (in [label_declaration])
File "rpc_portmapper_aux.ml", line 1:
Error: Error while running external preprocessor
Command line: camlp4 '-I' '/home/deplai_j/.opam/4.02.0+trunk/lib/ocaml/camlp4' '-I' '/home/deplai_j/.opam/4.02.0+trunk/lib/ocaml/camlp4' '-parser' 'o' '-parser' 'op' '-printer' 'p' '-parser' 'Camlp4MacroParser'  'rpc_portmapper_aux.ml' > /tmp/ocamlpp971f27

File "rpc_auth_gssapi_aux.mli", line 28, characters 25-26:
Parse error: [poly_type] expected after ":" (in [label_declaration])
File "rpc_auth_gssapi_aux.mli", line 1:
Error: Error while running external preprocessor
Command line: camlp4 '-I' '/home/deplai_j/.opam/4.02.0+trunk/lib/ocaml/camlp4' '-I' '/home/deplai_j/.opam/4.02.0+trunk/lib/ocaml/camlp4' '-parser' 'o' '-parser' 'op' '-printer' 'p' '-parser' 'Camlp4MacroParser'  'rpc_auth_gssapi_aux.mli' > /tmp/ocamlpp1dbcdc

File "rpc_portmapper_aux.mli", line 13, characters 20-21:
Parse error: [poly_type] expected after ":" (in [label_declaration])
File "rpc_portmapper_aux.mli", line 1:
Error: Error while running external preprocessor
Command line: camlp4 '-I' '/home/deplai_j/.opam/4.02.0+trunk/lib/ocaml/camlp4' '-I' '/home/deplai_j/.opam/4.02.0+trunk/lib/ocaml/camlp4' '-parser' 'o' '-parser' 'op' '-printer' 'p' '-parser' 'Camlp4MacroParser'  'rpc_portmapper_aux.mli' > /tmp/ocamlpp64dae3

Error with 4.02.0 and #load directives

Hi,
the use of "#load" directives to load syntax extensions broke during the 4.01.0 -> 4.02.0 transitions. I have tried to bissect but couldn't easily since I need to rewind both camlp4 AND the ocaml compiler (so that they have matching ASTs). Here are two code snippets that trigger the behaviour:

  • bug1.ml
#load "pa_extend.cmo";;

open A
open B
open C
open D
open E
  • bug2.ml
#load "pa_extend.cmo";;

open A
open B
open C
open D
open E
open F
  • tests :
$ camlp4 -version
4.02.0+dev12-2014-07-30

$ camlp4o bug1.ml
E

$ camlp4o bug2.ml
let _ = E

open F

This bug was originally spotted while compiling the cduce compiler with the opam switch 4.02.0+trunk. Using the ocamlfind package camlp4.extend as well as the corresponding -syntax flag fixes the issue (so I guess this should be low priority).

Cannot build lwt with camp4 trunk

Trying to install Lwt with camlp4 trunk on 4.02.0dev+trunk produces the following error:

# + ocamlfind ocamldep -package unix -package camlp4 -package bigarray -syntax camlp4o -ppopt syntax/pa_optcomp.cmo -modules src/unix/lwt_io.mli > src/unix/lwt_io.mli.depends
# File "src/unix/lwt_io.mli", line 63, characters 5-11:
# Parse error: [semi] expected after [sig_item] (in [interf])
# File "src/unix/lwt_io.mli", line 1:
# Error: Error while running external preprocessor

The offending line: https://github.com/ocsigen/lwt/blob/master/src/unix/lwt_io.mli#L63

Camlp4 Stack_overflow on large array declaration

I'm creating an example MirageOS unikernel that compiles a phone book into the kernel itself. When attempting to compile this the first time with 25K entries the compilation failed with a Stack_overflow from Camlp4:

vagrant@vagrant-ubuntu-trusty-64:/vagrant/phonebook$ make 
ocamlbuild -classic-display -use-ocamlfind -pkgs lwt.syntax,mirage-clock-xen,mirage-console-xen,mirage-http,mirage-net-xen,mirage-types.lwt,tcpip.stack-direct -tags "syntax(camlp4o),annot,bin_annot,strict_sequence,principal" -cflag -g -lflags -g,-linkpkg,-dontlink,unix main.native.o
ocamlfind ocamldep -package tcpip.stack-direct -package mirage-types.lwt -package mirage-net-xen -package mirage-http -package mirage-console-xen -package mirage-clock-xen -package lwt.syntax -syntax camlp4o -modules Pb.ml > Pb.ml.depends
+ ocamlfind ocamldep -package tcpip.stack-direct -package mirage-types.lwt -package mirage-net-xen -package mirage-http -package mirage-console-xen -package mirage-clock-xen -package lwt.syntax -syntax camlp4o -modules Pb.ml > Pb.ml.depends
Camlp4: Uncaught exception: Stack_overflow

Preprocessing error on file Pb.ml
Error while running external preprocessor
Command line: camlp4 '-I' '/usr/lib/ocaml/camlp4' '-I' '/home/vagrant/.opam/system/lib/lwt' '-I' '/home/vagrant/.opam/system/lib/lwt' '-parser' 'o' '-parser' 'op' '-printer' 'p' 'lwt-syntax-options.cma' 'lwt-syntax.cma'  'Pb.ml' > /tmp/ocamlpp3b14a0

Command exited with code 2.
make: *** [main.native.o] Error 10

An example file of 25K rows is here: https://gist.github.com/andness/3deedede35ac901b63f6

Yet another fail

Sorry if it's again not related to camlp4, but this time eliom doesn't compile with the latest 4.02 branch and the latest camlp4:

ocamlfind ocamldep -I ../server -I ../server/private -I ../common -I extensions -I ../clientserver/_server -package ocsigenserver -package ocsigenserver.ext -package deriving -package js_of_ocaml.deriving -package react -package calendar -package tyxml -package lwt.react -package cryptokit -package deriving.syntax -package js_of_ocaml.deriving.syntax -package lwt.syntax -package tyxml.syntax -ppopt ../syntax/pa_include.cmo -syntax camlp4o eliom_registration.ml > .eliom_registration.ml.deps
File "eliom_registration.ml", line 2450, characters 9-22:
Parse error: [expr] expected after LABEL _ (in [expr])
File "eliom_registration.ml", line 1:
Error: Error while running external preprocessor
Command line: camlp4 '-I' '/home/deplai_j/.opam/4.02.0+trunk/lib/ocaml' '-I' '/home/deplai_j/.opam/4.02.0+trunk/lib/ocaml/camlp4' '-I' '/home/deplai_j/.opam/4.02.0+trunk/lib/deriving' '-I' '/home/deplai_j/.opam/4.02.0+trunk/lib/deriving' '-I' '/home/deplai_j/.opam/4.02.0+trunk/lib/deriving' '-I' '/home/deplai_j/.opam/4.02.0+trunk/lib/deriving' '-I' '/home/deplai_j/.opam/4.02.0+trunk/lib/deriving' '-I' '/home/deplai_j/.opam/4.02.0+trunk/lib/js_of_ocaml' '-I' '/home/deplai_j/.opam/4.02.0+trunk/lib/lwt' '-I' '/home/deplai_j/.opam/4.02.0+trunk/lib/lwt' '-I' '/home/deplai_j/.opam/4.02.0+trunk/lib/tyxml' 'unix.cma' '-parser' 'o' '-parser' 'op' '-printer' 'p' 'pa_deriving_common.cma' 'pa_deriving_std.cma' 'pa_deriving_classes.cma' '-ignore' 'dummy' '-ignore' 'dummy' 'pa_deriving_Json.cmo' 'lwt-syntax-options.cma' 'lwt-syntax.cma' 'pa_tyxml.cma' '../syntax/pa_include.cmo' 'eliom_registration.ml' > /tmp/ocamlpp5a0662

Fails to install (ocamlfind cannot find camlp4/META)

Installation fails with ocamlfind: camlp4/META: No such file or directory. While the file camlp4/META has been created by the top-level Makefile, ocamlfind is invoked inside _build/camlp4 and fails to locate it there.

Having the Makefile produce the META file inside _build/camlp4/ instead of inside camlp4/ and changing the relevant line in build/install.sh into
ocamlfind install camlp4 META \
fixed the issue for me, but I have no idea how all this is supposed to work and whether this is the appropriate way to fix it.

  • linux-amd64
  • opam 1.2 from git (but had the same issue with 1.1)
  • ocaml 4.02.0+trunk
  • ocamlfind 1.5.2
  • camlp4 4.02.0

build failure with stack overflow on 4.02.0dev

With ocaml/ocaml@774e30e (4.02.0dev as of today afternoon), I get a Stack_overflow compiling camlp4 on MacOS X.

+ echo camlp4/Camlp4.cmo camlp4/Camlp4Top.cmo camlp4/camlp4prof.byte camlp4/mkcamlp4.byte camlp4/camlp4.byte camlp4/camlp4fulllib.cma camlp4/camlp4boot.byte camlp4/camlp4boot.cma camlp4/camlp4r.byte camlp4/camlp4r.cma camlp4/camlp4rf.byte camlp4/camlp4rf.cma camlp4/camlp4o.byte camlp4/camlp4o.cma camlp4/camlp4of.byte camlp4/camlp4of.cma camlp4/camlp4oof.byte camlp4/camlp4oof.cma camlp4/camlp4orf.byte camlp4/camlp4orf.cma camlp4/Camlp4Parsers/Camlp4AstLoader.cmo camlp4/Camlp4Parsers/Camlp4DebugParser.cmo camlp4/Camlp4Parsers/Camlp4GrammarParser.cmo camlp4/Camlp4Parsers/Camlp4ListComprehension.cmo camlp4/Camlp4Parsers/Camlp4MacroParser.cmo camlp4/Camlp4Parsers/Camlp4OCamlOriginalQuotationExpander.cmo camlp4/Camlp4Parsers/Camlp4OCamlParser.cmo camlp4/Camlp4Parsers/Camlp4OCamlParserParser.cmo camlp4/Camlp4Parsers/Camlp4OCamlReloadedParser.cmo camlp4/Camlp4Parsers/Camlp4OCamlRevisedParser.cmo camlp4/Camlp4Parsers/Camlp4OCamlRevisedParserParser.cmo camlp4/Camlp4Parsers/Camlp4OCamlRevisedQuotationExpander.cmo camlp4/Camlp4Parsers/Camlp4QuotationCommon.cmo camlp4/Camlp4Parsers/Camlp4QuotationExpander.cmo camlp4/Camlp4Printers/Camlp4AstDumper.cmo camlp4/Camlp4Printers/Camlp4AutoPrinter.cmo camlp4/Camlp4Printers/Camlp4NullDumper.cmo camlp4/Camlp4Printers/Camlp4OCamlAstDumper.cmo camlp4/Camlp4Printers/Camlp4OCamlPrinter.cmo camlp4/Camlp4Printers/Camlp4OCamlRevisedPrinter.cmo camlp4/Camlp4Filters/Camlp4AstLifter.cmo camlp4/Camlp4Filters/Camlp4ExceptionTracer.cmo camlp4/Camlp4Filters/Camlp4FoldGenerator.cmo camlp4/Camlp4Filters/Camlp4LocationStripper.cmo camlp4/Camlp4Filters/Camlp4MapGenerator.cmo camlp4/Camlp4Filters/Camlp4MetaGenerator.cmo camlp4/Camlp4Filters/Camlp4Profiler.cmo camlp4/Camlp4Filters/Camlp4TrashRemover.cmo
/Users/avsm/.opam/4.02.0dev+trunk/bin/ocamlc.opt -c -g -warn-error A -w a -I camlp4/import -I camlp4/config -I camlp4/boot -o camlp4/boot/Camlp4.cmo camlp4/boot/Camlp4.ml
+ /Users/avsm/.opam/4.02.0dev+trunk/bin/ocamlc.opt -c -g -warn-error A -w a -I camlp4/import -I camlp4/config -I camlp4/boot -o camlp4/boot/Camlp4.cmo camlp4/boot/Camlp4.ml
Fatal error: exception Stack_overflow
Called from file "arg.ml", line 214, characters 2-73
Command exited with code 2.

camlp4 builds with corebuild failing on ocaml 4.02

Some odd build problem with building using corebuild. I'm not
sure it's actually a camlp4 problem, really.

make -k 
true
corebuild \
    -j 6 \
    -cflag -g \
    -cflags -w,-40,-w,-18 \
    excel.cmo
ocamlfind ocamldep -syntax camlp4o -package bin_prot.syntax -package sexplib.syntax,comparelib.syntax,fieldslib.syntax,variantslib.syntax -package core -modules excel.ml > excel.ml.depends
+ ocamlfind ocamldep -syntax camlp4o -package bin_prot.syntax -package sexplib.syntax,comparelib.syntax,fieldslib.syntax,variantslib.syntax -package core -modules excel.ml > excel.ml.depends
Camlp4: Uncaught exception: DynLoader.Error ("/Users/yminsky/.opam/4.02.0/lib/type_conv/pa_type_conv.cma", "/Users/yminsky/.opam/4.02.0/lib/type_conv/pa_type_conv.cma is not a bytecode object file")

Preprocessing error on file excel.ml
Error while running external preprocessor
Command line: camlp4 '-I' '/Users/yminsky/.opam/4.02.0/lib/ocaml/camlp4' '-I' '/Users/yminsky/.opam/4.02.0/lib/type_conv' '-I' '/Users/yminsky/.opam/4.02.0/lib/ocaml' '-I' '/Users/yminsky/.opam/4.02.0/lib/ocaml' '-I' '/Users/yminsky/.opam/4.02.0/lib/bin_prot' '-I' '/Users/yminsky/.opam/4.02.0/lib/bin_prot' '-I' '/Users/yminsky/.opam/4.02.0/lib/sexplib' '-I' '/Users/yminsky/.opam/4.02.0/lib/sexplib' '-I' '/Users/yminsky/.opam/4.02.0/lib/comparelib' '-I' '/Users/yminsky/.opam/4.02.0/lib/comparelib' '-I' '/Users/yminsky/.opam/4.02.0/lib/fieldslib' '-I' '/Users/yminsky/.opam/4.02.0/lib/fieldslib' '-I' '/Users/yminsky/.opam/4.02.0/lib/variantslib' '-I' '/Users/yminsky/.opam/4.02.0/lib/variantslib' '-parser' 'o' '-parser' 'op' '-printer' 'p' 'pa_type_conv.cma' 'unix.cma' 'bigarray.cma' 'bin_prot.cma' 'pa_bin_prot.cma' 'sexplib.cma' 'pa_sexp_conv.cma' 'comparelib.cma' 'pa_compare.cma' 'fieldslib.cma' 'pa_fields_conv.cma' 'variantslib.cma' 'pa_variants_conv.cma'  'excel.ml' > /var/folders/x_/d45m_mpx2r7g79x2212dkjsm0000gn/T/ocamlpp7daa73

Command exited with code 2.
make: *** [excel.cmo] Error 10
make: Target `all' not remade because of errors.

camlp4 messes with comments

From http://caml.inria.fr/mantis/view.php?id=4713 and http://caml.inria.fr/mantis/view.php?id=4346

Camlp4o messes with comments, hence with ocamldoc generation of documentation.

In order for comments to be used by ocamldoc, they should come immediately before or after a value. Camlp4o moves comments away from values, hence breaks ocamldoc.

Is there any hope that this could be fixed?

Examples :

$ cat tst.ml 
 (** comment of t *)
 type t =
   {
     mutable a : int; (** a *)
     mutable b : int; (** b *)
     mutable c : int; (** c *)
     mutable d : int; (** d *)
     mutable e : int; (** e *)
   }
 (** after *)
 $ camlp4o tst.ml 
 (** comment of t *)
 type t =
   { (** a *) (** b *) (** c *) mutable a : int; mutable b : int;
     mutable c : int; mutable d : int; (** d *) mutable e : int
   }
 cat tst_bis.ml
 (** comment of t *)
 type t =
   {
     mutable a : int; (** a *)
     mutable b : int; (** b *)
     mutable c : int; (** c *)
     mutable d : int; (** d *)
     mutable e : int; (** e *)
   }
 (** after *)
 ()
 $ camlp4o tst_bis.ml
 (** comment of t *)
 type t =
   { (** a *) (** b *) (** c *) mutable a : int; mutable b : int;
     mutable c : int; mutable d : int; (** d *) mutable e : int
   }
 (** e *)
 (** after *)
 let _ = ()

Old patch with partial fix :

diff --exclude=.svn -ur /home/ygrek/work/contrib/ocaml/3.11/camlp4/Camlp4/Printers/OCaml.ml camlp4/Camlp4/Printers/OCaml.ml
--- /home/ygrek/work/contrib/ocaml/3.11/camlp4/Camlp4/Printers/OCaml.ml 2009-10-31 13:58:04.000000000 +0200
+++ camlp4/Camlp4/Printers/OCaml.ml 2009-12-31 14:39:27.000000000 +0200
@@ -152,6 +152,13 @@
           do_print_comments_before loc f s
     | [: :] -> () ];

+  value rec do_print_all_comments loc f =
+    parser
+    [ [: ` (comm, comm_loc); s :] ->
+          let () = f comm comm_loc in
+          do_print_all_comments loc f s
+    | [: :] -> () ];
+
   class printer ?curry_constr:(init_curry_constr = False) ?(comments = True) () =
   object (o)

@@ -737,7 +744,7 @@
         <:sig_item< $<:sig_item<>>$; $sg$ >> ->
           o#sig_item f sg
       | <:sig_item< $sg1$; $sg2$ >> ->
-          do { o#sig_item f sg1; cut f; o#sig_item f sg2 }
+          do { o#sig_item f sg1; o#node f sg2 Ast.loc_of_sig_item; cut f; o#sig_item f sg2 }
       | <:sig_item< exception $t$ >> ->
           pp f "@[<2>exception@ %a%(%)@]" o#ctyp t semisep
       | <:sig_item< external $s$ : $t$ = $sl$ >> ->
@@ -1012,7 +1019,13 @@
       [ <:str_item< $exp:e$ >> -> pp f "@[<0>%a%(%)@]@." o#expr e semisep
       | st -> pp f "@[<v0>%a@]@." o#str_item st ];

-    method interf f sg = pp f "@[<v0>%a@]@." o#sig_item sg;
+    method interf f sg = 
+      let () = pp f "@[<v0>%a@]" o#sig_item sg in
+      let loc = Ast.loc_of_sig_item sg in
+      let () = do_print_all_comments loc (fun c _ -> pp f "%s@ " c)
+        (CommentFilter.take_stream comment_filter) in
+      pp f "@.";
+
   end;

   value with_outfile output_file fct arg =

Inconsistent behavior with polymorphic variants, camlp4, and ocamlc's -pp flag

Under certain conditions, using the -pp flag of ocamlc (as opposed to using camlp4 and then ocamlc) causes incorrect errors during compilation.

This was originally submitted as a bug to OCaml's MANTIS (http://caml.inria.fr/mantis/view.php?id=6440), was asked to resubmit here.

Steps to reproduce:

> cat garrigue.ml
(* example modified from Garrigue, J.--APLAS '06 *)
module type Ops = sig
  type expr
  val eval : expr -> expr
  val show : expr -> string
end
module Test = struct
  type 'a expr0 = [`Num of int | `True]
  module F(X : Ops with type expr = private [> 'a expr0] as 'a) =
  struct
    type expr = X.expr expr0
    let eval : expr -> X.expr = function
      | `True -> `True
      | `Num _ as e -> e
    let show : expr -> string = function
      | `Num n -> string_of_int n
      | `True -> "true"
  end
  module rec L : (Ops with type expr = L.expr expr0) = F(L)
end
let _ = Printf.printf "%s\n" (Test.L.show(`True)) ;;
> wget http://caml.inria.fr/pub/distrib/ocaml-4.01/ocaml-4.01.0.tar.gz
> tar -xf ocaml-4.01.0.tar.gz
> cd ocaml-4.01.0
> ./configure --prefix $PWD/local && make world.opt && make install
...
> cd ..
> ./ocaml-4.01.0/local/bin/ocamlc -pp "./ocaml-4.01.0/local/bin/camlp4o" garrigue.ml 
File "garrigue.ml", line 14, characters 8-13:
Error: This pattern matches values of type [? `True ]
       but a pattern was expected which matches values of type expr
       The second variant type does not allow tag(s) `True
> ./ocaml-4.01.0/local/bin/camlp4o garrigue.ml > pp_garrigue.ml
> ./ocaml-4.01.0/local/bin/ocamlc pp_garrigue.ml 
> ./a.out 
true

It only seems to occur if the pv constructor has no arguments; if you remove `True from the type and the relevant cases from the functions, there is no issue. This issue seems to be present in 3.12.1, 4.01.0, and the current latest ocaml/ocaml on github (as of May 22nd @ 15:00).

Build failure with OCaml 4.02.0 MinGW

The following build trial fails with OCaml 4.02.0 MinGW:

# in Cygwin shell
$ ./configure
$ make all
...
''C:/ocamlmgw/bin/ocamldep.opt -pp '''camlp4/boot/camlp4boot.native -D OPT' -modules camlp4/Camlp4/Debug.mli > camlp4/Camlp4/Debug.mli.depends
'camlp4' is not recognized as an internal or external command,
operable program or batch file.
File "camlp4/Camlp4/Debug.mli", line 1:
Error: Error while running external preprocessor
Command line: camlp4/boot/camlp4boot.native -D OPT "camlp4/Camlp4/Debug.mli" > C:\cygwin\tmp\ocamlpp08f0af

Exit code 2 while executing this command:
  ''C:/ocamlmgw/bin/ocamldep.opt -pp '''camlp4/boot/camlp4boot.native -D OPT' -modules camlp4/Camlp4/Debug.mli > camlp4/Camlp4/Debug.mli.depends
Makefile:9: recipe for target 'byte' failed

The string "camlp4/boot/camlp4boot.native" is sent to Sys.command and cmd.exe does not understand it. It must be "camlp4\boot\camlp4boot.native":

$ C:/ocamlmgw/bin/ocamldep.opt -pp '_build/camlp4/boot/fcamlp4boot.native -D OPT' -modules camlp4/Camlp4/Debug.mli
'_build' is not recognized as an internal or external command,
operable program or batch file.
File "camlp4/Camlp4/Debug.mli", line 1:
Error: Error while running external preprocessor
Command line: _build/camlp4/boot/fcamlp4boot.native -D OPT "camlp4/Camlp4/Debug.mli" > C:\cygwin\tmp\ocamlpp005928

camlp4/Camlp4/Debug.mli:

Using "_build\camlp4\boot\camlp4boot.native" resolves the problem:

$ C:/ocamlmgw/bin/ocamldep.opt -pp '_build\\camlp4\\boot\\camlp4boot.native -D OPT' -modules camlp4/Camlp4/Debug.mli
camlp4/Camlp4/Debug.mli: Format

comments disappear when using line directive

current filename = test.mli
WORKS = comments are present
DOESN'T WORK = comments disappear

tested with command : camlp4 -parser o -printer o test.mli

WORK:

#1 "somthing.mli"

(* one *)
(** 2 test **)
val x : int

DOESN'T WORK if no new line after the line directive

#1 "somthing.mli"
(* one *)
(** 2 test **)
val x : int

BUT IT WORKS if the filename in the line directive is the same if the file your read

#1 "test.mli"
(* one *)
(** 2 test **)
val x : int

camlp4 fails to install with ocaml 4.02.1

Installing camlp4 on osx with ocaml 4.02.1 fails with:

File "camlp4/boot/Camlp4.ml", line 15035, characters 31-42:
Error: This record expression is expected to have type
         Parsetree.constructor_declaration
       The constructor Pcstr_tuple does not belong to type list
Command exited with code 2.
make: *** [byte] Error 10

Any suggestions?

Cheers

Fatal error: Parmatch.set_args when compiling camlp4

Compiling the current Camlp4 trunk (latest commit f2d6252) with the current OCaml trunk (SVN revision 15568) gives:

/usr/local/ocaml-trunk/bin/ocamlc.opt -c -g -w a -I camlp4/import -warn-error A-3 -I camlp4/config -I camlp4/boot -o camlp4/boot/Camlp4.cmo camlp4/boot/Camlp4.ml
Fatal error: Parmatch.set_args
Fatal error: exception Misc.Fatal_error

I don't know whether this is a problem with OCaml or with camlp4 or an expected incompatibility between the two trunks, so I'm reporting the issue here as well as on the OCaml bug tracker.
(See http://caml.inria.fr/mantis/view.php?id=6647)

camlp4 + toplevel = hang

I ran into the following problem after upgrading to 4.02. As soon as I load the
camlp4o.cma in the toplevel, it doesn't seem to want to parse statements as
they're typed in anymore -- ";;" has no effect and I had to type several ^D in a
row to get the statement parsed.

4.01 is fine. Utop is fine. It's only been a problem for me under plain
toplevel since 4.02.

Thanks!

Steps to Reproduce:

        OCaml version 4.02.1+dev0-2014-08-29

# #load "dynlink.cma";;
# #load "camlp4o.cma";;
        Camlp4 Parsing version 4.02.1+dev0-2014-08-29

#1;;
  3;;




^D
^D
^D
^D
^D
^D
^D
- : int = 1

camlp4 fails to build

Building 1d4c549 with ocaml/ocaml@26a8bc2

[10:13am][jwatzman@dev1456:~/local/camlp4] $ make distclean
rm -rf _build myocamlbuild_config.ml Makefile.config
[10:13am][jwatzman@dev1456:~/local/camlp4] $ ./configure
[10:13am][jwatzman@dev1456:~/local/camlp4] $ make all
ocamlbuild -classic-display -no-ocamlfind `./build/camlp4-byte-only.sh`
+ echo camlp4/Camlp4.cmo camlp4/Camlp4Top.cmo camlp4/camlp4prof.byte camlp4/mkcamlp4.byte camlp4/camlp4.byte camlp4/camlp4fulllib.cma camlp4/camlp4boot.byte camlp4/camlp4boot.cma camlp4/camlp4r.byte camlp4/camlp4r.cma camlp4/camlp4rf.byte camlp4/camlp4rf.cma camlp4/camlp4o.byte camlp4/camlp4o.cma camlp4/camlp4of.byte camlp4/camlp4of.cma camlp4/camlp4oof.byte camlp4/camlp4oof.cma camlp4/camlp4orf.byte camlp4/camlp4orf.cma camlp4/Camlp4Parsers/Camlp4AstLoader.cmo camlp4/Camlp4Parsers/Camlp4DebugParser.cmo camlp4/Camlp4Parsers/Camlp4GrammarParser.cmo camlp4/Camlp4Parsers/Camlp4ListComprehension.cmo camlp4/Camlp4Parsers/Camlp4MacroParser.cmo camlp4/Camlp4Parsers/Camlp4OCamlOriginalQuotationExpander.cmo camlp4/Camlp4Parsers/Camlp4OCamlParser.cmo camlp4/Camlp4Parsers/Camlp4OCamlParserParser.cmo camlp4/Camlp4Parsers/Camlp4OCamlReloadedParser.cmo camlp4/Camlp4Parsers/Camlp4OCamlRevisedParser.cmo camlp4/Camlp4Parsers/Camlp4OCamlRevisedParserParser.cmo camlp4/Camlp4Parsers/Camlp4OCamlRevisedQuotationExpander.cmo camlp4/Camlp4Parsers/Camlp4QuotationCommon.cmo camlp4/Camlp4Parsers/Camlp4QuotationExpander.cmo camlp4/Camlp4Printers/Camlp4AstDumper.cmo camlp4/Camlp4Printers/Camlp4AutoPrinter.cmo camlp4/Camlp4Printers/Camlp4NullDumper.cmo camlp4/Camlp4Printers/Camlp4OCamlAstDumper.cmo camlp4/Camlp4Printers/Camlp4OCamlPrinter.cmo camlp4/Camlp4Printers/Camlp4OCamlRevisedPrinter.cmo camlp4/Camlp4Filters/Camlp4AstLifter.cmo camlp4/Camlp4Filters/Camlp4ExceptionTracer.cmo camlp4/Camlp4Filters/Camlp4FoldGenerator.cmo camlp4/Camlp4Filters/Camlp4LocationStripper.cmo camlp4/Camlp4Filters/Camlp4MapGenerator.cmo camlp4/Camlp4Filters/Camlp4MetaGenerator.cmo camlp4/Camlp4Filters/Camlp4Profiler.cmo camlp4/Camlp4Filters/Camlp4TrashRemover.cmo
/home/jwatzman/.opam/4.02.0dev+trunk/bin/ocamlopt.opt unix.cmxa -I /home/jwatzman/.opam/4.02.0dev+trunk/lib/ocaml/ocamlbuild /home/jwatzman/.opam/4.02.0dev+trunk/lib/ocaml/ocamlbuild/ocamlbuildlib.cmxa myocamlbuild_config.ml myocamlbuild.ml /home/jwatzman/.opam/4.02.0dev+trunk/lib/ocaml/ocamlbuild/ocamlbuild.cmx -o myocamlbuild
/home/jwatzman/.opam/4.02.0dev+trunk/bin/ocamldep.opt -modules camlp4/boot/camlp4boot.ml > camlp4/boot/camlp4boot.ml.depends
/home/jwatzman/.opam/4.02.0dev+trunk/bin/ocamldep.opt -modules camlp4/boot/Camlp4.ml > camlp4/boot/Camlp4.ml.depends
/home/jwatzman/.opam/4.02.0dev+trunk/bin/ocamldep.opt -modules camlp4/config/Camlp4_config.mli > camlp4/config/Camlp4_config.mli.depends
cp /home/jwatzman/.opam/4.02.0dev+trunk/lib/ocaml/compiler-libs/warnings.cmi camlp4/import/warnings.cmi
cp /home/jwatzman/.opam/4.02.0dev+trunk/lib/ocaml/compiler-libs/location.cmi camlp4/import/location.cmi
cp /home/jwatzman/.opam/4.02.0dev+trunk/lib/ocaml/compiler-libs/longident.cmi camlp4/import/longident.cmi
cp /home/jwatzman/.opam/4.02.0dev+trunk/lib/ocaml/compiler-libs/asttypes.cmi camlp4/import/asttypes.cmi
cp /home/jwatzman/.opam/4.02.0dev+trunk/lib/ocaml/compiler-libs/parsetree.cmi camlp4/import/parsetree.cmi
cp /home/jwatzman/.opam/4.02.0dev+trunk/lib/ocaml/compiler-libs/outcometree.cmi camlp4/import/outcometree.cmi
cp /home/jwatzman/.opam/4.02.0dev+trunk/lib/ocaml/compiler-libs/oprint.cmi camlp4/import/oprint.cmi
cp /home/jwatzman/.opam/4.02.0dev+trunk/lib/ocaml/compiler-libs/toploop.cmi camlp4/import/toploop.cmi
/home/jwatzman/.opam/4.02.0dev+trunk/bin/ocamlc.opt -c -g -warn-error A -w Z -I camlp4/import -I camlp4/config -I camlp4 -o camlp4/config/Camlp4_config.cmi camlp4/config/Camlp4_config.mli
/home/jwatzman/.opam/4.02.0dev+trunk/bin/ocamlc.opt -c -g -warn-error A -w a -I camlp4/import -I camlp4/config -I camlp4/boot -o camlp4/boot/Camlp4.cmo camlp4/boot/Camlp4.ml
+ /home/jwatzman/.opam/4.02.0dev+trunk/bin/ocamlc.opt -c -g -warn-error A -w a -I camlp4/import -I camlp4/config -I camlp4/boot -o camlp4/boot/Camlp4.cmo camlp4/boot/Camlp4.ml
File "camlp4/boot/Camlp4.ml", line 16263, characters 31-40:
Error: Unbound constructor Pdir_none
Hint: Did you mean Pdir_int or Pdir_bool?
Command exited with code 2.
make: *** [byte] Error 10

Problem may be due to this change in ocaml: ocaml/ocaml@26a8bc2#diff-1a4cbbaf5214f2b13806aacadfea3e62L766

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.