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 =
symbol this stack cell is associated with. *)
let reducecellparams prod i holds_state symbol =
let ids = Production.identifiers prod
and used = Production.used prod in
let ids = Production.identifiers prod in
(* If the semantic value is used in the semantic action, then it is
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. *)
(* The semantic value is bound to the variable [ids.(i)]. *)
let semvpat _t =
if used.(i) then
PVar ids.(i)
else
PWildcard
PVar ids.(i)
in
elementif holds_state (if i = 0 then PVar state else PWildcard) @
......@@ -1137,7 +1130,6 @@ let reducebody prod =
let nt, rhs = Production.def prod
and ids = Production.identifiers prod
and used = Production.used prod
and length = Production.length prod in
(* Build a pattern that represents the shape of the stack. Out of
......@@ -1167,14 +1159,11 @@ let reducebody prod =
let unitbindings =
Misc.foldi length (fun i unitbindings ->
if used.(i) then
match semvtype rhs.(i) with
| [] ->
(PVar ids.(i), EUnit) :: unitbindings
| _ ->
unitbindings
else
unitbindings
match semvtype rhs.(i) with
| [] ->
(PVar ids.(i), EUnit) :: unitbindings
| _ ->
unitbindings
) []
in
......
......@@ -432,9 +432,6 @@ module Production = struct
let identifiers : identifier array array =
Array.make n [||]
let used : bool array array =
Array.make n [||]
let actions : action option array =
Array.make n None
......@@ -451,7 +448,6 @@ module Production = struct
and nt' = Nonterminal.lookup (nonterminal ^ "'") in
table.(k) <- (nt', [| Symbol.N nt |]);
identifiers.(k) <- [| "_1" |];
used.(k) <- [| true |];
ntprods.(nt') <- (k, k+1);
positions.(k) <- Nonterminal.positions nt;
k+1,
......@@ -473,8 +469,6 @@ module Production = struct
let symbols = Array.of_list branch.producers in
table.(k) <- (nt, Array.map (fun (v, _) -> Symbol.lookup v) 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;
reduce_precedence.(k) <- rprec;
prec_decl.(k) <- sprec;
......@@ -535,9 +529,6 @@ module Production = struct
let identifiers prod =
identifiers.(prod)
let used prod =
used.(prod)
let is_start prod =
prod < start
......
......@@ -266,14 +266,6 @@ module Production : sig
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 function is not applicable to a start production. *)
......
......@@ -144,12 +144,11 @@ let define_and_measure (x, e) =
let reducecellparams prod i _symbol (next : pattern) : pattern =
let ids = Production.identifiers prod
and used = Production.used prod in
let ids = Production.identifiers prod in
PRecord [
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));
fendp, PVar (Printf.sprintf "_endpos_%s_" ids.(i));
fnext, next;
......@@ -162,27 +161,22 @@ let reducecellparams prod i _symbol (next : pattern) : pattern =
let reducecellcasts prod i symbol casts =
let ids = Production.identifiers prod
and used = Production.used prod in
if used.(i) then
let id = ids.(i) in
let t : typ =
match semvtype symbol with
| [] ->
tunit
| [ t ] ->
t
| _ ->
assert false
in
(* Cast: [let id = ((Obj.magic id) : t) in ...]. *)
(
PVar id,
EAnnot (EMagic (EVar id), type2scheme t)
) :: casts
else
casts
let ids = Production.identifiers prod in
let id = ids.(i) in
let t : typ =
match semvtype symbol with
| [] ->
tunit
| [ t ] ->
t
| _ ->
assert false
in
(* Cast: [let id = ((Obj.magic id) : t) in ...]. *)
(
PVar id,
EAnnot (EMagic (EVar id), type2scheme t)
) :: casts
(* This is the body of the [reduce] function associated with
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