Commit f6cd9aee by POTTIER Francois

### Isolate an auxiliary function for greater readability.

parent 9f19c66f
 ... @@ -78,6 +78,15 @@ let show_cycle nts nt = ... @@ -78,6 +78,15 @@ let show_cycle nts nt = end end end end let fail nts nt = let positions = List.flatten (List.map Nonterminal.positions nts) in Error.error positions "the grammar is cyclic:\n\ the nonterminal symbol %s expands to itself.\n%s\ A cyclic grammar is ambiguous." (Nonterminal.print false nt) (show_cycle nts nt) (* To detect a cycle in a relation, we use the combinator [defensive_fix] that (* To detect a cycle in a relation, we use the combinator [defensive_fix] that is provided by the library Fix. We define a function of type [Nonterminal.t is provided by the library Fix. We define a function of type [Nonterminal.t -> unit] that computes nothing but calls itself recursively according to the -> unit] that computes nothing but calls itself recursively according to the ... @@ -93,13 +102,7 @@ let () = ... @@ -93,13 +102,7 @@ let () = try try Nonterminal.iter check Nonterminal.iter check with M.Cycle (nts, nt) -> with M.Cycle (nts, nt) -> let positions = List.flatten (List.map Nonterminal.positions nts) in fail nts nt Error.error positions "the grammar is cyclic:\n\ the nonterminal symbol %s expands to itself.\n%s\ A cyclic grammar is ambiguous." (Nonterminal.print false nt) (show_cycle nts nt) (* -------------------------------------------------------------------------- *) (* -------------------------------------------------------------------------- *) ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!