diff --git a/src/ast.ml b/src/ast.ml index 2179b24..78f1133 100644 --- a/src/ast.ml +++ b/src/ast.ml @@ -47,6 +47,7 @@ type t_expression = | ETriOp of full_ty * triop * t_expression * t_expression * t_expression | EComp of full_ty * compop * 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 | ETuple of full_ty * (t_expression list) | EApp of full_ty * t_node * t_expression diff --git a/src/lexer.mll b/src/lexer.mll index 5acc6ea..2a4423a 100644 --- a/src/lexer.mll +++ b/src/lexer.mll @@ -29,6 +29,7 @@ ("else", ELSE); ("merge", TO_merge); ("when", WHEN); + ("fby", FBY); ("pre", MO_pre); ("true", CONST_BOOL(true)); ("false", CONST_BOOL(false)); diff --git a/src/parser.mly b/src/parser.mly index fd62e82..33a2420 100644 --- a/src/parser.mly +++ b/src/parser.mly @@ -35,6 +35,7 @@ | ETriOp (full_ty , _ , _ , _ , _) -> full_ty | EComp (full_ty , _ , _ , _) -> full_ty | EWhen (full_ty , _ , _) -> full_ty + | EFby (full_ty , _ , _) -> full_ty | EConst (full_ty , _) -> full_ty | ETuple (full_ty , _) -> full_ty | EApp (full_ty , _ , _) -> full_ty @@ -95,6 +96,7 @@ %token TO_merge %token WHEN +%token FBY %token IF %token THEN @@ -234,6 +236,7 @@ expr: | 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) */ | expr WHEN expr { EWhen (type_exp $1, $1, $3) } + | expr FBY expr { EFby (type_exp $1, $1, $3) } /* Constants */ | CONST_INT { EConst (FTBase TInt, CInt $1) } | CONST_BOOL { EConst (FTBase TBool, CBool $1) } diff --git a/src/pp.ml b/src/pp.ml index fa537f1..035c84e 100644 --- a/src/pp.ml +++ b/src/pp.ml @@ -33,6 +33,13 @@ let pp_expression = | _ -> raise (MyTypeError "This exception should not have been raised.") in 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) -> begin Format.fprintf fmt "\t\t\t%sWHEN\n%a\t\t\tWHEN\n%a"