Mise à jour terminée. Pour connaître les apports de la version 13.8.4 par rapport à notre ancienne version vous pouvez lire les "Release Notes" suivantes :
https://about.gitlab.com/releases/2021/02/11/security-release-gitlab-13-8-4-released/
https://about.gitlab.com/releases/2021/02/05/gitlab-13-8-3-released/

parameters.ml 1.65 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
(* TEMPORARY clean up and write an .mli file *)

open Syntax
open Positions

let app p ps =
  match ps with
  | [] ->
      ParameterVar p
  | _ ->
      ParameterApp (p, ps)

let unapp = function
  | ParameterVar x ->
      (x, [])
  | ParameterApp (p, ps) ->
      (p, ps)
18 19 20
  | ParameterAnonymous _ ->
      (* Anonymous rules are eliminated early on. *)
      assert false
21 22 23 24 25 26

let rec map f = function
  | ParameterVar x ->
      ParameterVar (f x)
  | ParameterApp (p, ps) ->
      ParameterApp (f p, List.map (map f) ps)
27 28 29
  | ParameterAnonymous _ ->
      (* Anonymous rules are eliminated early on. *)
      assert false
30 31 32 33 34 35

let rec fold f init = function
  | ParameterVar x ->
      f init x
  | ParameterApp (p, ps) ->
      f (List.fold_left (fold f) init ps) p
36 37 38
  | ParameterAnonymous _ ->
      (* Anonymous rules are eliminated early on. *)
      assert false
POTTIER Francois's avatar
POTTIER Francois committed
39 40

let identifiers m p =
41
  fold (fun accu x -> StringMap.add x.value x.position accu) m p
42 43 44

type t = parameter

POTTIER Francois's avatar
POTTIER Francois committed
45
let rec equal x y =
46
  match x, y with
47 48
    | ParameterVar x, ParameterVar y ->
        x.value = y.value
49
    | ParameterApp (p1, p2), ParameterApp (p1', p2') ->
50
        p1.value = p1'.value && List.for_all2 equal p2 p2'
51 52 53
    | _ ->
        (* Anonymous rules are eliminated early on. *)
        false
54 55 56 57 58

let hash = function
  | ParameterVar x
  | ParameterApp (x, _) ->
      Hashtbl.hash (Positions.value x)
59 60 61
  | ParameterAnonymous _ ->
      (* Anonymous rules are eliminated early on. *)
      assert false
62 63

let position = function
POTTIER Francois's avatar
POTTIER Francois committed
64
  | ParameterVar x
65 66
  | ParameterApp (x, _) ->
      Positions.position x
67 68
  | ParameterAnonymous bs ->
      Positions.position bs
69 70 71

let with_pos p =
  Positions.with_pos (position p) p