Commit 899b2889 authored by POTTIER Francois's avatar POTTIER Francois

New function [Lr0.compare].

parent 2294287c
......@@ -363,6 +363,20 @@ let equal ((k1, toksr1) as state1) ((k2, toksr2) as state2) =
in
loop (Array.length toksr1)
(* A total order on states. *)
let compare ((k1, toksr1) as state1) ((k2, toksr2) as state2) =
assert (k1 = k2 && well_formed state1 && well_formed state2);
let rec loop i =
if i = 0 then
0
else
let i = i - 1 in
let c = TerminalSet.compare toksr1.(i) toksr2.(i) in
if c <> 0 then c else loop i
in
loop (Array.length toksr1)
(* Subsumption between states. *)
let subsume ((k1, toksr1) as state1) ((k2, toksr2) as state2) =
......
......@@ -88,6 +88,12 @@ val reductions: lr1state -> (TerminalSet.t * Production.index) list
val equal: lr1state -> lr1state -> bool
(* A total order on states. The two states must have the same core.
This is an arbitrary total order; it has nothing to do with set
inclusion, which is a partial order; see [subsume] below. *)
val compare: lr1state -> lr1state -> int
(* Subsumption between states. The two states must have the same
core. Then, one subsumes the other if and only if their lookahead
sets are (pointwise) in the subset relation. *)
......@@ -128,4 +134,3 @@ val restrict: TerminalSet.t -> lr1state -> lr1state
val print_concrete: string -> concretelr1state -> string
val print: string -> lr1state -> string
val print_closure: string -> lr1state -> string
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