Skip to content

Commit 2fa5506

Browse files
committed
Merge pull request #41 from neolem/master
Redefine constant_type to for ocaml 4.03
2 parents f908f40 + a9b9ae5 commit 2fa5506

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

ast_convenience.ml

+12
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@ module Label = struct
2525

2626
end
2727

28+
module Constant = struct
29+
type t = Parsetree.constant =
30+
Pconst_integer of string * char option
31+
| Pconst_char of char
32+
| Pconst_string of string * string option
33+
| Pconst_float of string * char option
34+
35+
let of_constant x = x
36+
37+
let to_constant x = x
38+
39+
end
2840

2941
let may_tuple ?loc tup = function
3042
| [] -> None

ast_convenience.mli

+18-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
(** {1 Convenience functions to help build and deconstruct AST fragments.} *)
66

7-
open Parsetree
87
open Asttypes
98
open Ast_helper
9+
open Parsetree
1010

1111
(** {2 Compatibility modules} *)
1212

@@ -26,6 +26,23 @@ module Label : sig
2626

2727
end
2828

29+
(** {2 Provides a unified abstraction over differences in Parsetree.constant and Asttypes.constant
30+
* types defined in ocaml 4.03 and 4.02 respectively}*)
31+
module Constant : sig
32+
type t = Parsetree.constant =
33+
Pconst_integer of string * char option
34+
| Pconst_char of char
35+
| Pconst_string of string * string option
36+
| Pconst_float of string * char option
37+
38+
(** Convert Asttypes.constant to Constant.t *)
39+
val of_constant : Parsetree.constant -> t
40+
41+
(** Convert Constant.t to Asttypes.constant *)
42+
val to_constant : t -> Parsetree.constant
43+
44+
end
45+
2946
(** {2 Misc} *)
3047

3148
val lid: ?loc:loc -> string -> lid

0 commit comments

Comments
 (0)