Add FBY instruction

This commit is contained in:
Benjamin Loison 2022-12-09 22:56:51 +01:00
parent a29666f673
commit e9dd3fbde4
4 changed files with 12 additions and 0 deletions

View File

@ -47,6 +47,7 @@ type t_expression =
| ETriOp of full_ty * triop * t_expression * t_expression * t_expression | ETriOp of full_ty * triop * t_expression * t_expression * t_expression
| EComp of full_ty * compop * t_expression * t_expression | EComp of full_ty * compop * t_expression * t_expression
| EWhen of full_ty * t_expression * t_expression | EWhen of full_ty * t_expression * t_expression
| EFby of full_ty * t_expression * t_expression
| EConst of full_ty * const | EConst of full_ty * const
| ETuple of full_ty * (t_expression list) | ETuple of full_ty * (t_expression list)
| EApp of full_ty * t_node * t_expression | EApp of full_ty * t_node * t_expression

View File

@ -29,6 +29,7 @@
("else", ELSE); ("else", ELSE);
("merge", TO_merge); ("merge", TO_merge);
("when", WHEN); ("when", WHEN);
("fby", FBY);
("pre", MO_pre); ("pre", MO_pre);
("true", CONST_BOOL(true)); ("true", CONST_BOOL(true));
("false", CONST_BOOL(false)); ("false", CONST_BOOL(false));

View File

@ -35,6 +35,7 @@
| ETriOp (full_ty , _ , _ , _ , _) -> full_ty | ETriOp (full_ty , _ , _ , _ , _) -> full_ty
| EComp (full_ty , _ , _ , _) -> full_ty | EComp (full_ty , _ , _ , _) -> full_ty
| EWhen (full_ty , _ , _) -> full_ty | EWhen (full_ty , _ , _) -> full_ty
| EFby (full_ty , _ , _) -> full_ty
| EConst (full_ty , _) -> full_ty | EConst (full_ty , _) -> full_ty
| ETuple (full_ty , _) -> full_ty | ETuple (full_ty , _) -> full_ty
| EApp (full_ty , _ , _) -> full_ty | EApp (full_ty , _ , _) -> full_ty
@ -95,6 +96,7 @@
%token TO_merge %token TO_merge
%token WHEN %token WHEN
%token FBY
%token IF %token IF
%token THEN %token THEN
@ -234,6 +236,7 @@ expr:
| TO_merge expr expr expr { ETriOp (type_exp $4, TOp_merge, $2, $3, $4) } | TO_merge expr expr expr { ETriOp (type_exp $4, TOp_merge, $2, $3, $4) }
/* When is neither a binop (a * 'a -> 'a) or a comp ('a * 'a -> bool) */ /* When is neither a binop (a * 'a -> 'a) or a comp ('a * 'a -> bool) */
| expr WHEN expr { EWhen (type_exp $1, $1, $3) } | expr WHEN expr { EWhen (type_exp $1, $1, $3) }
| expr FBY expr { EFby (type_exp $1, $1, $3) }
/* Constants */ /* Constants */
| CONST_INT { EConst (FTBase TInt, CInt $1) } | CONST_INT { EConst (FTBase TInt, CInt $1) }
| CONST_BOOL { EConst (FTBase TBool, CBool $1) } | CONST_BOOL { EConst (FTBase TBool, CBool $1) }

View File

@ -33,6 +33,13 @@ let pp_expression =
| _ -> raise (MyTypeError "This exception should not have been raised.") | _ -> raise (MyTypeError "This exception should not have been raised.")
in in
match expression with match expression with
| EFby (_, e1, e2) ->
begin
Format.fprintf fmt "\t\t\t%sFBY\n%a\t\t\tFBY\n%a"
prefix
(pp_expression_aux (upd_prefix prefix)) e1
(pp_expression_aux (upd_prefix prefix)) e2
end
| EWhen (_, e1, e2) -> | EWhen (_, e1, e2) ->
begin begin
Format.fprintf fmt "\t\t\t%sWHEN\n%a\t\t\tWHEN\n%a" Format.fprintf fmt "\t\t\t%sWHEN\n%a\t\t\tWHEN\n%a"