aboutsummaryrefslogtreecommitdiff
path: root/rego-proofs/compiler-rewrite/lib/ast.mli
blob: 1d3d69a8be65ca2b1e96cdb350bd3c6d385c183a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
type expr = Term of term | Every of string option * string * term * query

and literal =
  | Exists of expr list * with_modifier option
  | Expr of expr * with_modifier option
  | Negate of expr * with_modifier option

and query = literal list

and term =
  | Scalar of scalar
  | Var of string
  | Ref of reference
  | Array of term list
  | Object of (object_key * term) list
  | Set of term list
  | ArrayComprehension of term * query
  | ObjectComprehension of (object_key * term) * query
  | SetComprehension of term * query
  | Call of reference * term list

and scalar = String of string | Number of float | Bool of bool | Null
and reference = ref_target * term list

and ref_target =
  | Var of string
  | Array of term list
  | Object of (object_key * term) list
  | Set of term list
  | ArrayComprehension of term * query
  | ObjectComprehension of (object_key * term) * query
  | SetComprehension of term * query
  | Call of reference * term list

and object_key = Scalar of scalar | Ref of reference | Var of string
and with_modifier = (term * term) list

type assign_operator = Assign | Unify
type rule_head_lhs = reference

type rule_head_rhs =
  | Assignment of assign_operator * term
  | Function of assign_operator * string list * term
  | Set of term

type rule_head = rule_head_lhs * rule_head_rhs

type rule = {
  default : bool;
  head : rule_head;
  body : query;
  otherwise : rule option;
}

type import = { alias : string option; path : reference }
type package = { path : reference; imports : import list; policy : rule list }

val ast_of_string : string -> package
val show_package : package -> string

val equal_assign_operator : assign_operator -> assign_operator -> bool
val equal_expr : expr -> expr -> bool
val equal_import : import -> import -> bool
val equal_literal : literal -> literal -> bool
val equal_object_key : object_key -> object_key -> bool
val equal_package : package -> package -> bool
val equal_query : query -> query -> bool
val equal_ref_target : ref_target -> ref_target -> bool
val equal_reference : reference -> reference -> bool
val equal_rule : rule -> rule -> bool
val equal_rule_head : rule_head -> rule_head -> bool
val equal_rule_head_lhs : rule_head_lhs -> rule_head_lhs -> bool
val equal_rule_head_rhs : rule_head_rhs -> rule_head_rhs -> bool
val equal_scalar : scalar -> scalar -> bool
val equal_term : term -> term -> bool
val equal_with_modifier : with_modifier -> with_modifier -> bool
val pp_assign_operator : Format.formatter -> assign_operator -> unit
val pp_expr : Format.formatter -> expr -> unit
val pp_import : Format.formatter -> import -> unit
val pp_literal : Format.formatter -> literal -> unit
val pp_object_key : Format.formatter -> object_key -> unit
val pp_package : Format.formatter -> package -> unit
val pp_query : Format.formatter -> query -> unit
val pp_ref_target : Format.formatter -> ref_target -> unit
val pp_reference : Format.formatter -> reference -> unit
val pp_rule : Format.formatter -> rule -> unit
val pp_rule_head : Format.formatter -> rule_head -> unit
val pp_rule_head_lhs : Format.formatter -> rule_head_lhs -> unit
val pp_rule_head_rhs : Format.formatter -> rule_head_rhs -> unit
val pp_scalar : Format.formatter -> scalar -> unit
val pp_term : Format.formatter -> term -> unit
val pp_with_modifier : Format.formatter -> with_modifier -> unit
val show_assign_operator : assign_operator -> string
val show_expr : expr -> string
val show_import : import -> string
val show_literal : literal -> string
val show_object_key : object_key -> string
val show_package : package -> string
val show_query : query -> string
val show_ref_target : ref_target -> string
val show_reference : reference -> string
val show_rule : rule -> string
val show_rule_head : rule_head -> string
val show_rule_head_lhs : rule_head_lhs -> string
val show_rule_head_rhs : rule_head_rhs -> string
val show_scalar : scalar -> string
val show_term : term -> string
val show_with_modifier : with_modifier -> string

© 2015 - 2026 Jakob L. Kreuze