tp3
This commit is contained in:
parent
fca609035c
commit
1abd8c87d8
|
@ -1,18 +1,18 @@
|
|||
open Passe
|
||||
|
||||
(* Définition d'un compilateur comme l'enchaînement de
|
||||
(* Définition d'un compilateur comme l'enchaînement de
|
||||
quatre passes (gestion des identifiants, typage, placement mémoire
|
||||
génération de code). Chaque passe prend en entrée le type de
|
||||
sortie de la passe précédente.
|
||||
La dernière passe doit renvoyer une chaîne de caractères (le code généré)
|
||||
*)
|
||||
module Compilateur (Ptds:Passe)
|
||||
(Ptype:Passe with type t1 = Ptds.t2)
|
||||
(Pdep:Passe with type t1 = Ptype.t2)
|
||||
(Pcode:Passe with type t1 = Pdep.t2 and type t2 = string) :
|
||||
module Compilateur (Ptds:Passe)
|
||||
(Ptype:Passe with type t1 = Ptds.t2)
|
||||
(Pdep:Passe with type t1 = Ptype.t2)
|
||||
(Pcode:Passe with type t1 = Pdep.t2 and type t2 = string) :
|
||||
Passe with type t1 = Ptds.t1 and type t2 = string =
|
||||
struct
|
||||
|
||||
|
||||
type t1 = Ptds.t1
|
||||
type t2 = string
|
||||
|
||||
|
@ -38,15 +38,14 @@ module CompilateurRat = Compilateur (PasseTdsNop) (PasseNop) (PasseNop) (PasseCo
|
|||
*)
|
||||
|
||||
(* + passe de résolution des identifiants *)
|
||||
open PasseTdsRat
|
||||
module CompilateurRat = Compilateur (PasseTdsRat) (PasseTypeNop) (PasseNop) (PasseCodeNopNop)
|
||||
(* open PasseTdsRat
|
||||
module CompilateurRat = Compilateur (PasseTdsRat) (PasseTypeNop) (PasseNop) (PasseCodeNopNop) *)
|
||||
|
||||
(* + passe de typage *)
|
||||
(*
|
||||
open PasseTdsRat
|
||||
open PasseTypeRat
|
||||
module CompilateurRat = Compilateur (PasseTdsRat) (PasseTypeRat) (PassePlacementNop) (PasseCodeNopNop)
|
||||
*)
|
||||
|
||||
|
||||
(* + passe de placement mémoire *)
|
||||
(*
|
||||
|
|
185
src/passeTypeRat.ml
Normal file
185
src/passeTypeRat.ml
Normal file
|
@ -0,0 +1,185 @@
|
|||
(* Module de la passe de typage *)
|
||||
module PasseTypeRat : Passe.Passe with type t1 = Ast.AstTds.programme and type t2 = Ast.AstType.programme =
|
||||
struct
|
||||
|
||||
open Tds
|
||||
open Exceptions
|
||||
open Ast
|
||||
open AstType
|
||||
|
||||
type t1 = Ast.AstTds.programme
|
||||
type t2 = Ast.AstType.programme
|
||||
|
||||
|
||||
(* analyse_tds_expression : AstTds.expression -> (AstType.expression, type) *)
|
||||
(* Paramètre tds : la table des symboles courante *)
|
||||
(* Paramètre e : l'expression à analyser *)
|
||||
(* Vérifie la bonne utilisation des identifiants et tranforme l'expression
|
||||
en une expression de type AstType.expression *)
|
||||
(* Erreur si mauvaise utilisation des identifiants *)
|
||||
let rec analyse_type_expression e =
|
||||
match e with
|
||||
| AstTds.AppelFonction(info, l_expr) ->
|
||||
begin
|
||||
let n_l_expr, l_type = List.split (List.map analyse_type_expression l_expr) in
|
||||
let InfoFun(_, t, l_type_fun) = info_ast_to_info info in
|
||||
if (est_compatible_list l_type_fun l_type) then
|
||||
(AstType.AppelFonction(info, n_l_expr), t)
|
||||
else
|
||||
raise TypesParametresInattendus(l_type_fun, l_type)
|
||||
end
|
||||
|
||||
| AstTds.Unaire(u, expr) ->
|
||||
begin
|
||||
match (analyse_type_expression expr) with
|
||||
| n_expr, Rat ->
|
||||
match u with
|
||||
| AstSyntax.Numerateur -> (AstType.Unaire(Numerateur, n_expr), Int)
|
||||
| AstSyntax.Denominateur -> (AstType.Unaire(Denominateur, n_expr), Int)
|
||||
| _, t -> raise (TypeInattendu(Rat, t))
|
||||
end
|
||||
|
||||
| AstTds.Binaire(b, expr_1, expr_2) ->
|
||||
begin
|
||||
let (n_expr_1, t1) = analyse_type_expresseion expr_1 in
|
||||
let (n_expr_2, t2) = analyse_type_expresseion expr_2 in
|
||||
match (b, t1, t2) with
|
||||
| Fraction, Int, Int -> (AstType.Binaire(Fraction, n_expr_1, n_expr_2), Rat)
|
||||
| Plus, Int, Int -> (AstType.Binaire(PlusInt, n_expr_1, n_expr_2), Int)
|
||||
| Mult, Int, Int -> (AstType.Binaire(MultInt, n_expr_1, n_expr_2), Int)
|
||||
| Equ, Int ,Int -> (AstType.Binaire(EquInt, n_expr_1, n_expr_2), Int)
|
||||
| Inf, Int, Int -> (AstType.Binaire(Inf, n_expr_1, n_expr_2), Int)
|
||||
| Plus, Rat, Rat -> (AstType.Binaire(PlusRat, n_expr_1, n_expr_2), Rat)
|
||||
| Mult, Rat, Rat -> (AstType.Binaire(MultRat, n_expr_1, n_expr_2), Rat)
|
||||
| Equ, Bool ,Bool -> (AstType.Binaire(EquBool, n_expr_1, n_expr_2), Bool)
|
||||
| _,_,_ -> raise (TypeBinaireInattendu(b, t1, t2))
|
||||
end
|
||||
|
||||
| AstTds.Ident(info) ->
|
||||
begin
|
||||
match (info_ast_to_info info) with
|
||||
| InfoVar(_, t, _, _) -> (AstType.Ident(info), t)
|
||||
| InfoConst(_, _) -> (AstType.Ident(info), Int)
|
||||
end
|
||||
|
||||
| AstTds.Booleen(b) -> (AstType.Booleen(b), Bool)
|
||||
|
||||
| AstTds.Entier(i) -> (AstType.Entier(i), Int)
|
||||
|
||||
(* analyse_tds_instruction : AstTds.instruction -> tds -> AstType.instruction *)
|
||||
(* Paramètre tds : la table des symboles courante *)
|
||||
(* Paramètre i : l'instruction à analyser *)
|
||||
(* Vérifie la bonne utilisation des identifiants et tranforme l'instruction
|
||||
en une instruction de type AstType.instruction *)
|
||||
(* Erreur si mauvaise utilisation des identifiants *)
|
||||
let rec analyse_type_instruction tds i = failwith "TODO"
|
||||
(* match i with
|
||||
| AstTds.Declaration (t, info, e) ->
|
||||
match analyse_type_expr e with
|
||||
| (ne, nt) ->
|
||||
if (est_compatible t nt) then
|
||||
modifier_type_info t info
|
||||
AstType.Declaration(info, e)
|
||||
else
|
||||
Raise TypeInattendu(t, nt)
|
||||
|
||||
| AstTds.Affectation (info, e) ->
|
||||
|
||||
AstType.Affectation (info, e)
|
||||
|
||||
| AstTds.Constante (n,v) ->
|
||||
|
||||
| AstTds.Affichage e ->
|
||||
|
||||
| AstTds.Conditionnelle (c,t,e) ->
|
||||
|
||||
| AstTds.TantQue (c,b) ->
|
||||
|
||||
| AstTds.Retour (e) -> *)
|
||||
|
||||
|
||||
|
||||
(* analyse_tds_bloc : AstTds.bloc -> AstType.bloc *)
|
||||
(* Paramètre tds : la table des symboles courante *)
|
||||
(* Paramètre li : liste d'instructions à analyser *)
|
||||
(* Vérifie la bonne utilisation des identifiants et tranforme le bloc
|
||||
en un bloc de type AstType.bloc *)
|
||||
(* Erreur si mauvaise utilisation des identifiants *)
|
||||
and analyse_tds_bloc tds li =
|
||||
(* Entrée dans un nouveau bloc, donc création d'une nouvelle tds locale
|
||||
pointant sur la table du bloc parent *)
|
||||
let tdsbloc = creerTDSFille tds in
|
||||
(* Analyse des instructions du bloc avec la tds du nouveau bloc
|
||||
Cette tds est modifiée par effet de bord *)
|
||||
let nli = List.map (analyse_tds_instruction tdsbloc) li in
|
||||
(* afficher_locale tdsbloc ; *) (* décommenter pour afficher la table locale *)
|
||||
nli
|
||||
|
||||
|
||||
(* analyse_tds_fonction : AstTds.fonction -> AstType.fonction *)
|
||||
(* Paramètre tds : la table des symboles courante *)
|
||||
(* Paramètre : la fonction à analyser *)
|
||||
(* Vérifie la bonne utilisation des identifiants et tranforme la fonction
|
||||
en une fonction de type AstType.fonction *)
|
||||
(* Erreur si mauvaise utilisation des identifiants *)
|
||||
(*
|
||||
tds ->
|
||||
AstTds.fonction[typ * string * (typ * string) list * bloc] ->
|
||||
AstType.fonction[typ * Tds.info_ast * (typ * Tds.info_ast ) list * bloc]
|
||||
*)
|
||||
let analyse_tds_fonction maintds (AstTds.Fonction(t, str, l_typstr, bloc)) =
|
||||
begin
|
||||
match chercherLocalement maintds str with
|
||||
| Some _ -> raise (DoubleDeclaration str)
|
||||
| None ->
|
||||
begin
|
||||
(* Info de l'identifiant de la fonction *)
|
||||
let info = Tds.InfoVar(str, Undefined, 0, "") in
|
||||
|
||||
(* Copie de la tds globale dans la tds locale au bloc *)
|
||||
let tds_bloc = creerTDSFille maintds in
|
||||
|
||||
(* Ajouter les arguments de la fonction dans la tds locale *)
|
||||
let _ = (List.map (
|
||||
fun (_, nom) ->
|
||||
match chercherLocalement tds_bloc nom with
|
||||
| None -> ajouter tds_bloc nom (info_to_info_ast (Tds.InfoVar(nom, Undefined, 0, "")))
|
||||
(* Si un argument est en double, on lève une exception *)
|
||||
| Some _ -> raise (DoubleDeclaration nom)
|
||||
) l_typstr) in
|
||||
|
||||
(* On ajoute a la tds locale la fonction pour qu'il puisse y avoir des appels récursifs *)
|
||||
let _ = ajouter tds_bloc str (info_to_info_ast (Tds.InfoFun(str, t, (List.map (fun (t, _) -> t) l_typstr)))) in
|
||||
|
||||
(* On génère le nouveau bloc avec la tds locale *)
|
||||
let new_bloc = analyse_tds_bloc tds_bloc bloc in
|
||||
|
||||
(* On transforme les (type * str) en (typ * info) *)
|
||||
let nl_typinfo = List.map (
|
||||
fun (t, str2) ->
|
||||
( t, info_to_info_ast (Tds.InfoVar(str2, Undefined, 0, "")) )
|
||||
) l_typstr in
|
||||
|
||||
(* On crée l'info de la fonction *)
|
||||
let info_fun = InfoFun(str, t, (List.map (fun (t, _) -> t) l_typstr)) in
|
||||
|
||||
(* On ajoute la fonction a la tds globale *)
|
||||
ajouter maintds str (info_to_info_ast info_fun);
|
||||
|
||||
(* On retourne la AstType fonction *)
|
||||
AstType.Fonction(t, (info_to_info_ast info), nl_typinfo, new_bloc)
|
||||
end
|
||||
end
|
||||
|
||||
(* analyser : AstTds.ast -> AstType.ast *)
|
||||
(* Paramètre : le programme à analyser *)
|
||||
(* Vérifie la bonne utilisation des identifiants et tranforme le programme
|
||||
en un programme de type AstType.ast *)
|
||||
(* Erreur si mauvaise utilisation des identifiants *)
|
||||
let analyser (AstTds.Programme (fonctions,prog)) =
|
||||
let tds = creerTDSMere () in
|
||||
let nf = List.map (analyse_tds_fonction tds) fonctions in
|
||||
let nb = analyse_tds_bloc tds prog in
|
||||
Programme (nf,nb)
|
||||
|
||||
end
|
318
src/testType.ml
318
src/testType.ml
|
@ -7,416 +7,416 @@ exception ErreurNonDetectee
|
|||
(* Sans fonction *)
|
||||
(* ------------------------------ *)
|
||||
|
||||
let%test_unit "testDeclaration1"=
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testDeclaration1.rat" in ()
|
||||
(*
|
||||
let%test_unit "testDeclaration1"=
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testDeclaration1.rat" in ()
|
||||
|
||||
let%test_unit "testDeclaration2"=
|
||||
let%test_unit "testDeclaration2"=
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testDeclaration2.rat" in ()
|
||||
|
||||
let%test_unit "testDeclaration3"=
|
||||
let%test_unit "testDeclaration3"=
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testDeclaration3.rat" in ()
|
||||
|
||||
let%test_unit "testDeclaration4"=
|
||||
try
|
||||
let%test_unit "testDeclaration4"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testDeclaration4.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeInattendu(Bool,Int) -> ()
|
||||
|
||||
let%test_unit "testDeclaration5"=
|
||||
try
|
||||
let%test_unit "testDeclaration5"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testDeclaration5.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeInattendu(Bool,Rat) -> ()
|
||||
|
||||
let%test_unit "testDeclaration6"=
|
||||
try
|
||||
let%test_unit "testDeclaration6"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat//src-rat-type-test/testDeclaration6.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeInattendu(Int,Bool) -> ()
|
||||
|
||||
let%test_unit "testDeclaration7"=
|
||||
try
|
||||
let%test_unit "testDeclaration7"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testDeclaration7.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeInattendu(Int,Rat) -> ()
|
||||
|
||||
let%test_unit "testDeclaration8"=
|
||||
try
|
||||
let%test_unit "testDeclaration8"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testDeclaration8.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeInattendu(Rat,Int) -> ()
|
||||
|
||||
let%test_unit "testDeclaration9"=
|
||||
try
|
||||
let%test_unit "testDeclaration9"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testDeclaration9.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeInattendu(Rat,Bool) -> ()
|
||||
|
||||
let%test_unit "testAffectation1"=
|
||||
let%test_unit "testAffectation1"=
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testAffectation1.rat" in ()
|
||||
|
||||
let%test_unit "testAffectation2"=
|
||||
let%test_unit "testAffectation2"=
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testAffectation2.rat" in ()
|
||||
|
||||
let%test_unit "testAffectation3"=
|
||||
let%test_unit "testAffectation3"=
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testAffectation3.rat" in ()
|
||||
|
||||
let%test_unit "testAffectation4"=
|
||||
try
|
||||
let%test_unit "testAffectation4"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testAffectation4.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeInattendu(Int,Rat) -> ()
|
||||
|
||||
let%test_unit "testAffectation5"=
|
||||
try
|
||||
let%test_unit "testAffectation5"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testAffectation5.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeInattendu(Bool,Int) -> ()
|
||||
|
||||
let%test_unit "testAffectation6"=
|
||||
try
|
||||
let%test_unit "testAffectation6"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testAffectation6.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeInattendu(Bool,Rat) -> ()
|
||||
|
||||
let%test_unit "testAffectation7"=
|
||||
try
|
||||
let%test_unit "testAffectation7"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testAffectation7.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeInattendu(Rat,Int) -> ()
|
||||
|
||||
let%test_unit "testAffectation8"=
|
||||
try
|
||||
let%test_unit "testAffectation8"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testAffectation8.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeInattendu(Rat,Bool) -> ()
|
||||
|
||||
let%test_unit "testAffectation9"=
|
||||
try
|
||||
let%test_unit "testAffectation9"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testAffectation9.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeInattendu(Int,Bool) -> ()
|
||||
|
||||
let%test_unit "testConditionnelle1"=
|
||||
let%test_unit "testConditionnelle1"=
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testConditionnelle1.rat" in ()
|
||||
|
||||
let%test_unit "testConditionnelle2"=
|
||||
try
|
||||
let%test_unit "testConditionnelle2"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testConditionnelle2.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeInattendu(Int,Bool) -> ()
|
||||
|
||||
let%test_unit "testConditionnelle3"=
|
||||
try
|
||||
let%test_unit "testConditionnelle3"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testConditionnelle3.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeInattendu(Rat,Bool) -> ()
|
||||
|
||||
let%test_unit "testConditionnelle4"=
|
||||
let%test_unit "testConditionnelle4"=
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testConditionnelle4.rat" in ()
|
||||
|
||||
let%test_unit "testConditionnelle5"=
|
||||
try
|
||||
let%test_unit "testConditionnelle5"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testConditionnelle5.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeInattendu(Int,Bool) -> ()
|
||||
|
||||
let%test_unit "testConditionnelle6"=
|
||||
try
|
||||
let%test_unit "testConditionnelle6"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testConditionnelle6.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeInattendu(Rat,Bool) -> ()
|
||||
|
||||
let%test_unit "testRepetition1"=
|
||||
let%test_unit "testRepetition1"=
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testRepetition1.rat" in ()
|
||||
|
||||
let%test_unit "testRepetition2"=
|
||||
try
|
||||
let%test_unit "testRepetition2"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testRepetition2.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeInattendu(Int,Bool) -> ()
|
||||
|
||||
let%test_unit "testRepetition3"=
|
||||
try
|
||||
let%test_unit "testRepetition3"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testRepetition3.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeInattendu(Rat,Bool) -> ()
|
||||
|
||||
let%test_unit "testRepetition4"=
|
||||
let%test_unit "testRepetition4"=
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testRepetition4.rat" in ()
|
||||
|
||||
let%test_unit "testRepetition5"=
|
||||
try
|
||||
let%test_unit "testRepetition5"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testRepetition5.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeInattendu(Int,Bool) -> ()
|
||||
|
||||
let%test_unit "testRepetition6"=
|
||||
try
|
||||
let%test_unit "testRepetition6"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testRepetition6.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeInattendu(Rat,Bool) -> ()
|
||||
|
||||
let%test_unit "testPrint1"=
|
||||
let%test_unit "testPrint1"=
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testPrint1.rat" in ()
|
||||
|
||||
let%test_unit "testPrint2"=
|
||||
let%test_unit "testPrint2"=
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testPrint2.rat" in ()
|
||||
|
||||
let%test_unit "testPrint3"=
|
||||
let%test_unit "testPrint3"=
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testPrint3.rat" in ()
|
||||
|
||||
let%test_unit "testRationnel1"=
|
||||
let%test_unit "testRationnel1"=
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testRationnel1.rat" in ()
|
||||
|
||||
let%test_unit "testRationnel2"=
|
||||
let%test_unit "testRationnel2"=
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testRationnel2.rat" in ()
|
||||
|
||||
let%test_unit "testRationnel3"=
|
||||
try
|
||||
let%test_unit "testRationnel3"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testRationnel3.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeBinaireInattendu(Fraction,Int,Rat) -> ()
|
||||
|
||||
let%test_unit "testRationnel4"=
|
||||
try
|
||||
let%test_unit "testRationnel4"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testRationnel4.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeBinaireInattendu(Fraction,Bool,Int) -> ()
|
||||
|
||||
let%test_unit "testRationnel5"=
|
||||
try
|
||||
let%test_unit "testRationnel5"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testRationnel5.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeInattendu(Rat,Int) -> ()
|
||||
|
||||
let%test_unit "testNumerateur1"=
|
||||
let%test_unit "testNumerateur1"=
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testNumerateur1.rat" in ()
|
||||
|
||||
let%test_unit "testNumerateur2"=
|
||||
let%test_unit "testNumerateur2"=
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testNumerateur2.rat" in ()
|
||||
|
||||
let%test_unit "testNumerateur3"=
|
||||
try
|
||||
let%test_unit "testNumerateur3"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testNumerateur3.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeInattendu(Bool,Rat) -> ()
|
||||
|
||||
let%test_unit "testNumerateur4"=
|
||||
try
|
||||
let%test_unit "testNumerateur4"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testNumerateur4.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeInattendu(Int,Rat) -> ()
|
||||
|
||||
let%test_unit "testNumerateur5"=
|
||||
try
|
||||
let%test_unit "testNumerateur5"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testNumerateur5.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeInattendu(Int,Bool) -> ()
|
||||
|
||||
let%test_unit "testDenominateur1"=
|
||||
let%test_unit "testDenominateur1"=
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testDenominateur1.rat" in ()
|
||||
|
||||
let%test_unit "testDenominateur2"=
|
||||
let%test_unit "testDenominateur2"=
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testDenominateur2.rat" in ()
|
||||
|
||||
let%test_unit "testDenominateur3"=
|
||||
try
|
||||
let%test_unit "testDenominateur3"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testDenominateur3.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeInattendu(Bool,Rat) -> ()
|
||||
|
||||
let%test_unit "testDenominateur4"=
|
||||
try
|
||||
let%test_unit "testDenominateur4"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testDenominateur4.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeInattendu(Int,Rat) -> ()
|
||||
|
||||
let%test_unit "testDenominateur5"=
|
||||
try
|
||||
let%test_unit "testDenominateur5"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testDenominateur5.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeInattendu(Int,Bool) -> ()
|
||||
|
||||
let%test_unit "testIdent1"=
|
||||
let%test_unit "testIdent1"=
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testIdent1.rat" in ()
|
||||
|
||||
let%test_unit "testIdent2"=
|
||||
let%test_unit "testIdent2"=
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testIdent2.rat" in ()
|
||||
|
||||
let%test_unit "testIdent3"=
|
||||
let%test_unit "testIdent3"=
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testIdent3.rat" in ()
|
||||
|
||||
let%test_unit "testIdent4"=
|
||||
try
|
||||
let%test_unit "testIdent4"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testIdent4.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeInattendu(Rat,Int) -> ()
|
||||
|
||||
let%test_unit "testIdent5"=
|
||||
try
|
||||
let%test_unit "testIdent5"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testIdent5.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeInattendu(Rat,Bool) -> ()
|
||||
|
||||
let%test_unit "testIdent6"=
|
||||
try
|
||||
let%test_unit "testIdent6"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testIdent6.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeInattendu(Int,Bool) -> ()
|
||||
|
||||
let%test_unit "testIdent7"=
|
||||
try
|
||||
let%test_unit "testIdent7"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testIdent7.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeInattendu(Int,Rat) -> ()
|
||||
|
||||
let%test_unit "testIdent8"=
|
||||
try
|
||||
let%test_unit "testIdent8"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testIdent8.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeInattendu(Bool,Rat) -> ()
|
||||
|
||||
let%test_unit "testIdent9"=
|
||||
try
|
||||
let%test_unit "testIdent9"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testIdent9.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeInattendu(Bool,Int) -> ()
|
||||
|
||||
let%test_unit "testOperation1"=
|
||||
let%test_unit "testOperation1"=
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testOperation1.rat" in ()
|
||||
|
||||
let%test_unit "testOperation2"=
|
||||
let%test_unit "testOperation2"=
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testOperation2.rat" in ()
|
||||
|
||||
let%test_unit "testOperation3"=
|
||||
try
|
||||
let%test_unit "testOperation3"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testOperation3.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeBinaireInattendu(Plus, Bool, Bool) -> ()
|
||||
|
||||
let%test_unit "testOperation4"=
|
||||
try
|
||||
let%test_unit "testOperation4"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testOperation4.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeBinaireInattendu(Equ, Rat, Rat) -> ()
|
||||
|
||||
let%test_unit "testOperation5"=
|
||||
let%test_unit "testOperation5"=
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testOperation5.rat" in ()
|
||||
|
||||
let%test_unit "testOperation6"=
|
||||
let%test_unit "testOperation6"=
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testOperation6.rat" in ()
|
||||
|
||||
let%test_unit "testOperation7"=
|
||||
let%test_unit "testOperation7"=
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testOperation7.rat" in ()
|
||||
|
||||
let%test_unit "testOperation8"=
|
||||
let%test_unit "testOperation8"=
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testOperation8.rat" in ()
|
||||
|
||||
let%test_unit "testOperation9"=
|
||||
try
|
||||
let%test_unit "testOperation9"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testOperation9.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeBinaireInattendu(Mult, Bool, Bool) -> ()
|
||||
|
||||
let%test_unit "testOperation10"=
|
||||
try
|
||||
let%test_unit "testOperation10"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testOperation10.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeBinaireInattendu(Inf, Rat, Rat) -> ()
|
||||
|
||||
let%test_unit "testOperation11"=
|
||||
try
|
||||
let%test_unit "testOperation11"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testOperation11.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeBinaireInattendu(Inf, Bool, Bool) -> ()
|
||||
|
||||
let%test_unit "testOperation12"=
|
||||
let%test_unit "testOperation12"=
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testOperation12.rat" in ()
|
||||
|
||||
(* Fichiers de tests de la génération de code -> doivent passer le typage *)
|
||||
|
||||
let%test_unit "code_testprintint" =
|
||||
let%test_unit "code_testprintint" =
|
||||
let _ = compiler "../../fichiersRat/src-rat-tam-test/testprintint.rat" in ()
|
||||
|
||||
let%test_unit "code_testprintbool" =
|
||||
let%test_unit "code_testprintbool" =
|
||||
let _ = compiler "../../fichiersRat/src-rat-tam-test/testprintbool.rat" in ()
|
||||
|
||||
let%test_unit "code_testprintrat" =
|
||||
let%test_unit "code_testprintrat" =
|
||||
let _ = compiler "../../fichiersRat/src-rat-tam-test/testprintrat.rat" in ()
|
||||
|
||||
let%test_unit "code_testaddint" =
|
||||
let%test_unit "code_testaddint" =
|
||||
let _ = compiler "../../fichiersRat/src-rat-tam-test/testaddint.rat" in ()
|
||||
|
||||
let%test_unit "code_testaddrat" =
|
||||
let%test_unit "code_testaddrat" =
|
||||
let _ = compiler "../../fichiersRat/src-rat-tam-test/testaddrat.rat" in ()
|
||||
|
||||
let%test_unit "code_testmultint" =
|
||||
let%test_unit "code_testmultint" =
|
||||
let _ = compiler "../../fichiersRat/src-rat-tam-test/testmultint.rat" in ()
|
||||
|
||||
let%test_unit "code_testmultrat" =
|
||||
let%test_unit "code_testmultrat" =
|
||||
let _ = compiler "../../fichiersRat/src-rat-tam-test/testmultrat.rat" in ()
|
||||
|
||||
let%test_unit "code_testnum" =
|
||||
let%test_unit "code_testnum" =
|
||||
let _ = compiler "../../fichiersRat/src-rat-tam-test/testnum.rat" in ()
|
||||
|
||||
let%test_unit "code_testdenom" =
|
||||
let%test_unit "code_testdenom" =
|
||||
let _ = compiler "../../fichiersRat/src-rat-tam-test/testdenom.rat" in ()
|
||||
|
||||
let%test_unit "code_testwhile1" =
|
||||
let%test_unit "code_testwhile1" =
|
||||
let _ = compiler "../../fichiersRat/src-rat-tam-test/testwhile1.rat" in ()
|
||||
|
||||
let%test_unit "code_testif1" =
|
||||
let%test_unit "code_testif1" =
|
||||
let _ = compiler "../../fichiersRat/src-rat-tam-test/testif1.rat" in ()
|
||||
|
||||
let%test_unit "code_testif2" =
|
||||
let%test_unit "code_testif2" =
|
||||
let _ = compiler "../../fichiersRat/src-rat-tam-test/testif2.rat" in ()
|
||||
|
||||
let%test_unit "code_factiter" =
|
||||
let%test_unit "code_factiter" =
|
||||
let _ = compiler "../../fichiersRat/src-rat-tam-test/factiter.rat" in ()
|
||||
|
||||
let%test_unit "code_complique" =
|
||||
let%test_unit "code_complique" =
|
||||
let _ = compiler "../../fichiersRat/src-rat-tam-test/complique.rat" in ()
|
||||
|
||||
*)
|
||||
|
@ -426,85 +426,85 @@ let _ = compiler "../../fichiersRat/src-rat-tam-test/complique.rat" in ()
|
|||
(* ------------------------------ *)
|
||||
|
||||
(*
|
||||
let%test_unit "test2"=
|
||||
let%test_unit "test2"=
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/test2.rat" in ()
|
||||
|
||||
let%test_unit "testAppel1"=
|
||||
let%test_unit "testAppel1"=
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testAppel1.rat" in ()
|
||||
|
||||
let%test_unit "testAppel2"=
|
||||
let%test_unit "testAppel2"=
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testAppel2.rat" in ()
|
||||
|
||||
let%test_unit "testAppel3"=
|
||||
let%test_unit "testAppel3"=
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testAppel3.rat" in ()
|
||||
|
||||
let%test_unit "testAppel4"=
|
||||
let%test_unit "testAppel4"=
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testAppel4.rat" in ()
|
||||
|
||||
let%test_unit "testAppel5"=
|
||||
let%test_unit "testAppel5"=
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testAppel5.rat" in ()
|
||||
|
||||
let%test_unit "testAppel6"=
|
||||
try
|
||||
let%test_unit "testAppel6"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testAppel6.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypesParametresInattendus _ -> ()
|
||||
|
||||
let%test_unit "testAppel7"=
|
||||
try
|
||||
let%test_unit "testAppel7"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testAppel7.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypesParametresInattendus _ -> ()
|
||||
|
||||
let%test_unit "testAppel8"=
|
||||
try
|
||||
let%test_unit "testAppel8"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testAppel8.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypesParametresInattendus _ -> ()
|
||||
|
||||
let%test_unit "testAppel9"=
|
||||
try
|
||||
let%test_unit "testAppel9"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testAppel9.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypesParametresInattendus _ -> ()
|
||||
|
||||
let%test_unit "testAppel10"=
|
||||
try
|
||||
let%test_unit "testAppel10"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testAppel10.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypesParametresInattendus _ -> ()
|
||||
|
||||
let%test_unit "testAppel11"=
|
||||
try
|
||||
let%test_unit "testAppel11"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testAppel11.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypesParametresInattendus _ -> ()
|
||||
|
||||
let%test_unit "testAppel12"=
|
||||
try
|
||||
let%test_unit "testAppel12"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testAppel12.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeInattendu(Int,Bool) -> ()
|
||||
|
||||
let%test_unit "testAppel13"=
|
||||
try
|
||||
let%test_unit "testAppel13"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testAppel13.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
| TypeInattendu(Int,Rat) -> ()
|
||||
|
||||
let%test_unit "testRetourFonction1"=
|
||||
let%test_unit "testRetourFonction1"=
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testRetourFonction1.rat" in ()
|
||||
|
||||
let%test_unit "testRetourFonction2"=
|
||||
try
|
||||
let%test_unit "testRetourFonction2"=
|
||||
try
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testRetourFonction2.rat"
|
||||
in raise ErreurNonDetectee
|
||||
with
|
||||
|
@ -527,36 +527,36 @@ let%test_unit "testRetourFonction5"=
|
|||
with
|
||||
| RetourDansMain -> ()
|
||||
|
||||
let%test_unit "testRecursiviteFonction"=
|
||||
let%test_unit "testRecursiviteFonction"=
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/testRecursiviteFonction.rat" in ()
|
||||
|
||||
let%test_unit "test"=
|
||||
let%test_unit "test"=
|
||||
let _ = compiler "../../fichiersRat/src-rat-type-test/test.rat" in ()
|
||||
|
||||
let%test_unit "code_factrec" =
|
||||
let%test_unit "code_factrec" =
|
||||
let _ = compiler "../../fichiersRat/src-rat-tam-test/factrec.rat" in ()
|
||||
|
||||
(* Fichiers de tests de la génération de code -> doivent passer le typage *)
|
||||
|
||||
let%test_unit "code_testfun1" =
|
||||
let%test_unit "code_testfun1" =
|
||||
let _ = compiler "../../fichiersRat/src-rat-tam-test/testfun1.rat" in ()
|
||||
|
||||
let%test_unit "code_testfun2" =
|
||||
let%test_unit "code_testfun2" =
|
||||
let _ = compiler "../../fichiersRat/src-rat-tam-test/testfun2.rat" in ()
|
||||
|
||||
let%test_unit "code_testfun3" =
|
||||
let%test_unit "code_testfun3" =
|
||||
let _ = compiler "../../fichiersRat/src-rat-tam-test/testfun3.rat" in ()
|
||||
|
||||
let%test_unit "code_testfun4" =
|
||||
let%test_unit "code_testfun4" =
|
||||
let _ = compiler "../../fichiersRat/src-rat-tam-test/testfun4.rat" in ()
|
||||
|
||||
let%test_unit "code_testfun5" =
|
||||
let%test_unit "code_testfun5" =
|
||||
let _ = compiler "../../fichiersRat/src-rat-tam-test/testfun5.rat" in ()
|
||||
|
||||
let%test_unit "code_testfun6" =
|
||||
let%test_unit "code_testfun6" =
|
||||
let _ = compiler "../../fichiersRat/src-rat-tam-test/testfun6.rat" in ()
|
||||
|
||||
let%test_unit "code_testfuns" =
|
||||
let%test_unit "code_testfuns" =
|
||||
let _ = compiler "../../fichiersRat/src-rat-tam-test/testfuns.rat" in ()
|
||||
|
||||
*)
|
||||
|
|
Loading…
Reference in a new issue