Coccinelle release 1.0.0-rc13
[bpt/coccinelle.git] / bundles / menhirLib / menhir-20120123 / src / keyword.mli
1 (**************************************************************************)
2 (* *)
3 (* Menhir *)
4 (* *)
5 (* François Pottier, INRIA Rocquencourt *)
6 (* Yann Régis-Gianas, PPS, Université Paris Diderot *)
7 (* *)
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. *)
12 (* *)
13 (**************************************************************************)
14
15 (* This module provides some type and function definitions
16 that help deal with the keywords that we recognize within
17 semantic actions. *)
18
19 (* The user can request position information either at type
20 [int] (a simple offset) or at type [Lexing.position]. *)
21
22 type flavor =
23 | FlavorOffset
24 | FlavorPosition
25
26 (* The user can request position information about the
27 start or end of a symbol. *)
28
29 type where =
30 | WhereStart
31 | WhereEnd
32
33 (* The user can request position information about a production's
34 left-hand side or about one of the symbols in its right-hand
35 side, which he can refer to by position or by name. *)
36
37 type subject =
38 | Left
39 | RightDollar of int
40 | RightNamed of string
41
42 (* Keywords inside semantic actions. They allow access to semantic
43 values or to position information. *)
44
45 type keyword =
46 | Dollar of int
47 | Position of subject * where * flavor
48 | PreviousError
49 | SyntaxError
50
51 (* This maps a [Position] keyword to the name of the variable that the
52 keyword is replaced with. *)
53
54 val posvar: subject -> where -> flavor -> string
55
56 (* Sets of keywords. *)
57 module KeywordSet :
58 sig
59 include Set.S
60
61 (* This converts a list of keywords with positions into a set of keywords. *)
62 val from_list: elt list -> t
63
64 end with type elt = keyword
65
66 (* (\* TEMPORARY These functions are replaced by the ones found *)
67 (* in [Action]. *\) *)
68 (* (\* These iterate over a list of keywords with positions, disregarding *)
69 (* the positions, and making sure that duplicate elements are not *)
70 (* presented. *\) *)
71
72 (* val iter: (keyword -> unit) -> (keyword * 'a * 'b) list -> unit *)
73 (* val fold: (keyword -> 'c -> 'c) -> (keyword * 'a * 'b) list -> 'c -> 'c *)
74
75 (* (\* These tell whether a list of keywords with positions contains *)
76 (* a certain keyword. *\) *)
77
78 (* val has_previouserror: (keyword * 'a * 'b) list -> bool *)
79 (* val has_syntaxerror: (keyword * 'a * 'b) list -> bool *)
80 (* val has_leftstart: (keyword * 'a * 'b) list -> bool *)
81 (* val has_leftend: (keyword * 'a * 'b) list -> bool *)
82 (* val has_dollar: int -> (keyword * 'a * 'b) list -> bool *)