Commit 5071feb7 by POTTIER Francois

New comparison function, [equal].

parent 129fc0f9
......@@ -710,6 +710,14 @@ module Make (T : TABLE) = struct
Some (Element (env.current, cell.semv, cell.startp, cell.endp))
(* [equal] compares the stacks for physical equality, and compares the
current states via their numbers (this seems cleaner than using OCaml's
polymorphic equality). *)
let equal env1 env2 =
env1.stack == env2.stack &&
number env1.current = number env2.current
(* ------------------------------------------------------------------------ *)
(* Access to the position of the lookahead token. *)
......@@ -267,6 +267,15 @@ module type INCREMENTAL_ENGINE = sig
val top: 'a env -> element option
(* [equal env1 env2] tells whether the parser configurations [env1] and
[env2] are equal in the sense that the automaton's current state is
the same in [env1] and [env2] and the stack is *physically* the same
in [env1] and [env2]. If [equal env1 env2] is [true], then the list
of stack elements, as observed via [pop] and [top], must be the same
in [env1] and [env2]. The function [equal] has time complexity O(1). *)
val equal: 'a env -> 'a env -> bool
(* These are the start and end positions of the current lookahead token. If
invoked in an initial state, this function returns a pair of twice the
initial position. *)
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