Commit 58f83dea authored by POTTIER Francois's avatar POTTIER Francois

Update BasicSyntax to keep the location of every producer identifier.

parent 39d2e899
...@@ -33,7 +33,7 @@ let drop_parameter (param : S.parameter) : S.symbol = ...@@ -33,7 +33,7 @@ let drop_parameter (param : S.parameter) : S.symbol =
let drop_producer ((id, param, attrs) : S.producer) : T.producer = let drop_producer ((id, param, attrs) : S.producer) : T.producer =
{ {
T.producer_identifier = value id; T.producer_identifier = id;
T.producer_symbol = drop_parameter param; T.producer_symbol = drop_parameter param;
T.producer_attributes = attrs T.producer_attributes = attrs
} }
......
...@@ -31,11 +31,12 @@ open Syntax ...@@ -31,11 +31,12 @@ open Syntax
(* ------------------------------------------------------------------------ *) (* ------------------------------------------------------------------------ *)
(* A producer is a pair of identifier and a symbol. In concrete syntax, it (* A producer is a pair of a (located) identifier and a symbol. In concrete
could be [e = expr], for instance. It carries a number of attributes. *) syntax, it could be [e = expr], for instance. It carries a number of
attributes. *)
type producer = { type producer = {
producer_identifier : identifier; producer_identifier : identifier located;
producer_symbol : symbol; producer_symbol : symbol;
producer_attributes : attributes; producer_attributes : attributes;
} }
...@@ -95,9 +96,17 @@ type grammar = { ...@@ -95,9 +96,17 @@ type grammar = {
(* Accessors for the type [producer]. *) (* Accessors for the type [producer]. *)
let producer_identifier { producer_identifier } = producer_identifier let producer_identifier { producer_identifier } : identifier =
let producer_symbol { producer_symbol } = producer_symbol Positions.value producer_identifier
let producer_attributes { producer_attributes } = producer_attributes
let producer_identifier_located { producer_identifier } : identifier located =
producer_identifier
let producer_symbol { producer_symbol } =
producer_symbol
let producer_attributes { producer_attributes } =
producer_attributes
(* -------------------------------------------------------------------------- *) (* -------------------------------------------------------------------------- *)
......
...@@ -161,12 +161,14 @@ let rec fresh names x = ...@@ -161,12 +161,14 @@ let rec fresh names x =
let rename (used : StringSet.t) producers: Action.subst * producers = let rename (used : StringSet.t) producers: Action.subst * producers =
let phi, _used, producers = let phi, _used, producers =
List.fold_left (fun (phi, used, producers) producer -> List.fold_left (fun (phi, used, producers) producer ->
let x = producer_identifier producer in let id = producer_identifier_located producer in
let x = Positions.value id in
if StringSet.mem x used then if StringSet.mem x used then
let x' = fresh used x in let x' = fresh used x in
let id' = Positions.map (fun _x -> x') id in
(x, x') :: phi, (x, x') :: phi,
StringSet.add x' used, StringSet.add x' used,
{ producer with producer_identifier = x' } :: producers { producer with producer_identifier = id' } :: producers
else else
(phi, StringSet.add x used, producer :: producers) (phi, StringSet.add x used, producer :: producers)
) ([], used, []) producers ) ([], used, []) producers
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment