From ae2b764821eff7a0e171547fcb8038dd6d9f456f Mon Sep 17 00:00:00 2001 From: Nicolas PENELOUX Date: Sat, 25 Nov 2023 16:44:12 +0100 Subject: [PATCH] =?UTF-8?q?tentative=20de=20compr=C3=A9hension?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- flap/src/hopix/hopixTypechecker.ml | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/flap/src/hopix/hopixTypechecker.ml b/flap/src/hopix/hopixTypechecker.ml index 875cdbb..e12389b 100644 --- a/flap/src/hopix/hopixTypechecker.ml +++ b/flap/src/hopix/hopixTypechecker.ml @@ -67,21 +67,36 @@ let rec synth_expression : HopixTypes.typing_environment -> HopixAST.expression Position.located -> HopixTypes.aty = - fun env Position.{ value = e; position = pos } -> + fun env Position.{ value = e; position = pos } -> function + | Literal l -> type_of_literal l.value + | Variable(id,tlist) -> failwith "Students! This is your job! Variable" + | Tagged(cons,_,[]) -> HopixTypes.hbool (*Pas sûr, j'ai regardé comme dans hopixInterpreter au début*) + | Apply(a,b) -> failwith "Students! This is your job! Apply" + | Record(field,tliste) -> failwith "Students! This is your job! Record" + | Fun(_) -> failwith "Students! This is your job! Fun synth" (* TODO : ici on ne peut pas synthesisé. cf Cours*) + | TypeAnnotation(expr,t) -> failwith "Students! This is your job! TypeAnnotation" + +and type_of_literal l = + match l with + | LInt _ -> HopixTypes.hint + | LChar _ -> HopixTypes.hchar + | LString _ -> HopixTypes.hstring + and check_expression : HopixTypes.typing_environment -> HopixAST.expression Position.located -> HopixTypes.aty -> unit = - fun env (Position.{ value = e; position = pos } as exp) expected -> + fun env (Position.{ value = e; position = pos } as exp) expected -> function + | Fun df -> failwith "Students! This is your job! Fun check" + + and check_value_definition : HopixTypes.typing_environment -> HopixAST.value_definition -> HopixTypes.typing_environment - = -<<<<<<< HEAD -======= - fun env -> function + = +fun env -> function | SimpleValue (id, Some ty, ex) -> failwith "Students! This is your job! (check_value_definition | SimpleValue)" | RecFunctions _ -> @@ -89,7 +104,6 @@ and check_value_definition à faire les fonctions récursives *) failwith "Students! This is your job! (check_value_definition | RecFunctions)" | _ -> failwith "Students! This is your job!" ->>>>>>> acd881c0dd51529a11929a7e8abb27d101b9297f ;; let check_definition env = function