10238513f1f6a6d637d85d1aeff18f12820004ef
[bpt/coccinelle.git] / bundles / menhirLib / menhir-20120123 / src / action.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 (* $Id: action.mli,v 1.8 2006/06/26 09:41:33 regisgia Exp $ *)
16
17 (** Semantic action's type. *)
18 type t
19
20 (** [compose x a1 a2] builds the action [let x = a1 in a2]. This
21 feature is used during the processing of the %inline keyword. *)
22 val compose : string -> t -> t -> t
23
24 (** [rename renaming_env phi a] builds the action
25 [let x1 = x1' and ... xn = xn' in a] if [phi] is [(x1, x1') ... (xn, xn')].
26 Moreover, [renaming_env] is used to correctly replace $startpos/$endpos
27 present in the semantic action. *)
28 val rename:
29 string * (Keyword.subject * Keyword.where) * (Keyword.subject * Keyword.where)
30 -> (string * string) list -> t -> t * (bool * bool)
31
32 (** [rename_inlined_psym renaming_env phi a] updates the occurrences of the
33 inlined non terminal in the action [a].
34 *)
35 val rename_inlined_psym:
36 string * (Keyword.subject * Keyword.where) * (Keyword.subject * Keyword.where)
37 -> (string * string) list -> t -> t * (bool * bool)
38
39 (** Semantic actions are translated into [IL] code using the
40 [IL.ETextual] and [IL.ELet] constructors. *)
41 val to_il_expr: t -> IL.expr
42
43 (** A semantic action might be the inlining of several others. The
44 filenames of the different parts are given by [filenames a]. This
45 can be used, for instance, to check whether all parts come from
46 the standard library. *)
47 val filenames: t -> string list
48
49 (** [pkeywords a] returns a list of all keyword occurrences in [a]. *)
50 val pkeywords: t -> Keyword.keyword Positions.located list
51
52 (** [keywords a] is the set of keywords used in the semantic action [a]. *)
53 val keywords: t -> Keyword.KeywordSet.t
54
55 (** [print f a] prints [a] to channel [f]. *)
56 val print: out_channel -> t -> unit
57
58 (** [from_stretch s] builds an action out of a textual piece of code. *)
59 val from_stretch: Stretch.t -> t
60
61 (** Check whether the keyword $previouserror is used in the action. *)
62 val has_previouserror: t -> bool
63
64 (** Check whether the keyword $syntaxerror is used in the action. *)
65 val has_syntaxerror: t -> bool
66
67 (** Check whether the keyword $start is used in the action. *)
68 val has_leftstart: t -> bool
69
70 (** Check whether the keyword $end is used in the action. *)
71 val has_leftend: t -> bool
72
73 (** Check whether a particular $i keyword is used in the action. *)
74 val has_dollar: int -> t -> bool
75
76 (** Check whether any $i keyword is used in the action. *)
77 val use_dollar: t -> bool
78