action.mli 2.03 KB
Newer Older
1 2 3 4 5 6 7
(** Semantic action's type. *)
type t

(** [compose x a1 a2] builds the action [let x = a1 in a2]. This
    feature is used during the processing of the %inline keyword. *)
val compose : string -> t -> t -> t

8 9
(* TEMPORARY document this: *)

10 11 12
type subst =
  (string * string) list

13 14 15
type sw =
  Keyword.subject * Keyword.where

16 17 18 19 20 21 22 23 24 25
(** [rename f phi a] applies to the semantic action [a] the renaming [phi] as
    well as the transformations decided by the function [f]. The function [f] is
    applied to each (not-yet-renamed) keyword and may decide to transform it, by
    returning [Some _], or to not transform it, by returning [None]. (In the
    latter case, [phi] still applies to the keyword.) *)
val rename:
  (sw -> sw option) ->
  subst ->
  t ->
  t
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57

(** Semantic actions are translated into [IL] code using the
    [IL.ETextual] and [IL.ELet] constructors. *)
val to_il_expr: t -> IL.expr

(** A semantic action might be the inlining of several others. The
    filenames of the different parts are given by [filenames a]. This
    can be used, for instance, to check whether all parts come from
    the standard library. *)
val filenames: t -> string list

(** [pkeywords a] returns a list of all keyword occurrences in [a]. *)
val pkeywords: t -> Keyword.keyword Positions.located list

(** [keywords a] is the set of keywords used in the semantic action [a]. *)
val keywords: t -> Keyword.KeywordSet.t

(** [print f a] prints [a] to channel [f]. *)
val print: out_channel -> t -> unit

(** [from_stretch s] builds an action out of a textual piece of code. *)
val from_stretch: Stretch.t -> t

(** Check whether the keyword $syntaxerror is used in the action. *)
val has_syntaxerror: t -> bool

(** Check whether the keyword $start is used in the action. *)
val has_leftstart: t -> bool

(** Check whether the keyword $end is used in the action. *)
val has_leftend: t -> bool

58 59 60
(** Check whether the keyword $start or $end is used in the action. *)
val has_left: t -> bool

61
(** Check whether the keyword $endpos($0) is used in the action. *)
62
val has_beforeend: t -> bool