Commit 5a3903d4 by POTTIER Francois

Incremental API: rename [find_default_reduction] to [state_has_default_reduction],

and let it return a Boolean result.
parent b00eac64
......@@ -637,12 +637,6 @@ module Make (T : TABLE) = struct
type 'a lr1state =
state
let find_default_reduction (state : _ lr1state) : production option =
T.default_reduction state
(fun () prod -> Some prod)
(fun () -> None)
()
(* ------------------------------------------------------------------------ *)
(* Stack inspection. *)
......@@ -738,15 +732,22 @@ module Make (T : TABLE) = struct
(* Access to information about default reductions. *)
(* We can make this a function of states, or a function of environments. For
now, the latter appears simpler. *)
(* This can be a function of states, or a function of environments.
We offer both. *)
let env_has_default_reduction env : bool =
T.default_reduction
env.current
(* Instead of a Boolean result, we could return a [production option].
However, we would have to explicitly test whether [prod] is a start
production, and in that case, return [None], I suppose. Indeed, we
have decided not to expose the start productions. *)
let state_has_default_reduction (state : _ lr1state) : bool =
T.default_reduction state
(fun _env _prod -> true)
(fun _env -> false)
env
()
let env_has_default_reduction env =
state_has_default_reduction env.current
(* ------------------------------------------------------------------------ *)
......
......@@ -232,11 +232,6 @@ module type INCREMENTAL_ENGINE = sig
val production_index: production -> int
val find_production: int -> production
(* [find_default_reduction s] returns [Some prod] if the state [s] has a
default reduction of production [prod], and returns [None] otherwise. *)
val find_default_reduction: _ lr1state -> production option
(* An element is a pair of a non-initial state [s] and a semantic value [v]
associated with the incoming symbol of this state. The idea is, the value
[v] was pushed onto the stack just before the state [s] was entered. Thus,
......@@ -307,13 +302,18 @@ module type INCREMENTAL_ENGINE = sig
val positions: 'a env -> position * position
(* This tells whether the parser is about to perform a default reduction.
In particular, when applied to an environment taken from a result of
the form [AboutToReduce (env, prod)], this tells whether the reduction
that is about to take place is a default reduction. *)
(* When applied to an environment taken from a checkpoint of the form
[AboutToReduce (env, prod)], the function [env_has_default_reduction]
tells whether the reduction that is about to take place is a default
reduction. *)
val env_has_default_reduction: 'a env -> bool
(* [state_has_default_reduction s] tells whether the state [s] has a default
reduction. This includes the case where [s] is an accepting state. *)
val state_has_default_reduction: _ lr1state -> bool
end
(* This signature is a fragment of the inspection API that is made available
......
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