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

Added [production_defs2] to [TableFormat] and defined [rhs2].

parent ed989285
......@@ -127,7 +127,7 @@ module type INSPECTION_TABLES = sig
type 'a symbol
type xsymbol
val lhs: PackedIntArray.t
val lhs: PackedIntArray.t (* or: could include TABLES *)
val terminal: int -> xsymbol
val nonterminal: int -> xsymbol
......@@ -140,6 +140,8 @@ module type INSPECTION_TABLES = sig
(non-start) production. *)
val production_defs: xsymbol list array
val production_defs2: PackedIntArray.t * PackedIntArray.t
(* packed linearized array *)
(* A mapping of every (non-initial) state to its LR(0) core. *)
......
......@@ -175,10 +175,25 @@ module MakeInspection (T : TableFormat.INSPECTION_TABLES) = struct
T.symbol
let lhs prod =
let nt = PackedIntArray.get T.lhs prod in
let nt : int = PackedIntArray.get T.lhs prod in
T.nonterminal nt
let decode_symbol symbol =
let kind = symbol land 1 in
(if kind = 0 then T.terminal else T.nonterminal) (symbol lsr 1)
let rhs2 prod =
let (data, entry) = T.production_defs2 in
let rhs : int list =
LinearizedArray.read_row_via
(PackedIntArray.get data)
(PackedIntArray.get entry)
prod
in
List.map decode_symbol rhs
let rhs prod =
let _ = rhs2 prod in
T.production_defs.(prod)
(* This is a copy of [Item.export]. *)
......
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