Commit ca9cf047 authored by POTTIER Francois's avatar POTTIER Francois

Use [token * position * position] instead of [position * token * position],

as [MenhirLib.Convert] has already committed to this type.
parent 0fe47d21
......@@ -90,8 +90,8 @@ module Make (T : TABLE) = struct
let token = env.lexer lexbuf in
let startp = lexbuf.Lexing.lex_start_p
and endp = lexbuf.Lexing.lex_curr_p in
let triple = (startp, token, endp) in
Log.lookahead_token startp (T.token2terminal token) endp;
let triple = (token, startp, endp) in
Log.lookahead_token (T.token2terminal token) startp endp;
let env = { env with triple } in
check_for_default_reduction env
......@@ -119,7 +119,7 @@ module Make (T : TABLE) = struct
(* Note that, if [please_discard] was true, then we have just called
[discard], so the lookahead token cannot be [error]. *)
let (_, token, _) = env.triple in
let (token, _, _) = env.triple in
if token == error_token then begin
Log.resuming_error_handling();
error env
......@@ -161,7 +161,7 @@ module Make (T : TABLE) = struct
(* Push a new cell onto the stack, containing the identity of the
state that we are leaving. *)
let (startp, _, endp) = env.triple in
let (_, startp, endp) = env.triple in
let stack = {
state = env.current;
semv = value;
......@@ -236,15 +236,15 @@ module Make (T : TABLE) = struct
and initiate env : void =
Log.initiating_error_handling();
let (startp, _, endp) = env.triple in
let triple = (startp, error_token, endp) in
let (_, startp, endp) = env.triple in
let triple = (error_token, startp, endp) in
let env = { env with triple } in
error env
(* [error] handles errors. *)
and error env : void =
assert (let (_, token, _) = env.triple in token == error_token);
assert (let (token, _, _) = env.triple in token == error_token);
(* Consult the column associated with the [error] pseudo-token in the
action table. *)
......@@ -310,6 +310,8 @@ module Make (T : TABLE) = struct
(lexbuf : Lexing.lexbuf)
: semantic_value =
(* Pre-apply the lexer to the lexbuf. *)
(* Build an empty stack. This is a dummy cell, which is its own
successor. Its fields other than [next] contain dummy values. *)
......@@ -329,11 +331,11 @@ module Make (T : TABLE) = struct
(* Log our first lookahead token. *)
Log.lookahead_token startp (T.token2terminal token) endp;
Log.lookahead_token (T.token2terminal token) startp endp;
(* Build an initial environment. *)
let triple = (startp, token, endp) in
let triple = (token, startp, endp) in
let env = {
lexer;
lexbuf;
......
......@@ -63,7 +63,7 @@ type ('state, 'semantic_value, 'token) env = {
engine disguises the [error] pseudo-token as an illegal inhabitant of the
type [token]. Do not read this field unless you know what are doing! *)
triple: Lexing.position * 'token * Lexing.position;
triple: 'token * Lexing.position * Lexing.position;
(* The stack. In [CodeBackend], it is passed around on its own,
whereas, here, it is accessed via the environment. *)
......@@ -255,7 +255,7 @@ module type TABLE = sig
(* Lookahead token is now <terminal> (<pos>-<pos>) *)
val lookahead_token: Lexing.position -> terminal -> Lexing.position -> unit
val lookahead_token: terminal -> Lexing.position -> Lexing.position -> unit
(* Initiating error handling *)
......
......@@ -202,7 +202,7 @@ module T = struct
fprintf stderr "Reducing production %s" (Production.print prod)
)
let lookahead_token startp tok endp =
let lookahead_token tok startp endp =
maybe (fun () ->
fprintf stderr "Lookahead token is now %s (%d-%d)"
(Terminal.print tok)
......
......@@ -127,7 +127,7 @@ module Make (T : TableFormat.TABLES)
| None ->
()
let lookahead_token startp token endp =
let lookahead_token token startp endp =
match T.trace with
| Some (terminals, _) ->
fprintf stderr "Lookahead token is now %s (%d-%d)\n%!"
......
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