ErrorReporting.mli 1.96 KB
Newer Older
1 2
(* This module is part of MenhirLib. *)

3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
(* An explanation is a description of what the parser has recognized in the
   recent past and what it expects next. *)

type ('item, 'symbol) explanation = {

  (* An explanation is based on an item. *)
  item: 'item;

  (* A past. This is a non-empty sequence of (terminal and non-terminal)
     symbols, each of which corresponds to a range of the input file. These
     symbols correspond to the first half (up to the bullet) of the item's
     right-hand side. In short, they represent what we have recognized in
     the recent past. *)
  past: ('symbol * Lexing.position * Lexing.position) list;

  (* A future. This is a non-empty sequence of (terminal and non-terminal)
     symbols These symbols correspond to the second half (after the bullet)
     of the item's right-hand side. In short, they represent what we expect
     to recognize in the future, if this item is a good prediction. *)
  future: 'symbol list;

  (* A goal. This is a non-terminal symbol. It corresponds to the item's
     left-hand side. In short, it represents the reduction that we will
     be able to perform if we successfully recognize this future. *)
  goal: 'symbol

}

31
module Make
32
  (I : IncrementalEngine.EVERYTHING)
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
  (User : sig

    (* In order to submit artificial tokens to the parser, we need a function
       that converts a terminal symbol to a token. Unfortunately, we cannot
       (in general) auto-generate this code, because it requires making up
       semantic values of arbitrary OCaml types. *)

    val terminal2token: _ I.terminal -> I.token

  end)
: sig

  open I

  (* We build lists of explanations. These explanations may originate in
     distinct LR(1) states. *)

  (* TEMPORARY *)

  type reader =
    unit -> token * Lexing.position * Lexing.position

  (* TEMPORARY *)

57
  exception Error of (Lexing.position * Lexing.position) * (item, xsymbol) explanation list
58 59 60 61

  val entry: 'a I.result -> (Lexing.lexbuf -> token) -> Lexing.lexbuf -> 'a

end