feat: création de string_of_affectable
This commit is contained in:
parent
fba95515fe
commit
3b73128050
17
src/ast.ml
17
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 ^ " "
|
||||
|
|
|
@ -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) ->
|
||||
|
|
|
@ -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"^
|
||||
|
|
|
@ -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 =
|
||||
|
|
Loading…
Reference in a new issue