This commit is contained in:
Guillotin Damien 2021-11-24 19:22:01 +01:00
parent dd571ee403
commit 0170403fc6

View file

@ -23,15 +23,24 @@ let rec analyse_tds_expression tds e =
begin
match chercherGlobalement tds str with
| None -> raise (IdentifiantNonDeclare str)
| Some (InfoFun(str, typ, l_typ)) ->
let nl_expr = List.map (fun e -> analyse_tds_expression tds e) l_expr in
AstTds.AppelFonction((InfoFun(str, typ, l_typ)), nl_expr)
| Some info ->
match (info_ast_to_info info) with
| InfoFun(_, _, _) ->
let nl_expr = List.map (fun e -> analyse_tds_expression tds e) l_expr in
AstTds.AppelFonction(info, nl_expr)
| _ -> raise (MauvaiseUtilisationIdentifiant str)
end
| AstSyntax.Ident(str) ->
begin
match chercherGlobalement tds str with
| None -> raise (IdentifiantNonDeclare str)
| Some info -> AstTds.Ident(info)
| Some info ->
match (info_ast_to_info info) with
| InfoVar(_, _, _, _) ->
AstTds.Ident(info)
| InfoConst(_, v) ->
AstTds.Entier(v)
| _ -> raise (MauvaiseUtilisationIdentifiant str)
end
| AstSyntax.Booleen(b) ->
begin
@ -186,16 +195,21 @@ let analyse_tds_fonction maintds (AstSyntax.Fonction(t, str, l_typstr, bloc)) =
| None ->
begin
let info = Tds.InfoVar(str, Undefined, 0, "") in
let tds_bloc = maintds in (* tds_bloc doit inclure les nouveaux éléments passés en paramètre *)
let unit_l = (List.map (
let tds_bloc = creerTDSFille maintds in
let _ = (List.map (
fun (_, nom) ->
ajouter tds_bloc nom (info_to_info_ast (Tds.InfoVar(nom, Undefined, 0, "")))
match chercherLocalement tds_bloc nom with
| None -> ajouter tds_bloc nom (info_to_info_ast (Tds.InfoVar(nom, Undefined, 0, "")))
| Some _ -> raise (DoubleDeclaration nom)
) l_typstr) in
let _ = ajouter tds_bloc str (info_to_info_ast (Tds.InfoFun(str, t, (List.map (fun (t, _) -> t) l_typstr)))) in
let new_bloc = analyse_tds_bloc tds_bloc bloc in
let nl_typinfo = List.map (
fun (t, str2) ->
( t, info_to_info_ast (Tds.InfoVar(str2, Undefined, 0, "")) )
) l_typstr in
let info_fun = InfoFun(str, t, (List.map (fun (t, _) -> t) l_typstr)) in
ajouter maintds str (info_to_info_ast info_fun);
AstTds.Fonction(t, (info_to_info_ast info), nl_typinfo, new_bloc)
end
end