]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/lambda-delta/basic_rg/brg.ml
basic_rg: bugfix in AST to allow attributes in global entries
[helm.git] / helm / software / lambda-delta / basic_rg / brg.ml
index 5ad05a72f7da075221bedd10490b63900ddcf438..779a121e603042965c694c3d8f42d45bad083a7c 100644 (file)
@@ -20,32 +20,32 @@ type attr = Name of bool * id  (* real?, name *)
 
 type attrs = attr list
 
-type bind = Void         (* exclusion *)
-          | Abst of term (* abstraction *)
-          | Abbr of term (* abbreviation *)
+type bind = Void of attrs        (* attrs       *)
+          | Abst of attrs * term (* attrs, type *)
+          | Abbr of attrs * term (* attrs, body *)
 
 and term = Sort of attrs * int         (* attrs, hierarchy index *)
          | LRef of attrs * int         (* attrs, position index *)
          | GRef of attrs * uri         (* attrs, reference *)
          | Cast of attrs * term * term (* attrs, type, term *)
          | Appl of attrs * term * term (* attrs, argument, function *)
-         | Bind of attrs * bind * term (* attrs, binder, scope *)
+         | Bind of bind * term         (* binder, scope *)
 
 type obj = bind Item.obj (* age, uri, binder *)
 
 type item = bind Item.item
 
 type context = Null
-(* Cons: tail, relative context, attrs, binder *) 
-             | Cons of context * context option * attrs * bind 
+(* Cons: tail, relative context, binder *) 
+             | Cons of context * context option * bind 
 
 type message = (context, term) Log.item list
 
 (* Currified constructors ***************************************************)
 
-let abst w = Abst w
+let abst a w = Abst (a, w)
 
-let abbr v = Abbr v
+let abbr a v = Abbr (a, v)
 
 let lref a i = LRef (a, i)
 
@@ -53,40 +53,40 @@ let cast a u t = Cast (a, u, t)
 
 let appl a u t = Appl (a, u, t)
 
-let bind a b t = Bind (a, b, t)
+let bind b t = Bind (b, t)
 
-let bind_abst a u t = Bind (a, Abst u, t)
+let bind_abst a u t = Bind (Abst (a, u), t)
 
-let bind_abbr a v t = Bind (a, Abbr v, t)
+let bind_abbr a v t = Bind (Abbr (a, v), t)
 
 (* context handling functions ***********************************************)
 
 let empty_context = Null
 
-let push f es ?c b =
-   let es = Cons (es, c, a, b) in f es
+let push f es ?c b =
+   let es = Cons (es, c, b) in f es
 
 let get err f es i =
    let rec aux j = function
-      | Null                               -> err i
-      | Cons (tl, None, a, b)   when j = 0 -> f tl a b
-      | Cons (_, Some c, a, b) when j = 0  -> f c a b
-      | Cons (tl, _, _, _)                 -> aux (pred j) tl
+      | Null                            -> err i
+      | Cons (tl, None, b)   when j = 0 -> f tl b
+      | Cons (_, Some c, b) when j = 0  -> f c b
+      | Cons (tl, _, _)                 -> aux (pred j) tl
    in
    aux i es
 
 let rec rev_iter f map = function   
-   | Null                    -> f ()
-   | Cons (tl, None, a, b)   -> 
-      let f () = map f tl b in rev_iter f map tl
-   | Cons (tl, Some c, a, b) -> 
-      let f () = map f c b in rev_iter f map tl
+   | Null                 -> f ()
+   | Cons (tl, None, b)   -> 
+      let f () = map f tl b in rev_iter f map tl
+   | Cons (tl, Some c, b) -> 
+      let f () = map f c b in rev_iter f map tl
 
 let rec fold_left f map x = function
-   | Null               -> f x
-   | Cons (tl, _, a, b) ->
+   | Null            -> f x
+   | Cons (tl, _, b) ->
       let f x = fold_left f map x tl in
-      map f x b
+      map f x b
 
 let rec name err f = function
    | []               -> err ()