grew_rule.mli 2.74 KB
Newer Older
bguillaum's avatar
bguillaum committed
1 2 3
open Grew_utils
open Grew_graph
open Grew_command
pj2m's avatar
pj2m committed
4 5
open Grew_edge
open Grew_fs
bguillaum's avatar
bguillaum committed
6
open Grew_ast
pj2m's avatar
pj2m committed
7

8
(* ================================================================================ *)
pj2m's avatar
pj2m committed
9 10
module Instance : sig
  type t = {
11 12 13 14 15 16 17 18 19 20
    graph: G_graph.t;
    history: Command.h list;
    rules: string list;
    big_step: Grew_types.big_step option;
    free_index: int;
    activated_node: Gid.t list;
  }

  (** [from_graph graph] return a fresh instance based on the input [graph]. *)
  val from_graph: G_graph.t -> t
bguillaum's avatar
bguillaum committed
21

22 23
  (** [rev_steps t] reverses the small step list: during rewriting, the last rule
      is in the head of the list and the reverse is needed for display. *)
pj2m's avatar
pj2m committed
24 25
  val rev_steps: t -> t

26
  (** [flatten inst] returns a fresh representation of the graph where gid created by node
27
      activation are map to basic gid. Graphs are flattened after each module. *)
28
  val flatten: t -> t
pj2m's avatar
pj2m committed
29

30
  (** [to_gr t] returns a string which contains the "gr" code of the current graph *)
31 32
  val to_gr: t -> string

bguillaum's avatar
bguillaum committed
33 34 35
  (** [to_conll t] returns a string which contains the "conll" code of the current graph *)
  val to_conll: t -> string

36
  (** [save_dep_png base t] writes a file "base.png" with the dep representation of [t].
bguillaum's avatar
bguillaum committed
37
      NB: if the Dep2pict is not available, nothing is done *)
38
  val save_dep_png: ?filter: string list -> ?main_feat: string -> string -> t -> unit
39

40
  (** [save_dot_png base t] writes a file "base.png" with the dot representation of [t] *)
41
  val save_dot_png: ?filter: string list -> ?main_feat: string -> string -> t -> unit
42
end (* module Instance *)
pj2m's avatar
pj2m committed
43

bguillaum's avatar
bguillaum committed
44

45
(* ================================================================================ *)
pj2m's avatar
pj2m committed
46 47
module Instance_set : Set.S with type elt = Instance.t

48
(* ================================================================================ *)
pj2m's avatar
pj2m committed
49 50 51
module Rule : sig
  type t

52
  (** [get_name t] returns the name of the rule [t]. *)
bguillaum's avatar
bguillaum committed
53 54
  val get_name: t -> string

bguillaum's avatar
bguillaum committed
55
  (** [get_loc t] returns the file location of the rule [t]. *)
56 57
  val get_loc: t -> Loc.t

58
  (** [is_filter t] returns [true] iff the rule [t] is a filter rule. *)
59 60
  val is_filter: t -> bool

61
  (** [to_dep t] returns a string in the [dep] language describing the pattern. *)
bguillaum's avatar
bguillaum committed
62 63
  val to_dep: t -> string

64 65 66
  (** [build ?local dir ast_rule] returns the Rule.t value corresponding to [ast_rule].
      [dir] is used for localisation of lp files *)
  val build: ?locals:Label.decl array -> string -> Ast.rule -> t
pj2m's avatar
pj2m committed
67

68
  (** [normalize module_name ?confluent rule_list filter_list instance] returns two sets of good normal forms and bad normal forms *)
pj2m's avatar
pj2m committed
69
  (* raise Stop if some command fails to apply *)
70 71
  val normalize:
    string -> (* module name *)
bguillaum's avatar
bguillaum committed
72
    ?confluent:bool ->
73 74
    t list -> (* rule list *)
    t list -> (* filter list *)
pj2m's avatar
pj2m committed
75 76
    Instance.t ->
      Instance_set.t * Instance_set.t
77
end (* module Rule *)