parserAux.mli 1.86 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
(* This module provides utilities that are shared by the two versions
   of the parser. *)

open Syntax

(* TEMPORARY document *)

val current_token_precedence: Lexing.position -> Lexing.position -> precedence_level
val current_reduce_precedence: unit -> precedence_level

11 12
(* [check_production_group] accepts a production group and checks that all
   productions in the group define the same set of identifiers. *)
13

14 15 16 17 18 19 20 21 22 23 24 25
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]. *)

val normalize_producers: 
  (Positions.t * identifier Positions.located option * parameter) list ->
  producer list
26 27 28 29 30 31 32

(* [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

33 34 35 36 37 38 39 40
(* Support for on-the-fly expansion of anonymous rules. When such a
   rule is encountered, invoke [anonymous], which creates a fresh
   non-terminal symbol, records the definition of this symbol to a
   global variable, and returns this symbol. In the end, invoke
   [rules], so as to obtain a list of all recorded definitions. *)

val anonymous: Positions.t -> parameterized_branch list -> string
val rules: unit -> parameterized_rule list
41 42 43 44

(* [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]. *)
45 46 47
val producer_names :
  (_ * Syntax.identifier Positions.located option * _) list ->
  Syntax.identifier option array