grew_ast.mli 3.59 KB
Newer Older
bguillaum's avatar
bguillaum committed
1 2 3 4 5 6
open Grew_utils
 
module Ast : sig
  type feature_spec = 
    | Closed of string * string list (* (the name, the set of atomic values) *)
    | Open of string (* the name *)
bguillaum's avatar
bguillaum committed
7 8
    | Int of string (* the name *)

bguillaum's avatar
bguillaum committed
9 10
  type domain = feature_spec list
        
bguillaum's avatar
bguillaum committed
11 12 13 14
  type feature_kind = 
    | Equality of string list 
    | Disequality of string list
    | Param of string
bguillaum's avatar
bguillaum committed
15 16 17

  type u_feature = {
      name: string;
bguillaum's avatar
bguillaum committed
18
      kind: feature_kind;
bguillaum's avatar
bguillaum committed
19
    }
bguillaum's avatar
bguillaum committed
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40

  type feature = u_feature * Loc.t

  type u_node = {
      node_id: Id.name;
      position: int option;
      fs: feature list;
    }

  type node = u_node * Loc.t

  type u_edge = {
      edge_id: Id.name option;
      src: Id.name;
      edge_labels: string list;
      tar: Id.name;
      negative: bool;
    }

  type edge = u_edge * Loc.t

41 42 43 44 45
  (* the base node name and the eventual new_node extension *)
  type c_ident = Id.name * string option

  val c_ident_to_string: c_ident -> string

bguillaum's avatar
bguillaum committed
46 47 48 49
  type ineq = Lt | Gt | Le | Ge

  val string_of_ineq: ineq -> string

50 51
  type feature_name = string

bguillaum's avatar
bguillaum committed
52
  type u_const = 
53 54 55 56 57 58 59
    | Start of c_ident * string list (* (source, labels) *)
    | Cst_out of c_ident
    | End of c_ident * string list (* (target, labels) *)
    | Cst_in of c_ident
    | Feature_eq of (c_ident * feature_name) * (c_ident * feature_name)
    | Feature_diseq of (c_ident * feature_name) * (c_ident * feature_name)
    | Feature_ineq of ineq * (c_ident * feature_name) * (c_ident * feature_name)
bguillaum's avatar
bguillaum committed
60 61 62 63 64 65 66 67 68 69

  type const = u_const * Loc.t

  type pattern = {
      pat_nodes: node list;
      pat_edges: edge list;
      pat_const: const list;
    }

  type concat_item =
70
    | Qfn_item of (c_ident * feature_name)
bguillaum's avatar
bguillaum committed
71
    | String_item of string
72
    | Param_item of string
73

bguillaum's avatar
bguillaum committed
74
  type u_command = 
75
    | Del_edge_expl of (c_ident * c_ident * string)
bguillaum's avatar
bguillaum committed
76
    | Del_edge_name of string
77 78 79 80 81 82 83
    | Add_edge of (c_ident * c_ident * string)
    | Shift_in of (c_ident*c_ident)
    | Shift_out of (c_ident*c_ident)
    | Shift_edge of (c_ident*c_ident)
    | Merge_node of (c_ident*c_ident)
    | New_neighbour of (c_ident * c_ident * string)
    | Del_node of c_ident
84
    | Activate of c_ident
85 86 87

    | Del_feat of (c_ident * feature_name)
    | Update_feat of (c_ident * feature_name) * concat_item list
bguillaum's avatar
bguillaum committed
88 89

  type command = u_command * Loc.t
bguillaum's avatar
bguillaum committed
90

bguillaum's avatar
bguillaum committed
91 92 93 94 95
  type rule = {
      rule_id:Id.name;
      pos_pattern: pattern;
      neg_patterns: pattern list;
      commands: command list;
96 97
      param: (string list * string list) option; (* (files, vars) *)
      lp: string list option; (* lexical parameters in the file *)
bguillaum's avatar
bguillaum committed
98
      rule_doc:string list;
bguillaum's avatar
bguillaum committed
99 100 101 102 103
      rule_loc: Loc.t;
    }
        
  type modul = {
      module_id:Id.name;
104
      local_labels: (string * string list) list;
105
      new_node_names: string list;
bguillaum's avatar
bguillaum committed
106 107
      rules: rule list;
      confluent: bool;
bguillaum's avatar
bguillaum committed
108
      module_doc:string list;
bguillaum's avatar
bguillaum committed
109
      mod_loc:Loc.t;
110
      mod_dir: string; (* the directory where the module is defined (for lp file localisation) *)
bguillaum's avatar
bguillaum committed
111 112 113 114 115
    }
        
  type sequence = {
      seq_name:string;
      seq_mod:string list;
bguillaum's avatar
bguillaum committed
116
      seq_doc:string list;
bguillaum's avatar
bguillaum committed
117 118 119 120 121 122 123 124
      seq_loc:Loc.t;
    }
        
(** 
    a GRS: graph rewriting system 
 *)
  type module_or_include = 
    | Modul of modul
125
    | Includ of (string * Loc.t)
bguillaum's avatar
bguillaum committed
126 127 128

  type grs_with_include = {
      domain_wi: domain;
129
      labels_wi: (string * string list) list;    (* the list of global edge labels *)
bguillaum's avatar
bguillaum committed
130 131 132 133 134 135
      modules_wi: module_or_include list; 
      sequences_wi: sequence list;
    }

  type grs = {
      domain: domain;
136
      labels: (string * string list) list;
bguillaum's avatar
bguillaum committed
137 138 139 140 141
      modules: modul list;
      sequences: sequence list;
    }

  type gr = {
142 143 144 145
    meta: (string * string) list;
    nodes: node list;
    edges: edge list;
  }
bguillaum's avatar
bguillaum committed
146
end (* module Ast *)