Skip to content
This repository was archived by the owner on Oct 18, 2018. It is now read-only.

Commit 90f2199

Browse files
committed
Port to OMP
This will make it possible to use newer versions of the OCaml compiler. Closes #22
1 parent 1ebd2cc commit 90f2199

File tree

14 files changed

+94
-107
lines changed

14 files changed

+94
-107
lines changed

4.02/compat.ml

Lines changed: 0 additions & 17 deletions
This file was deleted.

4.03/compat.ml

Lines changed: 0 additions & 17 deletions
This file was deleted.

4.04/compat.ml

Lines changed: 0 additions & 17 deletions
This file was deleted.

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ How to configure ocamllint
7373
Similarly to how `ocamlbuild` works, it is necessary to write a plugin to modify
7474
the configuration. It is a dynamically-linked file from which one has to call
7575
`Ocamllint.Plugin.set_config`. The `example_plugin.ml` file is, well, an
76-
example. This plugin disables a warning. It can be built using `make example`.
76+
example. This plugin disables a warning.
7777

7878
When the ppx rewriter is loaded without an argument, it will use a default
7979
configuration:
8080

8181
```
82-
% ocamlfind ppx_tools/rewriter -ppx "ocamlfind ocamllint/ppx_lint.native" -str
82+
% ocamlfind ppx_tools/rewriter -ppx "ocamlfind ocamllint/ppx_lint --as-ppx" -str
8383
'let y = []@[] in let x = 3 in x'
8484
File "", line 1, characters 17-31:
8585
(ocamllint) Useless let binding
@@ -91,8 +91,8 @@ let _ = let y = [] @ [] in let x = 3 in x
9191
If you pass an option to the rewriter, it will load the configuration:
9292

9393
```
94-
% ocamlfind ppx_tools/rewriter -ppx "ocamlfind ocamllint/ppx_lint.native
95-
_build/example_plugin.cmxs" -str 'let y = []@[] in let x = 3 in x'
94+
% ocamlfind ppx_tools/rewriter -ppx "ocamlfind ocamllint/ppx_lint --as-ppx
95+
--plugin _build/example_plugin.cmxs" -str 'let y = []@[] in let x = 3 in x'
9696
File "", line 1, characters 8-13:
9797
(ocamllint) List operation on litteral: @
9898
let _ = let y = [] @ [] in let x = 3 in x

_tags

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
true: package(compiler-libs.common)
2-
true: package(ppx_tools.metaquot)
1+
true: bin_annot
2+
true: package(ocaml-migrate-parsetree)
3+
true: package(ppx_tools_versioned.metaquot_404)
4+
true: package(ppx_tools_versioned)
35
true: package(str)
46
"lib": include
57
<ppx/*>: package(dynlink)

lib/ast_tools.ml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
open Asttypes
2-
open Parsetree
1+
open Migrate_parsetree.Ast_404.Asttypes
2+
open Migrate_parsetree.Ast_404.Parsetree
33

44
let rec li_eq li1 li2 =
55
let open Longident in
@@ -39,7 +39,7 @@ and expr_list_eq el1 el2 =
3939
with Invalid_argument _ -> false
4040

4141
and label_eq l1 l2 =
42-
let open Ast_convenience.Label in
42+
let open Ppx_tools_404.Ast_convenience.Label in
4343
match explode l1, explode l2 with
4444
| Nolabel, Nolabel -> true
4545
| Labelled s1, Labelled s2
@@ -54,4 +54,18 @@ and expr_label_list_eq el1 el2 =
5454
List.for_all2 expr_label_eq el1 el2
5555
with Invalid_argument _ -> false
5656

57-
let sigitem_attributes = Compat.sigitem_attributes
57+
let sigitem_attributes { psig_desc } =
58+
match psig_desc with
59+
| Psig_value vd -> [vd.pval_attributes]
60+
| Psig_type (_, tdecls) -> List.map (fun tdecl -> tdecl.ptype_attributes) tdecls
61+
| Psig_typext text -> [text.ptyext_attributes]
62+
| Psig_exception exc -> [exc.pext_attributes]
63+
| Psig_module md -> [md.pmd_attributes]
64+
| Psig_recmodule mds -> List.map (fun md -> md.pmd_attributes) mds
65+
| Psig_modtype pmtd -> [pmtd.pmtd_attributes]
66+
| Psig_open popen -> [popen.popen_attributes]
67+
| Psig_include pincl -> [pincl.pincl_attributes]
68+
| Psig_class pcis
69+
| Psig_class_type pcis -> List.map (fun pct -> pct.pci_attributes) pcis
70+
| Psig_attribute attribute -> [[attribute]]
71+
| Psig_extension (_, attributes) -> [attributes]

lib/ast_tools.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
val expr_eq : Parsetree.expression -> Parsetree.expression -> bool
1+
val expr_eq : Migrate_parsetree.Ast_404.Parsetree.expression -> Migrate_parsetree.Ast_404.Parsetree.expression -> bool
22

33
(**
44
Return all attributes for a signature item.
55
In some cases (e.g. recursive type declarations) there can be several ones.
66
*)
7-
val sigitem_attributes : Parsetree.signature_item -> Parsetree.attributes list
7+
val sigitem_attributes : Migrate_parsetree.Ast_404.Parsetree.signature_item -> Migrate_parsetree.Ast_404.Parsetree.attributes list

lib/ocamllint_rules.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
open Ast_tools
2-
open Asttypes
3-
open Parsetree
2+
open Migrate_parsetree.Ast_404.Asttypes
3+
open Migrate_parsetree.Ast_404.Parsetree
44

55
(** Allocated litterals *)
66
let is_allocated_lit exp =
77
match exp.pexp_desc with
88
| Pexp_constant _ ->
99
begin
10-
match Ast_convenience.get_str exp with
10+
match Ppx_tools_404.Ast_convenience.get_str exp with
1111
| Some _ -> true
1212
| None -> false
1313
end
@@ -229,7 +229,7 @@ let filter_rev_map : type a b . (a -> b option) -> a list -> b list
229229
go []
230230

231231
let extract_ocaml_doc attributes =
232-
let open Ast_convenience in
232+
let open Ppx_tools_404.Ast_convenience in
233233
match find_attr_expr "ocaml.doc" attributes with
234234
| Some e -> get_str e
235235
| None -> None

lib/ocamllint_rules.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
val rate_expression : Parsetree.expression -> Ocamllint.Warning.t option
1+
val rate_expression : Migrate_parsetree.Ast_404.Parsetree.expression -> Ocamllint.Warning.t option
22

33
val rate_module_name : string -> Ocamllint.Warning.t option
44

55
val rate_module_type_name : string -> Ocamllint.Warning.t option
66

7-
val rate_signature_item : Parsetree.signature_item -> Ocamllint.Warning.t option
7+
val rate_signature_item : Migrate_parsetree.Ast_404.Parsetree.signature_item -> Ocamllint.Warning.t option
88

99
val is_snake_case : string -> bool

myocamlbuild.ml

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)