diff --git a/src/ast.ml b/src/ast.ml index b9b8dfd..2c009d7 100644 --- a/src/ast.ml +++ b/src/ast.ml @@ -3,11 +3,11 @@ open Type (* Interface des arbres abstraits *) module type Ast = sig - type expression - type instruction - type affectable - type fonction - type programme + type expression + type instruction + type affectable + type fonction + type programme end @@ -201,3 +201,10 @@ type fonction = Fonction of Tds.info_ast * Tds.info_ast list * bloc type programme = Programme of fonction list * bloc end + + +(* Conversion des affectables *) +let rec string_of_affectable a = + match a with + | AstSyntax.Dref(n) -> (string_of_affectable n) + | AstSyntax.Ident(n) -> n ^ " " diff --git a/src/passeTdsRat.ml b/src/passeTdsRat.ml index b237493..0fcfa04 100644 --- a/src/passeTdsRat.ml +++ b/src/passeTdsRat.ml @@ -103,10 +103,10 @@ let rec analyse_tds_instruction tds i = end | AstSyntax.Affectation (n,e) -> begin - match chercherGlobalement tds n with + match chercherGlobalement tds (string_of_affectable n) with | None -> (* L'identifiant n'est pas trouvé dans la tds globale. *) - raise (IdentifiantNonDeclare n) + raise (IdentifiantNonDeclare (string_of_affectable n)) | Some info -> (* L'identifiant est trouvé dans la tds globale, il a donc déjà été déclaré. L'information associée est récupérée. *) @@ -121,7 +121,7 @@ let rec analyse_tds_instruction tds i = Affectation (info, ne) | _ -> (* Modification d'une constante ou d'une fonction *) - raise (MauvaiseUtilisationIdentifiant n) + raise (MauvaiseUtilisationIdentifiant (string_of_affectable n)) end end | AstSyntax.Constante (n,v) -> diff --git a/src/printerAst.ml b/src/printerAst.ml index 8e22071..04f4f57 100644 --- a/src/printerAst.ml +++ b/src/printerAst.ml @@ -69,7 +69,7 @@ struct let rec string_of_instruction i = match i with | Declaration (t, n, e) -> "Declaration : "^(string_of_type t)^" "^n^" = "^(string_of_expression e)^"\n" - | Affectation (n,e) -> "Affectation : "^n^" = "^(string_of_expression e)^"\n" + | Affectation (n,e) -> "Affectation : "^ (string_of_affectable n)^" = "^(string_of_expression e)^"\n" | Constante (n,i) -> "Constante : "^n^" = "^(string_of_int i)^"\n" | Affichage e -> "Affichage : "^(string_of_expression e)^"\n" | Conditionnelle (c,t,e) -> "Conditionnelle : IF "^(string_of_expression c)^"\n"^ diff --git a/src/tds.ml b/src/tds.ml index da68fdc..b967a55 100644 --- a/src/tds.ml +++ b/src/tds.ml @@ -293,7 +293,7 @@ let string_of_info info = let afficher_locale tds = match tds with | Nulle -> print_newline () - |Courante (_,c) -> Hashtbl.iter ( fun n info -> (print_string (n^" : "^(string_of_info (info_ast_to_info info))^"\n"))) c + | Courante (_,c) -> Hashtbl.iter ( fun n info -> (print_string (n^" : "^(string_of_info (info_ast_to_info info))^"\n"))) c (* Affiche la tds locale et récursivement *) let afficher_globale tds =