Commit 6bd48f25 authored by POTTIER Francois's avatar POTTIER Francois

Moved [has_epsilon_reduction] to [Lr1].

parent 6a0e6726
......@@ -595,17 +595,6 @@ let rewind node : instruction =
in
rewind w
(* ------------------------------------------------------------------------ *)
(* This auxiliary function tests whether a state has a reduction action for
an epsilon production. It could be moved to [Lr1], if desired. *)
let has_epsilon_reduction node =
TerminalMap.fold (fun _ prods accu ->
accu ||
let prod = Misc.single prods in
Production.length prod = 0
) (Lr1.reductions node) false
(* ------------------------------------------------------------------------ *)
(* We now determine which positions must be kept track of. For
simplicity, we do this on a per symbol basis. That is, for each
......@@ -687,7 +676,7 @@ let () =
);
Lr1.iterx (fun node ->
(* 2015/11/04. See above. *)
if has_epsilon_reduction node then
if Lr1.has_epsilon_reduction node then
let sym = Misc.unSome (Lr1.incoming_symbol node) in
require WhereEnd sym
)
......
......@@ -836,6 +836,16 @@ let invert reductions : TerminalSet.t ProductionMap.t =
ProductionMap.add prod (TerminalSet.add tok toks) inverse
) reductions ProductionMap.empty
(* ------------------------------------------------------------------------ *)
(* Testing whether a state can reduce some epsilon production. *)
let has_epsilon_reduction node =
TerminalMap.fold (fun _ prods accu ->
accu ||
let prod = Misc.single prods in
Production.length prod = 0
) (reductions node) false
(* ------------------------------------------------------------------------ *)
(* Computing which terminal symbols a state is willing to act upon.
......
......@@ -83,6 +83,10 @@ val forbid_default_reduction: node -> bool
val invert : ProductionMap.key list TerminalMap.t -> TerminalSet.t ProductionMap.t
(* Testing whether a state can reduce some epsilon production. *)
val has_epsilon_reduction: node -> bool
(* Computing which terminal symbols a state is willing to act upon.
This function is currently unused, but could be used as part of an error
......
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