summaryrefslogtreecommitdiff
path: root/frontend/ast.ml
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/ast.ml')
-rw-r--r--frontend/ast.ml63
1 files changed, 39 insertions, 24 deletions
diff --git a/frontend/ast.ml b/frontend/ast.ml
index 180608c..72f7049 100644
--- a/frontend/ast.ml
+++ b/frontend/ast.ml
@@ -18,59 +18,74 @@ type typ =
type unary_op =
| AST_UPLUS
| AST_UMINUS
- | AST_NOT
- | AST_PRE
type binary_op =
+ (* num * num -> num *)
| AST_PLUS
| AST_MINUS
| AST_MUL
| AST_DIV
| AST_MOD
+type binary_rel_op =
+ (* 'a * 'a -> bool *)
| AST_EQ
| AST_NE
-
+ (* num * num -> bool *)
| AST_LT
| AST_LE
| AST_GT
| AST_GE
+type bin_bool_op =
+ (* bool * bool -> bool *)
| AST_AND
| AST_OR
- | AST_ARROW
-
type expr =
- | AST_unary of unary_op * (expr ext)
- | AST_binary of binary_op * (expr ext) * (expr ext)
- | AST_identifier of id ext
- | AST_int_const of string ext
- | AST_bool_const of bool
- | AST_real_const of string ext
- | AST_if of (expr ext) * (expr ext) * (expr ext)
- | AST_instance of (id ext) * (expr ext list)
-
-type lvalue = id
+ | AST_identifier of id ext
+ (* on numerical values *)
+ | AST_int_const of string ext
+ | AST_real_const of string ext
+ | AST_unary of unary_op * (expr ext)
+ | AST_binary of binary_op * (expr ext) * (expr ext)
+ (* on boolean values *)
+ | AST_bool_const of bool
+ | AST_binary_rel of binary_rel_op * (expr ext) * (expr ext)
+ | AST_binary_bool of bin_bool_op * (expr ext) * (expr ext)
+ | AST_not of expr ext
+ (* temporal primitives *)
+ | AST_pre of expr ext
+ | AST_arrow of (expr ext) * (expr ext)
+ (* other *)
+ | AST_if of (expr ext) * (expr ext) * (expr ext)
+ | AST_instance of (id ext) * (expr ext list)
+ (* (TODO) and more : when, merge, activate instances, ... *)
type eqn =
- | AST_assign of (lvalue ext) * (expr ext)
- | AST_guarantee of (id ext) * (expr ext)
- | AST_assume of (id ext) * (expr ext)
- (* and more : automaton, activate... *)
+ | AST_assign of (id ext) * (expr ext)
+ | AST_guarantee of (id ext) * (expr ext)
+ | AST_assume of (id ext) * (expr ext)
+ (* (TODO) and more : automaton, activate... *)
+
+type var_def = bool * (id ext) * typ
type node_decl = {
name : id;
- args : (bool * (id ext) * typ) list;
- ret : (bool * (id ext) * typ) list;
- var : (bool * (id ext) * typ) list;
+ args : var_def list;
+ ret : var_def list;
+ var : var_def list;
body : eqn ext list;
}
-type const_decl = (id ext) * typ * (expr ext)
+type const_decl = {
+ name : id;
+ typ : typ;
+ value : expr ext;
+}
type toplevel =
- | AST_node_decl of node_decl ext
+ | AST_node_decl of node_decl ext
| AST_const_decl of const_decl ext
type prog = toplevel list