Commit a3d13801 authored by POTTIER Francois's avatar POTTIER Francois

Make [foreach_terminal] accessible to the Engine.

parent db8089a2
......@@ -134,6 +134,10 @@ module type TABLE = sig
val error_terminal: terminal
val error_value: semantic_value
(* [foreach_terminal] allows iterating over all terminal symbols. *)
val foreach_terminal: (terminal -> 'a -> 'a) -> 'a -> 'a
(* The type of productions. *)
type production
......
......@@ -44,6 +44,26 @@ module Make (T : TableFormat.TABLES)
let error_value =
Obj.repr ()
(* The function [foreach_terminal] exploits the fact that the
first component of [T.error] is [Terminal.n - 1], i.e., the
number of terminal symbols, including [error] but not [#]. *)
(* There is similar code in [InspectionTableInterpreter]. The
code there contains an additional conversion of the type
[terminal] to the type [xsymbol]. *)
let rec foldij i j f accu =
if i = j then
accu
else
foldij (i + 1) j f (f i accu)
let foreach_terminal f accu =
let n, _ = T.error in
foldij 0 n (fun i accu ->
f i accu
) accu
type production =
int
......
......@@ -51,6 +51,9 @@ module T = struct
let error_value =
CstError
let foreach_terminal =
Terminal.foldx
type production =
Production.index
......
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