Commit 82ed54e0 authored by POTTIER Francois's avatar POTTIER Francois
Browse files

Change [strategy] to a variant type, for convenience.

parent e71ce45f
......@@ -122,8 +122,7 @@ module Make (T : TABLE) = struct
the first [ErrorHandling] checkpoint appears. *)
type strategy =
| Legacy
| Simplified
[ `Legacy | `Simplified ]
(* ------------------------------------------------------------------------ *)
......@@ -394,7 +393,7 @@ module Make (T : TABLE) = struct
token. *)
let please_discard =
match strategy with Legacy -> please_discard | Simplified -> false
match strategy with `Legacy -> please_discard | `Simplified -> false
in
shift env please_discard terminal value s'
......@@ -413,9 +412,9 @@ module Make (T : TABLE) = struct
announced. *)
match strategy with
| Legacy ->
| `Legacy ->
reduce env prod
| Simplified ->
| `Simplified ->
announce_reduce env prod
and error_fail ~strategy env =
......@@ -428,9 +427,9 @@ module Make (T : TABLE) = struct
when the goal is merely to produce a good syntax error message.) *)
match strategy with
| Simplified ->
| `Simplified ->
Rejected
| Legacy ->
| `Legacy ->
(* Attempt to pop a stack cell. *)
......@@ -543,7 +542,7 @@ module Make (T : TABLE) = struct
invalid_arg "offer expects InputNeeded"
let resume : 'a . ?strategy:strategy -> 'a checkpoint -> 'a checkpoint =
fun ?(strategy=Legacy) checkpoint ->
fun ?(strategy=`Legacy) checkpoint ->
match checkpoint with
| HandlingError env ->
Obj.magic error ~strategy env
......@@ -591,7 +590,7 @@ module Make (T : TABLE) = struct
above. *)
let rec loop : 'a . ?strategy:strategy -> supplier -> 'a checkpoint -> 'a =
fun ?(strategy=Legacy) read checkpoint ->
fun ?(strategy=`Legacy) read checkpoint ->
match checkpoint with
| InputNeeded _ ->
(* The parser needs a token. Request one from the lexer,
......
......@@ -94,7 +94,7 @@ module type INCREMENTAL_ENGINE = sig
(* The optional argument [strategy] influences the manner in which [resume]
deals with checkpoints of the form [ErrorHandling _]. Its default value
is [Legacy]. It can be briefly described as follows:
is [`Legacy]. It can be briefly described as follows:
- If the [error] token is used only to report errors (that is, if the
[error] token appears only at the end of a production, whose semantic
......@@ -109,8 +109,7 @@ module type INCREMENTAL_ENGINE = sig
More details on these strategies appear in the file [Engine.ml]. *)
type strategy =
| Legacy
| Simplified
[ `Legacy | `Simplified ]
val resume:
?strategy:strategy ->
......
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