Skip to content
Commits on Source (4)
Camlp5 Version 7.08:
--------------------
* [02 Aug 19] Updated for (incoming) ocaml version 4.10.0.
* [02 Aug 19] Updated for ocaml version 4.09.0.
* [27 Jun 19] Updated for ocaml version 4.08.1.
* [27 Jun 19] Updated for ocaml version 4.08.0 (by github user madroach).
* [27 Jun 19] Added raw string syntax (by Check Murthy).
* [21 Dec 18] Fixed bug: in printer pr_o.cmo, comment did not get passed
through after "let in".
Camlp5 Version 7.07:
--------------------
......
......@@ -2,10 +2,10 @@ OVERVIEW
Camlp5 is a preprocessor-pretty-printer of ocaml.
It is compatible with all versions of ocaml from 1.07 to 4.07.2 (when
It is compatible with all versions of ocaml from 1.07 to 4.10.0 (when
they compile), and jocaml 3.12.0 to 3.12.1.
This Camlp5 version is 7.07.
This Camlp5 version is 7.08.
INSTALL
......
......@@ -26,11 +26,11 @@ authors: ["Daniel de Rauglaudre"]
homepage: "https://camlp5.github.io"
license: "BSD-3-Clause"
bug-reports: "https://github.com/camlp5/camlp5/issues"
dev-repo: "https://github.com/camlp5/camlp5.git"
dev-repo: "git+https://github.com/camlp5/camlp5.git"
doc: "https://camlp5.github.io/doc/html"
depends: [
"ocaml" { >= "4.02" & <= "4.07.1" }
"ocaml" { >= "4.02" & <= "4.08.0" }
]
build: [
......
camlp5 (7.08-1) unstable; urgency=medium
* New upstream release
-- Stéphane Glondu <glondu@debian.org> Sun, 04 Aug 2019 06:21:22 +0200
camlp5 (7.07-1) unstable; urgency=medium
* New upstream release
......
......@@ -1023,12 +1023,12 @@ EXTEND_PRINTER
pprintf pc "(let%s %q in %q)"
(if rf then " rec" else "")
(hlist2 let_binding (and_before let_binding)) pel ""
expr e ""
(comm_expr expr) e ""
else
pprintf pc "let%s %q in %p"
(if rf then " rec" else "")
(hlist2 let_binding (and_before let_binding)) pel ""
expr e)
(comm_expr expr) e)
(fun () ->
if pc.dang = ";" then
pprintf pc "@[<a>begin let%s %qin@;%q@ end@]"
......
......@@ -95,7 +95,7 @@ and print_symbol1 ppf =
fprintf ppf "(%a)" print_symbol s ]
and print_rule ppf symbols = do {
fprintf ppf "@[<hov 0>";
let _ =
let _ : _ -> _ =
List.fold_left
(fun sep symbol -> do {
fprintf ppf "%t%a" sep print_symbol symbol;
......@@ -107,7 +107,7 @@ and print_rule ppf symbols = do {
}
and print_level ppf pp_print_space rules = do {
fprintf ppf "@[<hov 0>[ ";
let _ =
let _ : _ -> _ =
List.fold_left
(fun sep rule -> do {
fprintf ppf "%t%a" sep print_rule rule;
......@@ -119,7 +119,7 @@ and print_level ppf pp_print_space rules = do {
};
value print_levels ppf elev =
let _ =
let _ : _ -> _ =
List.fold_left
(fun sep lev -> do {
let rules =
......
......@@ -386,6 +386,60 @@ value rec any_to_nl =
| ]
;
value rec rawstring1 (ofs, delim) ctx buf =
parser bp [: `c ; strm :] -> do {
ctx.line_cnt bp c;
let buf = $add c in
if String.get delim ofs <> c then
rawstring1 (0, delim) ctx buf strm
else if ofs+1 < String.length delim then
rawstring1 (ofs+1, delim) ctx buf strm
else
let s = $buf in
let slen = String.length s in
("STRING", String.escaped (String.sub s 0 (slen - (String.length delim))))
}
;
value rec rawstring0 ctx bp buf =
parser bp [
[: `'|' ; strm :] -> do {
rawstring1 (0, "|" ^ $buf ^ "}") ctx $empty strm
}
| [: `('a'..'z' | '_' as c) ; strm :] -> do {
rawstring0 ctx bp ($add c) strm
}
]
;
(*
* predicate checks that the stream contains "[:alpha:]+|", and it gets
* called when the main lexer has already seen a "{". To check for at least
* one alpha, require that the offset of the "|" be > 1 (which means that
* offset 1 must be [:alpha:].
*
* The further check for alpha here is unnecessary, since the main lexer will
* NOT call this function in the case where the input is "{|" (because that's
* a valid token, and precedes the branch where this code is invoked.
*)
value raw_string_starter_p strm =
let rec predrec n =
match stream_peek_nth n strm with
[ None -> False
| Some ('a'..'z' | '_') ->
predrec (n+1)
| Some '|' when n > 1 -> True
| Some _ -> False ]
in predrec 1
;
value keyword_or_error_or_rawstring ctx bp (loc,s) buf strm =
if not (raw_string_starter_p strm) then
keyword_or_error ctx loc "{"
else
rawstring0 ctx bp $empty strm
;
value next_token_after_spaces ctx bp =
lexer
[ 'A'-'Z' ident! ->
......@@ -433,7 +487,7 @@ value next_token_after_spaces ctx bp =
| "{|" -> keyword_or_error ctx (bp, $pos) $buf
| "{<" -> keyword_or_error ctx (bp, $pos) $buf
| "{:" -> keyword_or_error ctx (bp, $pos) $buf
| "{" -> keyword_or_error ctx (bp, $pos) $buf
| "{" (keyword_or_error_or_rawstring ctx bp ((bp, $pos),$buf))
| ".." -> keyword_or_error ctx (bp, $pos) ".."
| "." ?= [ "\n" ] -> keyword_or_error ctx (bp, bp + 1) ctx.dot_newline_is
| "." ->
......
......@@ -787,8 +787,21 @@ value ocaml_pexp_open =
IFDEF OCAML_VERSION < OCAML_3_12 THEN None
ELSIFDEF OCAML_VERSION < OCAML_4_01 THEN
Some (fun li e -> Pexp_open (mknoloc li) e)
ELSE
ELSIFDEF OCAML_VERSION < OCAML_4_08 THEN
Some (fun li e -> Pexp_open Fresh (mknoloc li) e)
ELSE
Some (fun li e ->
Pexp_open
{ popen_expr =
{ pmod_desc = Pmod_ident (mknoloc li)
; pmod_loc = loc_none
; pmod_attributes = []
}
; popen_override = Fresh
; popen_loc = loc_none
; popen_attributes = []
}
e)
END
;
......@@ -999,10 +1012,14 @@ value ocaml_psig_modtype loc s mto =
value ocaml_psig_open loc li =
IFDEF OCAML_VERSION < OCAML_4_01 THEN Psig_open (mkloc loc li)
ELSIFDEF OCAML_VERSION < OCAML_4_02_0 THEN Psig_open Fresh (mkloc loc li)
ELSE
ELSIFDEF OCAML_VERSION < OCAML_4_08 THEN
Psig_open
{popen_lid = mknoloc li; popen_override = Fresh; popen_loc = loc;
popen_attributes = []}
ELSE
Psig_open
{popen_expr = mknoloc li; popen_override = Fresh; popen_loc = loc;
popen_attributes = []}
END
;
......@@ -1136,10 +1153,21 @@ value ocaml_pstr_module loc s me =
value ocaml_pstr_open loc li =
IFDEF OCAML_VERSION < OCAML_4_01 THEN Pstr_open (mknoloc li)
ELSIFDEF OCAML_VERSION < OCAML_4_02_0 THEN Pstr_open Fresh (mknoloc li)
ELSE
ELSIFDEF OCAML_VERSION < OCAML_4_08 THEN
Pstr_open
{popen_lid = mknoloc li; popen_override = Fresh; popen_loc = loc;
popen_attributes = []}
ELSE
Pstr_open
{ popen_expr =
{ pmod_desc = Pmod_ident (mknoloc li)
; pmod_loc = loc_none
; pmod_attributes = []
}
; popen_override = Fresh
; popen_loc = loc
; popen_attributes = []
}
END
;
......
(* camlp5r *)
(* pcaml.ml,v *)
(* Copyright (c) INRIA 2007-2018 *)
(* Copyright (c) INRIA 2007-2019 *)
#load "pa_macro.cmo";
#load "pa_extend.cmo";
open Printf;
value version = "7.07";
value version = "7.08";
value syntax_name = ref "";
value ocaml_version =
......
......@@ -101,28 +101,30 @@ and print_symbol1 ppf =
and print_rule ppf symbols =
fprintf ppf "@[<hov 0>";
let _ =
List.fold_left
(List.fold_left
(fun sep symbol ->
fprintf ppf "%t%a" sep print_symbol symbol;
fun ppf -> fprintf ppf ";@ ")
(fun ppf -> ()) symbols
(fun ppf -> ()) symbols :
_ -> _)
in
fprintf ppf "@]"
and print_level ppf pp_print_space rules =
fprintf ppf "@[<hov 0>[ ";
let _ =
List.fold_left
(List.fold_left
(fun sep rule ->
fprintf ppf "%t%a" sep print_rule rule;
fun ppf -> fprintf ppf "%a| " pp_print_space ())
(fun ppf -> ()) rules
(fun ppf -> ()) rules :
_ -> _)
in
fprintf ppf " ]@]"
;;
let print_levels ppf elev =
let _ =
List.fold_left
(List.fold_left
(fun sep lev ->
let rules =
List.map (fun t -> Sself :: t) (flatten_tree lev.lsuffix) @
......@@ -141,7 +143,8 @@ let print_levels ppf elev =
fprintf ppf "@]@;<1 2>";
print_level ppf pp_force_newline rules;
fun ppf -> fprintf ppf "@,| ")
(fun ppf -> ()) elev
(fun ppf -> ()) elev :
_ -> _)
in
()
;;
......
......@@ -747,6 +747,62 @@ let rec any_to_nl buf (strm__ : _ Stream.t) =
| _ -> buf
;;
let rec rawstring1 (ofs, delim) ctx buf (strm__ : _ Stream.t) =
let bp = Stream.count strm__ in
match Stream.peek strm__ with
Some c ->
Stream.junk strm__;
let strm = strm__ in
ctx.line_cnt bp c;
let buf = Plexing.Lexbuf.add c buf in
if String.get delim ofs <> c then rawstring1 (0, delim) ctx buf strm
else if ofs + 1 < String.length delim then
rawstring1 (ofs + 1, delim) ctx buf strm
else
let s = Plexing.Lexbuf.get buf in
let slen = String.length s in
"STRING", String.escaped (String.sub s 0 (slen - String.length delim))
| _ -> raise Stream.Failure
;;
let rec rawstring0 ctx bp buf (strm__ : _ Stream.t) =
let bp = Stream.count strm__ in
match Stream.peek strm__ with
Some '|' ->
Stream.junk strm__;
rawstring1 (0, "|" ^ Plexing.Lexbuf.get buf ^ "}") ctx
Plexing.Lexbuf.empty strm__
| Some ('a'..'z' | '_' as c) ->
Stream.junk strm__; rawstring0 ctx bp (Plexing.Lexbuf.add c buf) strm__
| _ -> raise Stream.Failure
;;
(*
* predicate checks that the stream contains "[:alpha:]+|", and it gets
* called when the main lexer has already seen a "{". To check for at least
* one alpha, require that the offset of the "|" be > 1 (which means that
* offset 1 must be [:alpha:].
*
* The further check for alpha here is unnecessary, since the main lexer will
* NOT call this function in the case where the input is "{|" (because that's
* a valid token, and precedes the branch where this code is invoked.
*)
let raw_string_starter_p strm =
let rec predrec n =
match stream_peek_nth n strm with
None -> false
| Some ('a'..'z' | '_') -> predrec (n + 1)
| Some '|' when n > 1 -> true
| Some _ -> false
in
predrec 1
;;
let keyword_or_error_or_rawstring ctx bp (loc, s) buf strm =
if not (raw_string_starter_p strm) then keyword_or_error ctx loc "{"
else rawstring0 ctx bp Plexing.Lexbuf.empty strm
;;
let next_token_after_spaces ctx bp buf (strm__ : _ Stream.t) =
match Stream.peek strm__ with
Some ('A'..'Z' as c) ->
......@@ -952,7 +1008,8 @@ let next_token_after_spaces ctx bp buf (strm__ : _ Stream.t) =
end
| Some '{' ->
Stream.junk strm__;
begin match Stream.npeek 2 strm__ with
begin try
match Stream.npeek 2 strm__ with
['<'; '<'] | ['<'; ':'] ->
keyword_or_error ctx (bp, Stream.count strm__)
(Plexing.Lexbuf.get (Plexing.Lexbuf.add '{' buf))
......@@ -977,8 +1034,11 @@ let next_token_after_spaces ctx bp buf (strm__ : _ Stream.t) =
(Plexing.Lexbuf.add ':'
(Plexing.Lexbuf.add '{' buf)))
| _ ->
keyword_or_error ctx (bp, Stream.count strm__)
(Plexing.Lexbuf.get (Plexing.Lexbuf.add '{' buf))
keyword_or_error_or_rawstring ctx bp
((bp, Stream.count strm__),
Plexing.Lexbuf.get buf)
(Plexing.Lexbuf.add '{' buf) strm__
with Stream.Failure -> raise (Stream.Error "")
end
| Some '.' ->
Stream.junk strm__;
......@@ -1438,15 +1498,15 @@ let gmake () =
let glexr =
ref
{Plexing.tok_func =
(fun _ -> raise (Match_failure ("plexer.ml", 743, 25)));
(fun _ -> raise (Match_failure ("plexer.ml", 797, 25)));
Plexing.tok_using =
(fun _ -> raise (Match_failure ("plexer.ml", 743, 45)));
(fun _ -> raise (Match_failure ("plexer.ml", 797, 45)));
Plexing.tok_removing =
(fun _ -> raise (Match_failure ("plexer.ml", 743, 68)));
(fun _ -> raise (Match_failure ("plexer.ml", 797, 68)));
Plexing.tok_match =
(fun _ -> raise (Match_failure ("plexer.ml", 744, 18)));
(fun _ -> raise (Match_failure ("plexer.ml", 798, 18)));
Plexing.tok_text =
(fun _ -> raise (Match_failure ("plexer.ml", 744, 37)));
(fun _ -> raise (Match_failure ("plexer.ml", 798, 37)));
Plexing.tok_comm = None}
in
let glex =
......
......@@ -325,7 +325,17 @@ let ocaml_pexp_newtype = Some (fun loc s e -> Pexp_newtype (mkloc loc s, e));;
let ocaml_pexp_object = Some (fun cs -> Pexp_object cs);;
let ocaml_pexp_open = Some (fun li e -> Pexp_open (Fresh, mknoloc li, e));;
let ocaml_pexp_open =
Some
(fun li e ->
Pexp_open
({popen_expr =
{pmod_desc = Pmod_ident (mknoloc li); pmod_loc = loc_none;
pmod_attributes = []};
popen_override = Fresh; popen_loc = loc_none;
popen_attributes = []},
e))
;;
let ocaml_pexp_override sel =
let sel = List.map (fun (s, e) -> mknoloc s, e) sel in Pexp_override sel
......@@ -438,7 +448,7 @@ let ocaml_psig_modtype loc s mto =
let ocaml_psig_open loc li =
Psig_open
{popen_lid = mknoloc li; popen_override = Fresh; popen_loc = loc;
{popen_expr = mknoloc li; popen_override = Fresh; popen_loc = loc;
popen_attributes = []}
;;
......@@ -508,8 +518,10 @@ let ocaml_pstr_module loc s me =
let ocaml_pstr_open loc li =
Pstr_open
{popen_lid = mknoloc li; popen_override = Fresh; popen_loc = loc;
popen_attributes = []}
{popen_expr =
{pmod_desc = Pmod_ident (mknoloc li); pmod_loc = loc_none;
pmod_attributes = []};
popen_override = Fresh; popen_loc = loc; popen_attributes = []}
;;
let ocaml_pstr_primitive s vd = Pstr_primitive vd;;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
(* camlp5r *)
(* pcaml.ml,v *)
(* Copyright (c) INRIA 2007-2018 *)
(* Copyright (c) INRIA 2007-2019 *)
(* #load "pa_macro.cmo" *)
(* #load "pa_extend.cmo" *)
open Printf;;
let version = "7.07";;
let version = "7.08";;
let syntax_name = ref "";;
let ocaml_version =
......
......@@ -49,10 +49,7 @@ let path = ref ([] : string list);;
let loadfile file =
if not !initialized then
begin
begin Dynlink.init (); Dynlink.allow_unsafe_modules true end;
initialized := true
end;
begin Dynlink.allow_unsafe_modules true; initialized := true end;
let path =
if !nolib then !path else Odyl_config.standard_library :: !path
in
......
......@@ -105,9 +105,6 @@ val print_locs: formatter -> t list -> unit
val highlight_terminfo:
Lexing.lexbuf -> formatter -> t list -> unit
val highlight_dumb:
Lexing.lexbuf -> formatter -> t list -> unit
(** {1 Reporting errors and warnings} *)
......@@ -119,8 +116,10 @@ val msg: ?loc:t -> ('a, Format.formatter, unit, msg) format4 -> 'a
type report_kind =
| Report_error
| Report_warning of int
| Report_warning_as_error of int
| Report_warning of string
| Report_warning_as_error of string
| Report_alert of string
| Report_alert_as_error of string
type report = {
kind : report_kind;
......@@ -158,7 +157,6 @@ type report_printer = {
val batch_mode_printer: report_printer
val terminfo_toplevel_printer: Lexing.lexbuf -> report_printer
val dumb_toplevel_printer: Lexing.lexbuf -> report_printer
val best_toplevel_printer: unit -> report_printer
(** Detects the terminal capabilities and selects an adequate printer *)
......@@ -205,8 +203,35 @@ val prerr_warning: t -> Warnings.t -> unit
(** Same as [print_warning], but uses [!formatter_for_warnings] as output
formatter. *)
(** {1 Reporting alerts} *)
(** {2 Converting an [Alert.t] into a [report]} *)
val report_alert: t -> Warnings.alert -> report option
(** [report_alert loc w] produces a report for the given alert [w], or
[None] if the alert is not to be printed. *)
val alert_reporter: (t -> Warnings.alert -> report option) ref
(** Hook for intercepting alerts. *)
val default_alert_reporter: t -> Warnings.alert -> report option
(** Original alert reporter for use in hooks. *)
(** {2 Printing alerts} *)
val print_alert: t -> formatter -> Warnings.alert -> unit
(** Prints an alert. This is simply the composition of [report_alert] and
[print_report]. *)
val prerr_alert: t -> Warnings.alert -> unit
(** Same as [print_alert], but uses [!formatter_for_warnings] as output
formatter. *)
val deprecated: ?def:t -> ?use:t -> t -> string -> unit
(** Prints a deprecation warning. *)
(** Prints a deprecation alert. *)
val alert: ?def:t -> ?use:t -> kind:string -> t -> string -> unit
(** Prints an arbitrary alert. *)
(** {1 Reporting errors} *)
......
......@@ -368,10 +368,13 @@ and expression_desc =
(module ME : S) is represented as
Pexp_constraint(Pexp_pack, Ptyp_package S) *)
| Pexp_open of override_flag * Longident.t loc * expression
| Pexp_open of open_declaration * expression
(* M.(E)
let open M in E
let! open M in E *)
| Pexp_letop of letop
(* let* P = E in E
let* P = E and* P = E in E *)
| Pexp_extension of extension
(* [%id] *)
| Pexp_unreachable
......@@ -384,6 +387,21 @@ and case = (* (P -> E) or (P when E0 -> E) *)
pc_rhs: expression;
}
and letop =
{
let_ : binding_op;
ands : binding_op list;
body : expression;
}
and binding_op =
{
pbop_op : string loc;
pbop_pat : pattern;
pbop_exp : expression;
pbop_loc : Location.t;
}
(* Value descriptions *)
and value_description =
......@@ -535,7 +553,7 @@ and class_type_desc =
*)
| Pcty_extension of extension
(* [%id] *)
| Pcty_open of override_flag * Longident.t loc * class_type
| Pcty_open of open_description * class_type
(* let open M in CT *)
and class_signature =
......@@ -627,7 +645,7 @@ and class_expr_desc =
(* (CE : CT) *)
| Pcl_extension of extension
(* [%id] *)
| Pcl_open of override_flag * Longident.t loc * class_expr
| Pcl_open of open_description * class_expr
(* let open M in CE *)
......@@ -720,12 +738,17 @@ and signature_item_desc =
*)
| Psig_type of rec_flag * type_declaration list
(* type t1 = ... and ... and tn = ... *)
| Psig_typesubst of type_declaration list
(* type t1 := ... and ... and tn := ... *)
| Psig_typext of type_extension
(* type t1 += ... *)
| Psig_exception of type_exception
(* exception C of T *)
| Psig_module of module_declaration
(* module X : MT *)
(* module X = M
module X : MT *)
| Psig_modsubst of module_substitution
(* module X := M *)
| Psig_recmodule of module_declaration list
(* module rec X1 : MT1 and ... and Xn : MTn *)
| Psig_modtype of module_type_declaration
......@@ -753,6 +776,14 @@ and module_declaration =
}
(* S : MT *)
and module_substitution =
{
pms_name: string loc;
pms_manifest: Longident.t loc;
pms_attributes: attributes; (* ... [@@id1] [@@id2] *)
pms_loc: Location.t;
}
and module_type_declaration =
{
pmtd_name: string loc;
......@@ -764,9 +795,9 @@ and module_type_declaration =
S (abstract module type declaration, pmtd_type = None)
*)
and open_description =
and 'a open_infos =
{
popen_lid: Longident.t loc;
popen_expr: 'a;
popen_override: override_flag;
popen_loc: Location.t;
popen_attributes: attributes;
......@@ -776,6 +807,15 @@ and open_description =
open X - popen_override = Fresh
*)
and open_description = Longident.t loc open_infos
(* open M.N
open M(N).O *)
and open_declaration = module_expr open_infos
(* open M.N
open M(N).O
open struct ... end *)
and 'a include_infos =
{
pincl_mod: 'a;
......@@ -858,7 +898,7 @@ and structure_item_desc =
(* module rec X1 = ME1 and ... and Xn = MEn *)
| Pstr_modtype of module_type_declaration
(* module type S = MT *)
| Pstr_open of open_description
| Pstr_open of open_declaration
(* open X *)
| Pstr_class of class_declaration list
(* class c1 = ... and ... and cn = ... *)
......
let ast_impl_magic_number = "Caml1999M023"
let ast_intf_magic_number = "Caml1999N023"
let ast_impl_magic_number = "Caml1999M025"
let ast_intf_magic_number = "Caml1999N025"