Commit 7d8b7d27 authored by POTTIER Francois's avatar POTTIER Francois

Added [has_default_reduction] to the incremental API.

parent 09e5937e
2015/09/29:
Added [has_default_reduction] to the incremental API.
2015/09/25: 2015/09/25:
Modified the meaning of --canonical to allow default reductions to take Modified the meaning of --canonical to allow default reductions to take
place. There implies no loss of precision in terms of lookahead sets, place. There implies no loss of precision in terms of lookahead sets,
......
...@@ -2145,6 +2145,18 @@ current lookahead token. It is legal to invoke this function only after at ...@@ -2145,6 +2145,18 @@ current lookahead token. It is legal to invoke this function only after at
least one token has been offered to the parser via \verb+offer+. In other least one token has been offered to the parser via \verb+offer+. In other
words, it is illegal to invoke it in an initial state. words, it is illegal to invoke it in an initial state.
%% val has_default_reduction
\begin{verbatim}
val has_default_reduction: env -> bool
\end{verbatim}
The function \verb+has_default_reduction+
tells whether the parser is about to perform a default reduction.
In particular, when applied to an environment \verb+env+ taken from a result of
the form \verb+AboutToReduce (env, prod)+, it tells whether the reduction
that is about to take place is a default reduction.
% ------------------------------------------------------------------------------ % ------------------------------------------------------------------------------
\subsection{Inspection API} \subsection{Inspection API}
......
...@@ -100,6 +100,13 @@ module type INCREMENTAL_ENGINE = sig ...@@ -100,6 +100,13 @@ module type INCREMENTAL_ENGINE = sig
val positions: env -> Lexing.position * Lexing.position val positions: env -> Lexing.position * Lexing.position
(* This tells whether the parser is about to perform a default reduction.
In particular, when applied to an environment taken from a result of
the form [AboutToReduce (env, prod)], this tells whether the reduction
that is about to take place is a default reduction. *)
val has_default_reduction: env -> bool
end end
(* This signature is a fragment of the inspection API that is made available (* This signature is a fragment of the inspection API that is made available
......
...@@ -577,5 +577,19 @@ module Make (T : TABLE) = struct ...@@ -577,5 +577,19 @@ module Make (T : TABLE) = struct
assert (startp != dummy_pos && endp != dummy_pos); assert (startp != dummy_pos && endp != dummy_pos);
startp, endp startp, endp
(* --------------------------------------------------------------------------- *)
(* Access to information about default reductions. *)
(* We can make this a function of states, or a function of environments. For
now, the latter appears simpler. *)
let has_default_reduction env : bool =
T.default_reduction
env.current
(fun _env _prod -> true)
(fun _env -> false)
env
end end
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