Commit 69749d76 authored by POTTIER Francois's avatar POTTIER Francois

In [IncrementalEngine] and in the documentation, use [position] as a synonym

for [Lexing.position].
parent 843faef0
...@@ -2125,11 +2125,14 @@ the name of the start symbol.) The generated file \texttt{parser.mli} contains ...@@ -2125,11 +2125,14 @@ the name of the start symbol.) The generated file \texttt{parser.mli} contains
the following declaration: the following declaration:
\begin{verbatim} \begin{verbatim}
module Incremental : sig module Incremental : sig
val main: Lexing.position -> thing MenhirInterpreter.checkpoint val main: position -> thing MenhirInterpreter.checkpoint
end end
\end{verbatim} \end{verbatim}
The argument is the initial position. If the lexer is based on an OCaml The argument is the initial position. If the lexer is based on an OCaml
lexing buffer, this argument should be \verb+lexbuf.lex_curr_p+. lexing buffer, this argument should be \verb+lexbuf.lex_curr_p+.
In \sref{sec:incremental} and \sref{sec:inspection},
the type \verb+position+ is a synonym for \verb+Lexing.position+.
We emphasize that the function \verb+Incremental.main+ does not parse We emphasize that the function \verb+Incremental.main+ does not parse
anything. It constructs a checkpoint which serves as a \emph{starting} anything. It constructs a checkpoint which serves as a \emph{starting}
point. The functions \verb+offer+ and \verb+resume+, described below, are used point. The functions \verb+offer+ and \verb+resume+, described below, are used
...@@ -2217,7 +2220,7 @@ transitions and possibly handle errors in a different manner, if desired. ...@@ -2217,7 +2220,7 @@ transitions and possibly handle errors in a different manner, if desired.
\begin{verbatim} \begin{verbatim}
val offer: val offer:
'a checkpoint -> 'a checkpoint ->
token * Lexing.position * Lexing.position -> token * position * position ->
'a checkpoint 'a checkpoint
\end{verbatim} \end{verbatim}
...@@ -2256,7 +2259,7 @@ give a few more type definitions. ...@@ -2256,7 +2259,7 @@ give a few more type definitions.
\begin{verbatim} \begin{verbatim}
type supplier = type supplier =
unit -> token * Lexing.position * Lexing.position unit -> token * position * position
\end{verbatim} \end{verbatim}
A token supplier is a function of no arguments which delivers a new token A token supplier is a function of no arguments which delivers a new token
...@@ -2347,7 +2350,7 @@ The states of the LR(1) automaton are numbered (from 0 and up). ...@@ -2347,7 +2350,7 @@ The states of the LR(1) automaton are numbered (from 0 and up).
\begin{verbatim} \begin{verbatim}
type element = type element =
| Element: 'a lr1state * 'a * Lexing.position * Lexing.position -> element | Element: 'a lr1state * 'a * position * position -> element
\end{verbatim} \end{verbatim}
The type \verb+element+ describes one entry in the stack of the LR(1) The type \verb+element+ describes one entry in the stack of the LR(1)
...@@ -2396,7 +2399,7 @@ constant time. ...@@ -2396,7 +2399,7 @@ constant time.
%% val positions %% val positions
\begin{verbatim} \begin{verbatim}
val positions: env -> Lexing.position * Lexing.position val positions: env -> position * position
\end{verbatim} \end{verbatim}
The function \verb+positions+ returns the start and end positions of the The function \verb+positions+ returns the start and end positions of the
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
(* *) (* *)
(******************************************************************************) (******************************************************************************)
type position = Lexing.position
open General open General
(* This signature describes the incremental LR engine. *) (* This signature describes the incremental LR engine. *)
...@@ -78,7 +80,7 @@ module type INCREMENTAL_ENGINE = sig ...@@ -78,7 +80,7 @@ module type INCREMENTAL_ENGINE = sig
val offer: val offer:
'a checkpoint -> 'a checkpoint ->
token * Lexing.position * Lexing.position -> token * position * position ->
'a checkpoint 'a checkpoint
(* [resume] allows the user to resume the parser after it has suspended (* [resume] allows the user to resume the parser after it has suspended
...@@ -94,7 +96,7 @@ module type INCREMENTAL_ENGINE = sig ...@@ -94,7 +96,7 @@ module type INCREMENTAL_ENGINE = sig
(together with its start and end positions) every time it is called. *) (together with its start and end positions) every time it is called. *)
type supplier = type supplier =
unit -> token * Lexing.position * Lexing.position unit -> token * position * position
(* A pair of a lexer and a lexing buffer can be easily turned into a supplier. *) (* A pair of a lexer and a lexing buffer can be easily turned into a supplier. *)
...@@ -180,7 +182,7 @@ module type INCREMENTAL_ENGINE = sig ...@@ -180,7 +182,7 @@ module type INCREMENTAL_ENGINE = sig
hypothetical token, and may be picked up by the semantic actions. We hypothetical token, and may be picked up by the semantic actions. We
suggest using the position where the error was detected. *) suggest using the position where the error was detected. *)
val acceptable: 'a checkpoint -> token -> Lexing.position -> bool val acceptable: 'a checkpoint -> token -> position -> bool
(* [pop env] returns a new environment, where the parser's top stack cell (* [pop env] returns a new environment, where the parser's top stack cell
has been popped off. (If the stack is empty, [None] is returned.) This has been popped off. (If the stack is empty, [None] is returned.) This
...@@ -236,7 +238,7 @@ module type INCREMENTAL_ENGINE = sig ...@@ -236,7 +238,7 @@ module type INCREMENTAL_ENGINE = sig
has type ['a]. In other words, the type [element] is an existential type. *) has type ['a]. In other words, the type [element] is an existential type. *)
type element = type element =
| Element: 'a lr1state * 'a * Lexing.position * Lexing.position -> element | Element: 'a lr1state * 'a * position * position -> element
(* The parser's stack is (or, more precisely, can be viewed as) a stream of (* The parser's stack is (or, more precisely, can be viewed as) a stream of
elements. The type [stream] is defined by the module [General]. *) elements. The type [stream] is defined by the module [General]. *)
...@@ -255,7 +257,7 @@ module type INCREMENTAL_ENGINE = sig ...@@ -255,7 +257,7 @@ module type INCREMENTAL_ENGINE = sig
invoked in an initial state, this function returns a pair of twice the invoked in an initial state, this function returns a pair of twice the
initial position. *) initial position. *)
val positions: 'a env -> Lexing.position * Lexing.position val positions: 'a env -> position * position
(* This tells whether the parser is about to perform a default reduction. (* This tells whether the parser is about to perform a default reduction.
In particular, when applied to an environment taken from a result of In particular, when applied to an environment taken from a result of
...@@ -391,7 +393,7 @@ module type INSPECTION = sig ...@@ -391,7 +393,7 @@ module type INSPECTION = sig
determined by [env]) has an outgoing transition labeled with [symbol]. determined by [env]) has an outgoing transition labeled with [symbol].
Otherwise, [Invalid_argument _] is raised. *) Otherwise, [Invalid_argument _] is raised. *)
val feed: 'a symbol -> Lexing.position -> 'a -> Lexing.position -> 'b env -> 'b env val feed: 'a symbol -> position -> 'a -> position -> 'b env -> 'b 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