grew_ast.mli 3.01 KB
Newer Older
bguillaum's avatar
bguillaum committed
1 2 3 4 5 6 7 8 9
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 *)
          
  type domain = feature_spec list
        
bguillaum's avatar
bguillaum committed
10 11 12 13
  type feature_kind = 
    | Equality of string list 
    | Disequality of string list
    | Param of string
bguillaum's avatar
bguillaum committed
14 15 16

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

  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

  type u_const = 
    | Start of Id.name * string list (* (source, labels) *)
bguillaum's avatar
bguillaum committed
46
    | Cst_out of Id.name
bguillaum's avatar
bguillaum committed
47
    | End of Id.name * string list (* (target, labels) *)
bguillaum's avatar
bguillaum committed
48
    | Cst_in of Id.name
bguillaum's avatar
bguillaum committed
49 50 51 52 53 54 55 56 57 58 59 60 61
    | Feature_eq of qfn * qfn

  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
62
    | Param_item of string
bguillaum's avatar
bguillaum committed
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
          
  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
79

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

  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 = {
      nodes: node list;
      edges: edge list;
    }
end (* module Ast *)