keyword.mli 1.25 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
(* This module provides some type and function definitions
   that help deal with the keywords that we recognize within
   semantic actions. *)

(* The user can request position information either at type
   [int] (a simple offset) or at type [Lexing.position]. *)

type flavor =
  | FlavorOffset
  | FlavorPosition

(* The user can request position information about the
   start or end of a symbol. *)

type where =
  | WhereStart
  | WhereEnd

(* The user can request position information about a production's
   left-hand side or about one of the symbols in its right-hand
   side, which he can refer to by position or by name. *)
22 23 24 25
type parsed_subject =
  | PLeft
  | PRightDollar of int
  | PRightNamed of string
26

27
and subject =
28 29 30 31 32 33
  | Left
  | RightNamed of string

(* Keywords inside semantic actions. They allow access to semantic
   values or to position information. *)

34 35 36 37 38 39
type parsed_keyword =
  | PDollar of int
  | PPosition of parsed_subject * where * flavor
  | PSyntaxError

and keyword =
40 41 42 43 44 45 46 47 48
  | Position of subject * where * flavor
  | SyntaxError

(* This maps a [Position] keyword to the name of the variable that the
   keyword is replaced with. *)

val posvar: subject -> where -> flavor -> string

(* Sets of keywords. *)
49
module KeywordSet : Set.S with type elt = keyword
50