Attention une mise à jour du service Gitlab va être effectuée le mardi 18 janvier (et non lundi 17 comme annoncé précédemment) entre 18h00 et 18h30. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes.

Commit f07a2835 authored by POTTIER Francois's avatar POTTIER Francois
Browse files

New functions [drop] and [get].

parent 05faa567
......@@ -823,4 +823,22 @@ module Make (T : TABLE) = struct
let input_needed (env : 'a env) : 'a checkpoint =
InputNeeded env
(* The following functions are compositions of [top] and [pop]. *)
let rec drop i env =
if i = 0 then
Some env
else match pop env with
| None ->
None
| Some env ->
drop (i - 1) env
let get i env =
match drop i env with
| None ->
None
| Some env ->
top env
end
......@@ -267,6 +267,19 @@ module type INCREMENTAL_ENGINE = sig
val top: 'a env -> element option
(* [drop i env] pops [i] cells off the automaton's stack. This is done by
invoking [pop] [i] times in succession. Thus, [drop 1] is [pop]. The
index [i] must be nonnegative. The time complexity is O(i). *)
val drop: int -> 'a env -> 'a env option
(* [get i env] returns the parser's [i]-th stack cell. The index [i] is
0-based: thus, [get 0] is [top]. If [i] is greater than or equal to the
number of elements in the stack, [None] is returned. The time complexity
is O(i). *)
val get: int -> 'a env -> element option
(* [error_state checkpoint] requires [checkpoint] to be of the form
[HandlingError env]. Out of [env], it extracts the automaton's current
state, and returns this state, as an integer number. (This works even if
......
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