Commit dcc89cc9 authored by POTTIER Francois's avatar POTTIER Francois

Expose the function [number] in the incremental API.

parent 942ce961
...@@ -4,6 +4,7 @@ A [supplier] is a function that produces tokens on demand. ...@@ -4,6 +4,7 @@ A [supplier] is a function that produces tokens on demand.
[lexer_lexbuf_to_supplier] turns a lexer and a lexbuf into a supplier. [lexer_lexbuf_to_supplier] turns a lexer and a lexbuf into a supplier.
[loop] is a ready-made made main parsing loop. [loop] is a ready-made made main parsing loop.
[loop_handle] is a variant of [loop] that lets the user do her own error handling. [loop_handle] is a variant of [loop] that lets the user do her own error handling.
[number] maps a state of the LR(1) automaton to its number.
2015/10/16: 2015/10/16:
Incompatible change of the incremental API: renamed the type ['a result] Incompatible change of the incremental API: renamed the type ['a result]
......
...@@ -88,7 +88,7 @@ ...@@ -88,7 +88,7 @@
* Suite des patchs de Frédéric Bour. * Suite des patchs de Frédéric Bour.
API d'inspection complète. API d'inspection complète.
Exposer le nombre d'états (pour la mémoisation) et une conversion état -> entier. Exposer le nombre d'états (pour la mémoisation).
Idem pour les productions. Idem pour les productions.
Fonctions d'affichage pour les types terminal, nonterminal, etc.? Fonctions d'affichage pour les types terminal, nonterminal, etc.?
Fonctions d'isomorphisme entre token et 'a terminal * 'a? Fonctions d'isomorphisme entre token et 'a terminal * 'a?
......
...@@ -2149,6 +2149,14 @@ The index \verb+'a+ is the type of the semantic values associated with $A$. ...@@ -2149,6 +2149,14 @@ The index \verb+'a+ is the type of the semantic values associated with $A$.
The role played by \verb+'a+ is clarified in the definition of the The role played by \verb+'a+ is clarified in the definition of the
type \verb+element+, which follows. type \verb+element+, which follows.
%% val number
\begin{verbatim}
val number: _ lr1state -> int
\end{verbatim}
The states of the LR(1) automaton are numbered (from 0 and up).
%% type element %% type element
\begin{verbatim} \begin{verbatim}
......
...@@ -113,6 +113,10 @@ module type INCREMENTAL_ENGINE = sig ...@@ -113,6 +113,10 @@ module type INCREMENTAL_ENGINE = sig
type 'a lr1state type 'a lr1state
(* The states of the LR(1) automaton are numbered (from 0 and up). *)
val number: _ lr1state -> int
(* An element is a pair of a non-initial state [s] and a semantic value [v] (* An element is a pair of a non-initial state [s] and a semantic value [v]
associated with the incoming symbol of this state. The idea is, the value associated with the incoming symbol of this state. The idea is, the value
[v] was pushed onto the stack just before the state [s] was entered. Thus, [v] was pushed onto the stack just before the state [s] was entered. Thus,
......
...@@ -84,6 +84,10 @@ module type TABLE = sig ...@@ -84,6 +84,10 @@ module type TABLE = sig
type state type state
(* States are numbered. *)
val number: state -> int
(* The type of tokens. These can be thought of as real tokens, that is, (* The type of tokens. These can be thought of as real tokens, that is,
tokens returned by the lexer. They carry a semantic value. This type tokens returned by the lexer. They carry a semantic value. This type
does not include the [error] pseudo-token. *) does not include the [error] pseudo-token. *)
......
...@@ -8,6 +8,9 @@ module T = struct ...@@ -8,6 +8,9 @@ module T = struct
type state = type state =
Lr1.node Lr1.node
let number =
Lr1.number
type token = type token =
Terminal.t Terminal.t
......
...@@ -5,6 +5,8 @@ module Make (T : TableFormat.TABLES) ...@@ -5,6 +5,8 @@ module Make (T : TableFormat.TABLES)
type state = type state =
int int
let number s = s
type token = type token =
T.token T.token
......
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