parserAux.mli 2.62 KB
Newer Older
1 2 3 4 5
(* This module provides utilities that are shared by the two versions
   of the parser. *)

open Syntax

6 7 8 9 10 11 12
(* [new_precedence_level pos1 pos2] creates a new precendence level, which is
   stronger than any levels previously created by this function. It should be
   called every time a [%left], [%right], or [%nonassoc] declaration is found.
   The positions are the positions of this declaration in the source code. The
   precedence levels created by this function are attached to tokens and (via
   %prec) to productions. They are used in solving shift/reduce and
   shift/reduce/reduce conflicts. *)
13 14 15

val new_precedence_level: Lexing.position -> Lexing.position -> precedence_level

16
(* [new_production_level()] creates a new production level, which is stronger
17
   than any levels previously created by this function. It should be called
18
   every time a new production is found. The production levels created by this
19 20 21 22 23
   function are attached to productions. They are used in solving
   reduce/reduce conflicts: following ocamlyacc and bison, the production that
   appears first in the grammar receives preference. It may seem very strange
   that %prec annotations do not influence this process, but that's how it is,
   at least for the moment. *)
24

25
val new_production_level: unit -> branch_production_level
26

27 28 29 30 31
(* [new_on_error_reduce_level()] creates a new level, which is attached to an
   [%on_error_reduce] declaration. *)

val new_on_error_reduce_level: unit -> on_error_reduce_level

32 33
(* [check_production_group] accepts a production group and checks that all
   productions in the group define the same set of identifiers. *)
34

35 36 37 38 39 40 41 42 43
val check_production_group:
  ((Positions.t * identifier Positions.located option * parameter) list * 'a * 'b * 'c) list ->
  unit

(* [normalize_producers] accepts a list of producers where identifiers are
   optional and returns a list of producers where identifiers are mandatory.
   A missing identifier in the [i]-th position receives the conventional
   name [_i]. *)

POTTIER Francois's avatar
POTTIER Francois committed
44
val normalize_producers:
45 46
  (Positions.t * identifier Positions.located option * parameter) list ->
  producer list
47 48 49 50 51 52 53

(* [override pos oprec1 oprec2] decides which of the two optional
   %prec declarations [oprec1] and [oprec2] applies to a
   production. It signals an error if the two are present. *)

val override: Positions.t -> 'a option -> 'a option -> 'a option

54 55 56
(* [producer_names producers] returns an array [names] such that
   [names.(idx) = None] if the (idx + 1)-th producer is unnamed
   and [names.(idx) = Some id] if it is called [id]. *)
57 58 59
val producer_names :
  (_ * Syntax.identifier Positions.located option * _) list ->
  Syntax.identifier option array