Commit d71b33d3 authored by POTTIER Francois's avatar POTTIER Francois

Removed [Production.used], since it now always returns [true].

parent 09c47895
...@@ -710,19 +710,12 @@ let runcellparams var holds_state symbol = ...@@ -710,19 +710,12 @@ let runcellparams var holds_state symbol =
symbol this stack cell is associated with. *) symbol this stack cell is associated with. *)
let reducecellparams prod i holds_state symbol = let reducecellparams prod i holds_state symbol =
let ids = Production.identifiers prod let ids = Production.identifiers prod in
and used = Production.used prod in
(* If the semantic value is used in the semantic action, then it is (* The semantic value is bound to the variable [ids.(i)]. *)
bound to the variable [ids.(i)]. If the semantic value is not
used in the semantic action, then it is dropped using a wildcard
pattern. *)
let semvpat _t = let semvpat _t =
if used.(i) then PVar ids.(i)
PVar ids.(i)
else
PWildcard
in in
elementif holds_state (if i = 0 then PVar state else PWildcard) @ elementif holds_state (if i = 0 then PVar state else PWildcard) @
...@@ -1137,7 +1130,6 @@ let reducebody prod = ...@@ -1137,7 +1130,6 @@ let reducebody prod =
let nt, rhs = Production.def prod let nt, rhs = Production.def prod
and ids = Production.identifiers prod and ids = Production.identifiers prod
and used = Production.used prod
and length = Production.length prod in and length = Production.length prod in
(* Build a pattern that represents the shape of the stack. Out of (* Build a pattern that represents the shape of the stack. Out of
...@@ -1167,14 +1159,11 @@ let reducebody prod = ...@@ -1167,14 +1159,11 @@ let reducebody prod =
let unitbindings = let unitbindings =
Misc.foldi length (fun i unitbindings -> Misc.foldi length (fun i unitbindings ->
if used.(i) then match semvtype rhs.(i) with
match semvtype rhs.(i) with | [] ->
| [] -> (PVar ids.(i), EUnit) :: unitbindings
(PVar ids.(i), EUnit) :: unitbindings | _ ->
| _ -> unitbindings
unitbindings
else
unitbindings
) [] ) []
in in
......
...@@ -432,9 +432,6 @@ module Production = struct ...@@ -432,9 +432,6 @@ module Production = struct
let identifiers : identifier array array = let identifiers : identifier array array =
Array.make n [||] Array.make n [||]
let used : bool array array =
Array.make n [||]
let actions : action option array = let actions : action option array =
Array.make n None Array.make n None
...@@ -451,7 +448,6 @@ module Production = struct ...@@ -451,7 +448,6 @@ module Production = struct
and nt' = Nonterminal.lookup (nonterminal ^ "'") in and nt' = Nonterminal.lookup (nonterminal ^ "'") in
table.(k) <- (nt', [| Symbol.N nt |]); table.(k) <- (nt', [| Symbol.N nt |]);
identifiers.(k) <- [| "_1" |]; identifiers.(k) <- [| "_1" |];
used.(k) <- [| true |];
ntprods.(nt') <- (k, k+1); ntprods.(nt') <- (k, k+1);
positions.(k) <- Nonterminal.positions nt; positions.(k) <- Nonterminal.positions nt;
k+1, k+1,
...@@ -473,8 +469,6 @@ module Production = struct ...@@ -473,8 +469,6 @@ module Production = struct
let symbols = Array.of_list branch.producers in let symbols = Array.of_list branch.producers in
table.(k) <- (nt, Array.map (fun (v, _) -> Symbol.lookup v) symbols); table.(k) <- (nt, Array.map (fun (v, _) -> Symbol.lookup v) symbols);
identifiers.(k) <- Array.map snd symbols; identifiers.(k) <- Array.map snd symbols;
(* TEMPORARY: [used] is useless since all arguments are named now. Should we remove it? *)
used.(k) <- Array.map (fun _ -> true) symbols;
actions.(k) <- Some action; actions.(k) <- Some action;
reduce_precedence.(k) <- rprec; reduce_precedence.(k) <- rprec;
prec_decl.(k) <- sprec; prec_decl.(k) <- sprec;
...@@ -535,9 +529,6 @@ module Production = struct ...@@ -535,9 +529,6 @@ module Production = struct
let identifiers prod = let identifiers prod =
identifiers.(prod) identifiers.(prod)
let used prod =
used.(prod)
let is_start prod = let is_start prod =
prod < start prod < start
......
...@@ -266,14 +266,6 @@ module Production : sig ...@@ -266,14 +266,6 @@ module Production : sig
val identifiers: index -> Syntax.identifier array val identifiers: index -> Syntax.identifier array
(* This maps a production index to an array of Boolean flag. Each
flag tells whether the semantic value of the corresponding symbol
is used in the semantic action. This is a conservative
approximation: [true] means maybe, while [false] means certainly
not. *)
val used: index -> bool array
(* This maps a production index to the production's semantic action. (* This maps a production index to the production's semantic action.
This function is not applicable to a start production. *) This function is not applicable to a start production. *)
......
...@@ -144,12 +144,11 @@ let define_and_measure (x, e) = ...@@ -144,12 +144,11 @@ let define_and_measure (x, e) =
let reducecellparams prod i _symbol (next : pattern) : pattern = let reducecellparams prod i _symbol (next : pattern) : pattern =
let ids = Production.identifiers prod let ids = Production.identifiers prod in
and used = Production.used prod in
PRecord [ PRecord [
fstate, (if i = 0 then PVar state else PWildcard); fstate, (if i = 0 then PVar state else PWildcard);
fsemv, (if used.(i) then PVar ids.(i) else PWildcard); fsemv, PVar ids.(i);
fstartp, PVar (Printf.sprintf "_startpos_%s_" ids.(i)); fstartp, PVar (Printf.sprintf "_startpos_%s_" ids.(i));
fendp, PVar (Printf.sprintf "_endpos_%s_" ids.(i)); fendp, PVar (Printf.sprintf "_endpos_%s_" ids.(i));
fnext, next; fnext, next;
...@@ -162,27 +161,22 @@ let reducecellparams prod i _symbol (next : pattern) : pattern = ...@@ -162,27 +161,22 @@ let reducecellparams prod i _symbol (next : pattern) : pattern =
let reducecellcasts prod i symbol casts = let reducecellcasts prod i symbol casts =
let ids = Production.identifiers prod let ids = Production.identifiers prod in
and used = Production.used prod in let id = ids.(i) in
let t : typ =
if used.(i) then match semvtype symbol with
let id = ids.(i) in | [] ->
let t : typ = tunit
match semvtype symbol with | [ t ] ->
| [] -> t
tunit | _ ->
| [ t ] -> assert false
t in
| _ -> (* Cast: [let id = ((Obj.magic id) : t) in ...]. *)
assert false (
in PVar id,
(* Cast: [let id = ((Obj.magic id) : t) in ...]. *) EAnnot (EMagic (EVar id), type2scheme t)
( ) :: casts
PVar id,
EAnnot (EMagic (EVar id), type2scheme t)
) :: casts
else
casts
(* This is the body of the [reduce] function associated with (* This is the body of the [reduce] function associated with
production [prod]. It assumes that the variables [env] and [stack] production [prod]. It assumes that the variables [env] and [stack]
......
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