add PRecord, marche pas mais je l'ai fais quand même

This commit is contained in:
Nicolas PENELOUX 2023-11-13 14:31:17 +01:00
parent 4b32388ae7
commit b1cade7dd4

View file

@ -439,7 +439,6 @@ and expression pos environment memory = function
| TypeAnnotation _ -> VUnit | TypeAnnotation _ -> VUnit
(* On ignore le type car on interprète *) (* On ignore le type car on interprète *)
(* TODO a finir (à commencer plutôt) *)
and case_value expr branches environment memory = and case_value expr branches environment memory =
(* On calcule d'abord l'expression *) (* On calcule d'abord l'expression *)
let expr' = expression' environment memory expr in let expr' = expression' environment memory expr in
@ -604,9 +603,29 @@ and tuple_pattern environment tab tab2 =
and tagged_pattern cons1 cons2 pattern1 pattern2 environment = and tagged_pattern cons1 cons2 pattern1 pattern2 environment =
if cons1.value = cons2 then tuple_pattern environment pattern1 pattern2 else None if cons1.value = cons2 then tuple_pattern environment pattern1 pattern2 else None
and record_pattern environment r r' = and record_pattern environment r r' =
(* TODO *) (*)
None match r with
| [] -> Some environment
| field :: reste ->
let labbel_pattern = record_labbel_pattern environment field r' in
match labbel_pattern with
| Some env' -> record_pattern env' reste r'
| None -> None
and record_labbel_pattern environment field r' =
match r' with
| [] -> None
| (label,pat) :: reste ->
if (value (fst field)) = label then
match pattern environment (value (snd field)) pat with
| Some env' -> Some env'
| None -> record_labbel_pattern environment field reste
else
record_labbel_pattern environment field reste
*)
and literal_pattern pl environment expression = and literal_pattern pl environment expression =
let valeur_literal = pl.value in let valeur_literal = pl.value in