diff options
Diffstat (limited to 'frontend')
-rw-r--r-- | frontend/ast.ml | 1 | ||||
-rw-r--r-- | frontend/ast_printer.ml | 4 | ||||
-rw-r--r-- | frontend/ast_util.ml | 2 | ||||
-rw-r--r-- | frontend/typing.ml | 10 |
4 files changed, 14 insertions, 3 deletions
diff --git a/frontend/ast.ml b/frontend/ast.ml index 4f8c860..ae11064 100644 --- a/frontend/ast.ml +++ b/frontend/ast.ml @@ -57,6 +57,7 @@ type expr = (* other *) | AST_if of (expr ext) * (expr ext) * (expr ext) | AST_instance of (id ext) * (expr ext list) * id + | AST_tuple of expr ext list type var_def = bool * id * typ diff --git a/frontend/ast_printer.ml b/frontend/ast_printer.ml index 7ddcb67..ac30fe9 100644 --- a/frontend/ast_printer.ml +++ b/frontend/ast_printer.ml @@ -160,6 +160,10 @@ let rec print_expr fmt e = Format.fprintf fmt "%a(%a)" print_id i (print_list print_expr ", ") (List.map fst l) + | AST_tuple x -> + Format.fprintf fmt "(%a)" + (print_list print_expr ", ") (List.map fst x) + (* equations *) diff --git a/frontend/ast_util.ml b/frontend/ast_util.ml index a7953ad..b3393a7 100644 --- a/frontend/ast_util.ml +++ b/frontend/ast_util.ml @@ -55,6 +55,7 @@ let rec extract_instances p e = match fst e with let (node, _) = find_node_decl p f in let args_x = List.map2 (fun id arg -> id, arg) node.args args in (f, id, node.body, args_x)::more + | AST_tuple x -> List.flatten (List.map (extract_instances p) x) (* Utility : find pre declarations in an expression *) @@ -70,6 +71,7 @@ let rec extract_pre e = match fst e with extract_pre e1 @ extract_pre e2 @ extract_pre e3 | AST_instance((f, _), args, id) -> List.flatten (List.map extract_pre args) + | AST_tuple x -> List.flatten (List.map extract_pre x) | AST_pre(e', n) -> (n, e')::(extract_pre e') diff --git a/frontend/typing.ml b/frontend/typing.ml index 07b3bcd..1545a38 100644 --- a/frontend/typing.ml +++ b/frontend/typing.ml @@ -13,8 +13,8 @@ type typ = | TReal | TEnum of string list -let bool_true = "T" -let bool_false = "F" +let bool_true = "tt" +let bool_false = "ff" let bool_type = TEnum [bool_true; bool_false] let t_of_ast_t = function @@ -87,11 +87,15 @@ let rec type_expr_vl p vl cvl node expr = (* do not check types of arguments... TODO? *) let (n, _) = find_node_decl p f in List.map (fun (_, _, t) -> t_of_ast_t t) n.ret + | AST_tuple x -> List.flatten (List.map sub x) -(* type_expr : tp -> string -> typ list *) +(* type_expr : tp -> string -> expr -> typ list *) let type_expr tp = type_expr_vl tp.p tp.all_vars tp.const_vars +let type_var tp node id = + let _, _, t = List.find (fun (_, x, _) -> x = (node^"/"^id)) tp.all_vars in t + (* Program rooting *) |