grew_ast.mli 3.3 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 41 42 43

  type feature = u_feature * Loc.t

(* qualified feature name "A.lemma" *)
  type qfn = string * string

  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

bguillaum's avatar
bguillaum committed
44 45 46 47
  type ineq = Lt | Gt | Le | Ge

  val string_of_ineq: ineq -> string

bguillaum's avatar
bguillaum committed
48 49
  type u_const = 
    | Start of Id.name * string list (* (source, labels) *)
bguillaum's avatar
bguillaum committed
50
    | Cst_out of Id.name
bguillaum's avatar
bguillaum committed
51
    | End of Id.name * string list (* (target, labels) *)
bguillaum's avatar
bguillaum committed
52
    | Cst_in of Id.name
bguillaum's avatar
bguillaum committed
53
    | Feature_eq of qfn * qfn
bguillaum's avatar
bguillaum committed
54 55
    | Feature_diseq of qfn * qfn
    | Feature_ineq of ineq * qfn * qfn
bguillaum's avatar
bguillaum committed
56 57 58 59 60 61 62 63 64 65 66 67

  type const = u_const * Loc.t

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

  type concat_item =
    | Qfn_item of (string * string)
    | String_item of string
68
    | Param_item of string
bguillaum's avatar
bguillaum committed
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
          
  type u_command = 
    | Del_edge_expl of (Id.name * Id.name * string)
    | Del_edge_name of string
    | Add_edge of (Id.name * Id.name * string)
    | Shift_in of (Id.name*Id.name)
    | Shift_out of (Id.name*Id.name)
    | Shift_edge of (Id.name*Id.name)
    | Merge_node of (Id.name*Id.name)
    | New_neighbour of (Id.name * Id.name * string)
    | Del_node of Id.name

    | Del_feat of qfn
    | Update_feat of qfn * concat_item list

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

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

  type grs_with_include = {
      domain_wi: domain;
      labels_wi: (string * string option) list;    (* the list of global edge labels *)
      modules_wi: module_or_include list; 
      sequences_wi: sequence list;
    }

  type grs = {
      domain: domain;
      labels: (string * string option) list;
      modules: modul list;
      sequences: sequence list;
    }

  type gr = {
137 138 139 140
    meta: (string * string) list;
    nodes: node list;
    edges: edge list;
  }
bguillaum's avatar
bguillaum committed
141
end (* module Ast *)