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

Changed [nullable_first_rhs] to [nullable_first_prod] for external

users.
parent c017deea
...@@ -187,14 +187,14 @@ let rec follow1 tok derivation offset' = function ...@@ -187,14 +187,14 @@ let rec follow1 tok derivation offset' = function
at the moment, so let's skip it. *) at the moment, so let's skip it. *)
derivation derivation
| (item, _, offset) :: configs -> | (item, _, offset) :: configs ->
let _, _, rhs, pos, length = Item.def item in let prod, _, rhs, pos, length = Item.def item in
if offset = offset' then if offset = offset' then
(* This is an epsilon transition. Attack a new line and add (* This is an epsilon transition. Attack a new line and add
a comment that explains why the lookahead symbol is a comment that explains why the lookahead symbol is
produced or inherited. *) produced or inherited. *)
let nullable, first = Analysis.nullable_first_rhs rhs (pos + 1) in let nullable, first = Analysis.nullable_first_prod prod (pos + 1) in
if TerminalSet.mem tok first then if TerminalSet.mem tok first then
...@@ -304,7 +304,7 @@ let explain_reduce_item ...@@ -304,7 +304,7 @@ let explain_reduce_item
if pos < length then if pos < length then
match rhs.(pos) with match rhs.(pos) with
| Symbol.N nt -> | Symbol.N nt ->
let nullable, first = Analysis.nullable_first_rhs rhs (pos + 1) in let nullable, first = Analysis.nullable_first_prod prod (pos + 1) in
let first : bool = TerminalSet.mem tok first in let first : bool = TerminalSet.mem tok first in
let lookahead' = let lookahead' =
if nullable then first || lookahead else first if nullable then first || lookahead else first
......
...@@ -1270,7 +1270,9 @@ module Analysis = struct ...@@ -1270,7 +1270,9 @@ module Analysis = struct
let first = Array.get first let first = Array.get first
let nullable_first_rhs = nullable_first_rhs let nullable_first_prod prod i =
let rhs = Production.rhs prod in
nullable_first_rhs rhs i
let explain_first_rhs (tok : Terminal.t) (rhs : Symbol.t array) (i : int) = let explain_first_rhs (tok : Terminal.t) (rhs : Symbol.t array) (i : int) =
convert (explain tok rhs i) convert (explain tok rhs i)
......
...@@ -373,12 +373,12 @@ module Analysis : sig ...@@ -373,12 +373,12 @@ module Analysis : sig
val first: Nonterminal.t -> TerminalSet.t val first: Nonterminal.t -> TerminalSet.t
(* [nullable_first_rhs rhs i] considers the string of symbols found at (* [nullable_first_prod prod i] considers the suffix of the the production
offset [i] in the array [rhs]. It returns its NULLABLE flag as well [prod] defined by offset [i]. It returns its NULLABLE flag as well
as its FIRST set. The offset [i] must be contained between [0] and as its FIRST set. The offset [i] must be contained between [0] and
[n], where [n] is the length of [rhs], inclusive. *) [n], inclusive, where [n] is the length of production [prod]. *)
val nullable_first_rhs: Symbol.t array -> int -> bool * TerminalSet.t val nullable_first_prod: Production.index -> int -> bool * TerminalSet.t
(* [explain_first_rhs tok rhs i] explains why the token [tok] appears (* [explain_first_rhs tok rhs i] explains why the token [tok] appears
in the FIRST set for the string of symbols found at offset [i] in in the FIRST set for the string of symbols found at offset [i] in
......
...@@ -171,7 +171,7 @@ module Closure (L : Lookahead.S) = struct ...@@ -171,7 +171,7 @@ module Closure (L : Lookahead.S) = struct
let constant, transmits = let constant, transmits =
if pos < length then if pos < length then
let nullable, first = Analysis.nullable_first_rhs rhs (pos + 1) in let nullable, first = Analysis.nullable_first_prod prod (pos + 1) in
L.constant first, nullable L.constant first, nullable
else else
(* No epsilon transitions leave this item. *) (* No epsilon transitions leave this item. *)
......
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