Commit b5cb07e8 by POTTIER Francois

Added comparison functions for productions and items.

parent 9a2f8a37
......@@ -134,13 +134,6 @@ module type INSPECTION = sig
include SYMBOLS
(* Ordering functions. *)
val compare_terminals: _ terminal -> _ terminal -> int
val compare_nonterminals: _ nonterminal -> _ nonterminal -> int
val compare_symbols: xsymbol -> xsymbol -> int
val compare_words: xsymbol list -> xsymbol list -> int
(* The type ['a lr1state] is meant to be the same as in [INCREMENTAL_ENGINE]. *)
type 'a lr1state
......@@ -158,6 +151,15 @@ module type INSPECTION = sig
type item =
production * int
(* Ordering functions. *)
val compare_terminals: _ terminal -> _ terminal -> int
val compare_nonterminals: _ nonterminal -> _ nonterminal -> int
val compare_symbols: xsymbol -> xsymbol -> int
val compare_words: xsymbol list -> xsymbol list -> int
val compare_productions: production -> production -> int
val compare_items: item -> item -> int
(* [incoming_symbol s] is the incoming symbol of the state [s], that is,
the symbol that the parser must recognize before (has recognized when)
it enters the state [s]. This function gives access to the semantic
......
......@@ -104,6 +104,15 @@ module Make
let compare_words w1 w2 =
General.compare compare_symbols w1 w2
let compare_productions prod1 prod2 =
(* Subtraction is safe because overflow is impossible. *)
prod1 - prod2
let compare_items (prod1, index1) (prod2, index2) =
let c = compare_productions prod1 prod2 in
(* Subtraction is safe because overflow is impossible. *)
if c <> 0 then c else index1 - index2
(* The function [incoming_symbol] goes through the tables [T.lr0_core] and
[T.lr0_incoming]. This yields a representation of type [xsymbol], out of
which we strip the [X] quantifier, so as to get a naked symbol. This last
......
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