summaryrefslogtreecommitdiff
path: root/frontend
diff options
context:
space:
mode:
authorAlex Auvolat <alex.auvolat@ansys.com>2014-06-19 13:47:00 +0200
committerAlex Auvolat <alex.auvolat@ansys.com>2014-06-19 13:47:00 +0200
commitf4200a0aa90e2641ce1b0b1c54d00d9d4dd3b73e (patch)
tree53b82c4d758d11936f0ee0d106ea0aaf75d48f61 /frontend
parent8286c7c23a47c166aa87337a3146cdf3b278b144 (diff)
downloadscade-analyzer-f4200a0aa90e2641ce1b0b1c54d00d9d4dd3b73e.tar.gz
scade-analyzer-f4200a0aa90e2641ce1b0b1c54d00d9d4dd3b73e.zip
Did most of the boring stuff. Now, work on the abstract domain.
Diffstat (limited to 'frontend')
-rw-r--r--frontend/ast.ml1
-rw-r--r--frontend/ast_printer.ml4
-rw-r--r--frontend/ast_util.ml2
-rw-r--r--frontend/typing.ml10
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 *)