tp2 DONE
This commit is contained in:
parent
dd571ee403
commit
0170403fc6
|
@ -23,15 +23,24 @@ let rec analyse_tds_expression tds e =
|
||||||
begin
|
begin
|
||||||
match chercherGlobalement tds str with
|
match chercherGlobalement tds str with
|
||||||
| None -> raise (IdentifiantNonDeclare str)
|
| None -> raise (IdentifiantNonDeclare str)
|
||||||
| Some (InfoFun(str, typ, l_typ)) ->
|
| Some info ->
|
||||||
let nl_expr = List.map (fun e -> analyse_tds_expression tds e) l_expr in
|
match (info_ast_to_info info) with
|
||||||
AstTds.AppelFonction((InfoFun(str, typ, l_typ)), nl_expr)
|
| 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
|
end
|
||||||
| AstSyntax.Ident(str) ->
|
| AstSyntax.Ident(str) ->
|
||||||
begin
|
begin
|
||||||
match chercherGlobalement tds str with
|
match chercherGlobalement tds str with
|
||||||
| None -> raise (IdentifiantNonDeclare str)
|
| 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
|
end
|
||||||
| AstSyntax.Booleen(b) ->
|
| AstSyntax.Booleen(b) ->
|
||||||
begin
|
begin
|
||||||
|
@ -186,16 +195,21 @@ let analyse_tds_fonction maintds (AstSyntax.Fonction(t, str, l_typstr, bloc)) =
|
||||||
| None ->
|
| None ->
|
||||||
begin
|
begin
|
||||||
let info = Tds.InfoVar(str, Undefined, 0, "") in
|
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 tds_bloc = creerTDSFille maintds in
|
||||||
let unit_l = (List.map (
|
let _ = (List.map (
|
||||||
fun (_, nom) ->
|
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
|
) 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 new_bloc = analyse_tds_bloc tds_bloc bloc in
|
||||||
let nl_typinfo = List.map (
|
let nl_typinfo = List.map (
|
||||||
fun (t, str2) ->
|
fun (t, str2) ->
|
||||||
( t, info_to_info_ast (Tds.InfoVar(str2, Undefined, 0, "")) )
|
( t, info_to_info_ast (Tds.InfoVar(str2, Undefined, 0, "")) )
|
||||||
) l_typstr in
|
) 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)
|
AstTds.Fonction(t, (info_to_info_ast info), nl_typinfo, new_bloc)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue