1 (**************************************************************************)
5 (* François Pottier, INRIA Rocquencourt *)
6 (* Yann Régis-Gianas, PPS, Université Paris Diderot *)
8 (* Copyright 2005-2008 Institut National de Recherche en Informatique *)
9 (* et en Automatique. All rights reserved. This file is distributed *)
10 (* under the terms of the Q Public License version 1.0, with the change *)
11 (* described in file LICENSE. *)
13 (**************************************************************************)
15 (* This module provides some type and function definitions
16 that help deal with the keywords that we recognize within
19 (* ------------------------------------------------------------------------- *)
22 (* The user can request position information either at type
23 [int] (a simple offset) or at type [Lexing.position]. *)
29 (* The user can request position information about the
30 start or end of a symbol. *)
36 (* The user can request position information about a production's
37 left-hand side or about one of the symbols in its right-hand
38 side, which he can refer to by position or by name. *)
43 | RightNamed
of string
45 (* Keywords inside semantic actions. They allow access to semantic
46 values or to position information. *)
50 | Position
of subject
* where
* flavor
54 (* ------------------------------------------------------------------------- *)
55 (* These auxiliary functions help map a [Position] keyword to the
56 name of the variable that the keyword is replaced with. *)
64 let subject = function
68 Printf.sprintf
"__%d_" i
70 Printf.sprintf
"_%s_" id
79 Printf.sprintf
"_%s%s%s" (where w
) (flavor f
) (subject s
)
81 (* ------------------------------------------------------------------------- *)
82 (* Sets of keywords. *)
86 include Set.Make
(struct
91 (* This converts a list of keywords with positions into a set of keywords. *)
92 let from_list keywords
=
93 List.fold_right add keywords empty