diff --git a/lib/charset.ml b/lib/charset.ml index 484770c..0c8c127 100644 --- a/lib/charset.ml +++ b/lib/charset.ml @@ -12,17 +12,17 @@ way of building parsers using an extention of OCaml's syntax. This software is governed by the CeCILL-B license under French law and - abiding by the rules of distribution of free software. You can use, + abiding by the rules of distribution of free software. You can use, modify and/or redistribute the software under the terms of the CeCILL- B license as circulated by CEA, CNRS and INRIA at the following URL. - http://www.cecill.info + http://www.cecill.info As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited - liability. + liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the @@ -33,7 +33,7 @@ encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their sys- tems and/or data to be ensured and, more generally, to use and operate - it in the same conditions as regards security. + it in the same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL-B license and that you accept its terms. diff --git a/lib/charset.mli b/lib/charset.mli index c2c32fc..e266c86 100644 --- a/lib/charset.mli +++ b/lib/charset.mli @@ -12,17 +12,17 @@ way of building parsers using an extention of OCaml's syntax. This software is governed by the CeCILL-B license under French law and - abiding by the rules of distribution of free software. You can use, + abiding by the rules of distribution of free software. You can use, modify and/or redistribute the software under the terms of the CeCILL- B license as circulated by CEA, CNRS and INRIA at the following URL. - http://www.cecill.info + http://www.cecill.info As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited - liability. + liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the @@ -33,7 +33,7 @@ encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their sys- tems and/or data to be ensured and, more generally, to use and operate - it in the same conditions as regards security. + it in the same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL-B license and that you accept its terms. diff --git a/lib/earley_str.mli b/lib/earley_str.mli index b549aa3..5283f87 100644 --- a/lib/earley_str.mli +++ b/lib/earley_str.mli @@ -12,17 +12,17 @@ way of building parsers using an extention of OCaml's syntax. This software is governed by the CeCILL-B license under French law and - abiding by the rules of distribution of free software. You can use, + abiding by the rules of distribution of free software. You can use, modify and/or redistribute the software under the terms of the CeCILL- B license as circulated by CEA, CNRS and INRIA at the following URL. - http://www.cecill.info + http://www.cecill.info As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited - liability. + liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the @@ -33,7 +33,7 @@ encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their sys- tems and/or data to be ensured and, more generally, to use and operate - it in the same conditions as regards security. + it in the same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL-B license and that you accept its terms. @@ -45,7 +45,7 @@ open Earley_core.Input open Earley_core.Earley -(** [blank_regexp re] produces a blank function from the regexp [re] +(** [blank_regexp re] produces a blank function from the regexp [re] (following the [Str] syntax). There is an important limitation rega- rding regular expressions containing the newline character ['\n'], due to the fact that the [Str] module only matches on strings (and diff --git a/lib/internals.ml b/lib/internals.ml index 06de862..dfeb96d 100644 --- a/lib/internals.ml +++ b/lib/internals.ml @@ -711,8 +711,8 @@ let pred_prod_lec : type a. errpos -> a final -> a cur -> a reads try let res = Ref.find tmemo memo in res (* Check if this was done *) with Not_found -> - let rules = List.filter (good c) rules in - Ref.add tmemo memo rules; + let rules = List.filter (good c) rules in + Ref.add tmemo memo rules; List.iter (fun rule -> let start = cur_pos in diff --git a/lib/regexp.ml b/lib/regexp.ml index 71cab21..4a387e8 100644 --- a/lib/regexp.ml +++ b/lib/regexp.ml @@ -12,17 +12,17 @@ way of building parsers using an extention of OCaml's syntax. This software is governed by the CeCILL-B license under French law and - abiding by the rules of distribution of free software. You can use, + abiding by the rules of distribution of free software. You can use, modify and/or redistribute the software under the terms of the CeCILL- B license as circulated by CEA, CNRS and INRIA at the following URL. - http://www.cecill.info + http://www.cecill.info As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited - liability. + liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the @@ -33,7 +33,7 @@ encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their sys- tems and/or data to be ensured and, more generally, to use and operate - it in the same conditions as regards security. + it in the same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL-B license and that you accept its terms. diff --git a/lib/regexp.mli b/lib/regexp.mli index 035837e..9664380 100644 --- a/lib/regexp.mli +++ b/lib/regexp.mli @@ -12,17 +12,17 @@ way of building parsers using an extention of OCaml's syntax. This software is governed by the CeCILL-B license under French law and - abiding by the rules of distribution of free software. You can use, + abiding by the rules of distribution of free software. You can use, modify and/or redistribute the software under the terms of the CeCILL- B license as circulated by CEA, CNRS and INRIA at the following URL. - http://www.cecill.info + http://www.cecill.info As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited - liability. + liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the @@ -33,7 +33,7 @@ encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their sys- tems and/or data to be ensured and, more generally, to use and operate - it in the same conditions as regards security. + it in the same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL-B license and that you accept its terms. diff --git a/pa_ocaml/pa_ast.ml b/pa_ocaml/pa_ast.ml index 5b528df..a2562ff 100644 --- a/pa_ocaml/pa_ast.ml +++ b/pa_ocaml/pa_ast.ml @@ -87,8 +87,8 @@ let rec merge = function | [loc] -> loc | l2::ls when Location.(l2.loc_start = l2.loc_end) -> fn ls | l2::ls -> - Location.( - {loc_start = l1.loc_start; loc_end = l2.loc_end; loc_ghost = l1.loc_ghost && l2.loc_ghost}) + Location.( + {loc_start = l1.loc_start; loc_end = l2.loc_end; loc_ghost = l1.loc_ghost && l2.loc_ghost}) in fn ls let merge2 l1 l2 = diff --git a/pa_ocaml/pa_lexing.ml b/pa_ocaml/pa_lexing.ml index a888037..a9c9697 100644 --- a/pa_ocaml/pa_lexing.ml +++ b/pa_ocaml/pa_lexing.ml @@ -115,15 +115,15 @@ let ocaml_blank buf pos = | (`Ini , [] , _ ) -> curr | (`Opn(p) , _ , '*' ) -> (if stack = [] then - let (c, buf', pos') = Input.read buf' pos' in - let (c',_,_) = Input.read buf' pos' in - if c = '*' && c' <> '*' then ( - ocamldoc := true; - fn `Cls (p::stack) curr (buf',pos')) - else - fn `Ini (p::stack) curr next - else - fn `Ini (p::stack) curr next) + let (c, buf', pos') = Input.read buf' pos' in + let (c',_,_) = Input.read buf' pos' in + if c = '*' && c' <> '*' then ( + ocamldoc := true; + fn `Cls (p::stack) curr (buf',pos')) + else + fn `Ini (p::stack) curr next + else + fn `Ini (p::stack) curr next) | (`Opn(_) , _::_, '"' ) -> fn (`Str(curr)) stack curr next (*#*) | (`Opn(_) , _::_, '{' ) -> fn (`SOp([],curr)) stack curr next (*#*) | (`Opn(_) , _::_, '(' ) -> fn (`Opn(curr)) stack curr next @@ -166,13 +166,13 @@ let ocaml_blank buf pos = | (`Cls , _::_, '{' ) -> fn (`SOp([],curr)) stack curr next (*#*) | (`Cls , p::s, ')' ) -> if !ocamldoc && s = [] then ( - let comment = + let comment = try Buffer.sub ocamldoc_buf 0 (Buffer.length ocamldoc_buf - 2) with Invalid_argument _ -> "" in - Buffer.clear ocamldoc_buf; - ocamldoc_comments := (p,next,comment,!previous_newline)::!ocamldoc_comments; - ocamldoc := false + Buffer.clear ocamldoc_buf; + ocamldoc_comments := (p,next,comment,!previous_newline)::!ocamldoc_comments; + ocamldoc := false ); new_line := false; fn `Ini s curr next diff --git a/pa_ocaml/pa_ocaml.ml b/pa_ocaml/pa_ocaml.ml index 2cb8321..1905c44 100644 --- a/pa_ocaml/pa_ocaml.ml +++ b/pa_ocaml/pa_ocaml.ml @@ -465,12 +465,12 @@ let parser constr_decl with_bar = | (bar with_bar) cn:constr_name2 (args,res):{ te:{_:of_kw { _:'(' te:typexpr _:')' -> (te,true) | te:typexpr_nopar -> (te,false) }}? -> - let tes = - match te with - | None -> [] - | Some ({ ptyp_desc = Ptyp_tuple tes }, false) -> tes - | Some (t,_) -> [t] - in + let tes = + match te with + | None -> [] + | Some ({ ptyp_desc = Ptyp_tuple tes }, false) -> tes + | Some (t,_) -> [t] + in (Pcstr_tuple tes, None) | of_kw '{' fds:field_decl_list '}' -> (Pcstr_record fds, None) | ':' tes:{te:(typexpr_lvl (next_type_prio ProdType)) @@ -548,20 +548,20 @@ let typedef_gen = (fun att constr filter -> a:{post_item_attributes when att | EMPTY when not att -> []} -> (fun prev_loc -> let _loc = match - (prev_loc:Location.t option) with None -> _loc - | Some l -> merge2 l _loc + (prev_loc:Location.t option) with None -> _loc + | Some l -> merge2 l _loc in let (pri, te, tkind, cstrs) = ti in let pri, te = match te with - None -> pri, None - | Some(Private, te) -> - if pri = Private then give_up (); (* ty = private ty' = private A | B is not legal *) - Private, Some te - | Some(_, te) -> pri, Some te + None -> pri, None + | Some(Private, te) -> + if pri = Private then give_up (); (* ty = private ty' = private A | B is not legal *) + Private, Some te + | Some(_, te) -> pri, Some te in id_loc tcn _loc_tcn, type_declaration ~attributes:(if att then attach_attrib _loc a else []) - _loc (id_loc (filter tcn) _loc_tcn) tps cstrs tkind pri te) + _loc (id_loc (filter tcn) _loc_tcn) tps cstrs tkind pri te) ) let parser type_extension = @@ -715,7 +715,7 @@ let _ = set_pattern_lvl (fun @(as_ok,lvl) -> parser | '(' p:pattern ty:{_:':' typexpr}? ')' -> let p = match ty with - None -> loc_pat _loc p.ppat_desc + None -> loc_pat _loc p.ppat_desc | Some ty -> Pat.constraint_ ~loc:_loc p ty in p @@ -752,7 +752,7 @@ let _ = set_pattern_lvl (fun @(as_ok,lvl) -> parser match pat with | Some p -> (lab, p) | None -> - let slab = match lab.txt with + let slab = match lab.txt with | Lident s -> id_loc s lab.loc | _ -> give_up () in (lab, loc_pat lab.loc (Ppat_var slab)) @@ -829,7 +829,7 @@ let infix_prio s = | '<' -> if String.length s > 1 && s.[1] = '-' then Aff else Eq | '@' | '^' -> Append | '&' -> if String.length s = 1 || - (String.length s = 2 && s.[1] = '&') then Conj else Eq + (String.length s = 2 && s.[1] = '&') then Conj else Eq | '|' -> if String.length s = 2 && s.[1] = '|' then Disj else Eq | '=' | '>' | '$' | '!' -> Eq | 'o' -> Disj @@ -949,7 +949,7 @@ let apply_params_cls ?(gh=false) _loc params e = let parser right_member = | l:{lb:(parameter true) -> lb, _loc_lb}+ ty:{CHR(':') t:typexpr}? CHR('=') e:expression -> let e = match ty with - None -> e + None -> e | Some ty -> loc_expr (ghost (merge2 _loc_ty _loc)) (pexp_constraint(e, ty)) in apply_params ~gh:true _loc_e l e @@ -988,7 +988,7 @@ let _ = set_grammar let_binding ( let loc = merge2 _loc_vn _loc_e in let (e, ty) = wrap_type_annotation loc ids ty e in let pat = loc_pat (ghost loc) (Ppat_constraint( - loc_pat _loc_vn (Ppat_var(id_loc vn _loc_vn)), + loc_pat _loc_vn (Ppat_var(id_loc vn _loc_vn)), ty)) in value_binding ~attributes:(attach_attrib loc a) loc pat e::l @@ -1101,10 +1101,10 @@ let parser class_field = let (o,p,mn) = t in if ps = [] && te <> None then give_up (); let e = - match te with - None -> e - | Some te -> - loc_expr (ghost (merge2 _loc_te _loc_e)) (pexp_constraint (e, te)) + match te with + None -> e + | Some te -> + loc_expr (ghost (merge2 _loc_te _loc_e)) (pexp_constraint (e, te)) in let e : expression = apply_params ~gh:true _loc_e ps e in let e = loc_expr (ghost (merge2 _loc_t _loc_e)) (Pexp_poly (e, None)) in @@ -1151,9 +1151,9 @@ let pexp_list _loc ?loc_cl l = else let loc_cl = ghost (match loc_cl with None -> _loc | Some pos -> pos) in List.fold_right (fun (x,pos) acc -> - let _loc = ghost (merge2 pos loc_cl) in - loc_expr _loc (pexp_construct(id_loc (Lident "::") (ghost _loc), Some (loc_expr _loc (Pexp_tuple [x;acc]))))) - l (loc_expr loc_cl (pexp_construct(id_loc (Lident "[]") loc_cl, None))) + let _loc = ghost (merge2 pos loc_cl) in + loc_expr _loc (pexp_construct(id_loc (Lident "::") (ghost _loc), Some (loc_expr _loc (Pexp_tuple [x;acc]))))) + l (loc_expr loc_cl (pexp_construct(id_loc (Lident "[]") loc_cl, None))) let apply_lbl _loc (lbl, e) = @@ -1165,8 +1165,8 @@ let apply_lbl _loc (lbl, e) = let rec mk_seq loc_c final = function | [] -> final | x::l -> - let res = mk_seq loc_c final l in - loc_expr (merge2 x.pexp_loc loc_c) (Pexp_sequence(x,res)) + let res = mk_seq loc_c final l in + loc_expr (merge2 x.pexp_loc loc_c) (Pexp_sequence(x,res)) (* Expressions *) let parser extra_expressions_grammar c = @@ -1203,8 +1203,8 @@ let parser left_expr @(alm,lvl) = Exp.letmodule ~loc mn me e) | open_kw o:override_flag mp:module_path -> (fun e (_l,_) -> - (let mp = id_loc mp _loc_mp in - Exp.open_ ~loc:_l (Opn.mk ~override:o (Mod.ident mp)) e)) + (let mp = id_loc mp _loc_mp in + Exp.open_ ~loc:_l (Opn.mk ~override:o (Mod.ident mp)) e)) } _:in_kw when allow_let alm && lvl < App -> (Seq, false, f) @@ -1218,26 +1218,26 @@ let parser left_expr @(alm,lvl) = | ls:{(expression_lvl (NoMatch, next_exp Seq)) _:semi_col }+ when lvl <= Seq -> (next_exp Seq, false, (fun e' (_,_l) -> - mk_seq _l e' ls)) + mk_seq _l e' ls)) | v:inst_var_name STR("<-") when lvl <= Aff -> (next_exp Aff, false, (fun e (_l,_) -> loc_expr _l (Pexp_setinstvar(id_loc v _loc_v, e)))) | e':(expression_lvl (NoMatch, Dot)) '.' f:{ STR("(") f:expression STR(")") -> - fun e' e (_l,_) -> exp_apply _l (array_function (ghost (merge2 e'.pexp_loc _l)) "Array" "set") [e';f;e] + fun e' e (_l,_) -> exp_apply _l (array_function (ghost (merge2 e'.pexp_loc _l)) "Array" "set") [e';f;e] - | STR("[") f:expression STR("]") -> - fun e' e (_l,_) -> exp_apply _l (array_function (ghost (merge2 e'.pexp_loc _l)) "String" "set") [e';f;e] + | STR("[") f:expression STR("]") -> + fun e' e (_l,_) -> exp_apply _l (array_function (ghost (merge2 e'.pexp_loc _l)) "String" "set") [e';f;e] - | STR("{") f:expression STR("}") -> - fun e' e (_l,_) -> + | STR("{") f:expression STR("}") -> + fun e' e (_l,_) -> de_ghost (bigarray_set (ghost (merge2 e'.pexp_loc _l)) e' f e) - | f:field -> - fun e' e (_l,_) -> let f = id_loc f _loc_f in loc_expr _l (Pexp_setfield(e',f,e)) + | f:field -> + fun e' e (_l,_) -> let f = id_loc f _loc_f in loc_expr _l (Pexp_setfield(e',f,e)) - } "<-" + } "<-" when lvl <= Aff -> (next_exp Aff, false, f e') @@ -1320,14 +1320,14 @@ let parser right_expression @lvl = (match e with | Some(e) -> loc_expr _loc e.pexp_desc | None -> - let cunit = id_loc (Lident "()") _loc in - loc_expr _loc (pexp_construct(cunit, None))) + let cunit = id_loc (Lident "()") _loc in + loc_expr _loc (pexp_construct(cunit, None))) | '(' no_parser e:expression t:type_coercion ')' when lvl <= Atom -> (match t with - | (Some t1, None) -> loc_expr (ghost _loc) (pexp_constraint(e, t1)) - | (t1, Some t2) -> loc_expr (ghost _loc) (pexp_coerce(e, t1, t2)) - | None, None -> assert false) + | (Some t1, None) -> loc_expr (ghost _loc) (pexp_constraint(e, t1)) + | (t1, Some t2) -> loc_expr (ghost _loc) (pexp_coerce(e, t1, t2)) + | None, None -> assert false) | begin_kw e:expression? end_kw when lvl <= Atom -> (match e with @@ -1343,7 +1343,7 @@ let parser right_expression @lvl = | _ -> Pexp_apply(f,l)) | c:constructor no_dot when lvl <= Atom -> - loc_expr _loc (pexp_construct(id_loc c _loc_c, None)) + loc_expr _loc (pexp_construct(id_loc c _loc_c, None)) | l:tag_name when lvl <= Atom -> loc_expr _loc (Pexp_variant(l, None)) @@ -1380,17 +1380,17 @@ let parser right_expression @lvl = in loc_expr _loc desc | e':{e':(expression_lvl (NoMatch, Dot)) -> e'} '.' r:{ STR("(") f:expression STR(")") -> - fun e' _l -> exp_apply _l (array_function (ghost (merge2 e'.pexp_loc _l)) "Array" "get") [e';f] + fun e' _l -> exp_apply _l (array_function (ghost (merge2 e'.pexp_loc _l)) "Array" "get") [e';f] - | STR("[") f:expression STR("]") -> - fun e' _l -> exp_apply _l (array_function (ghost (merge2 e'.pexp_loc _l)) "String" "get") [e';f] + | STR("[") f:expression STR("]") -> + fun e' _l -> exp_apply _l (array_function (ghost (merge2 e'.pexp_loc _l)) "String" "get") [e';f] - | STR("{") f:expression STR("}") -> - fun e' _l -> bigarray_get (ghost (merge2 e'.pexp_loc _l)) e' f + | STR("{") f:expression STR("}") -> + fun e' _l -> bigarray_get (ghost (merge2 e'.pexp_loc _l)) e' f - | f:field -> - fun e' _l -> - let f = id_loc f _loc_f in loc_expr _l (Pexp_field(e',f)) + | f:field -> + fun e' _l -> + let f = id_loc f _loc_f in loc_expr _l (Pexp_field(e',f)) } when lvl <= Dot -> r e' _loc | e':(expression_lvl (NoMatch, Dash)) '#' f:method_name when lvl <= Dash -> @@ -1581,7 +1581,7 @@ let parser signature_item_base = Sig.exception_ ~loc:_loc (Te.mk_exception ~loc:_loc cd) | module_kw rec_kw mn:module_name ':' mt:module_type a:post_item_attributes ms:{and_kw mn:module_name ':' mt:module_type a:post_item_attributes -> - module_declaration ~attributes:(attach_attrib _loc a) _loc mn mt + module_declaration ~attributes:(attach_attrib _loc a) _loc mn mt }* -> let loc_first = merge2 _loc_mn _loc_a in let m = (module_declaration ~attributes:(attach_attrib loc_first a) loc_first mn mt) in @@ -1596,9 +1596,9 @@ let parser signature_item_base = let attrs = attach_attrib _loc a in Sig.module_ ~loc:_loc (Md.mk ~loc:_loc ~attrs mn mt) | type_kw mn:modtype_name mt:{'=' mt:module_type }? a:post_item_attributes -> - let attrs = attach_attrib _loc a in + let attrs = attach_attrib _loc a in Sig.modtype ~loc:_loc (Mtd.mk ~loc:_loc ~attrs ?typ:mt (id_loc mn _loc_mn)) - } + } | open_kw o:override_flag m:module_path a:post_item_attributes -> let attrs = attach_attrib _loc a in Sig.open_ ~loc:_loc (Opn.mk ~loc:_loc ~attrs ~override:o (id_loc m _loc_m)) diff --git a/sanity_check.sh b/sanity_check.sh new file mode 100755 index 0000000..7ce0fbe --- /dev/null +++ b/sanity_check.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# Check for long lines. +#awk 'length>78 {print "In " FILENAME ", line " FNR " more than 78 characters..."}' \ +# lib/*.ml lib/*.mli pa_ocaml/*.ml + +# Check for trailing spaces. +awk '/.*\s$/ {print "In " FILENAME ", line " FNR " has trailing spaces..."} ' \ + lib/*.ml lib/*.mli pa_ocaml/*.ml + +# Check for tabulations. +awk '/.*\t.*/ {print "In " FILENAME ", line " FNR " contains tabulations..."} ' \ + lib/*.ml lib/*.mli pa_ocaml/*.ml