From 18beb717b2aef45c9d48ea43999492dfe507107b Mon Sep 17 00:00:00 2001 From: Rochas Date: Wed, 30 Apr 2025 18:52:33 +0200 Subject: [PATCH] petit readme --- README.md | 3 +++ src/main/java/TP2/Error/TypeChecking.java | 8 ++++---- src/main/java/TP2/Main.java | 24 ++++++++++++++-------- src/main/java/TP2/asd/Program.java | 7 ++++++- tests/fragment0/add0 | Bin 109568 -> 109568 bytes tests/fragment0/add1 | Bin 109568 -> 109568 bytes tests/fragment0/const0 | Bin 109568 -> 109568 bytes tests/fragment0/const1 | Bin 109568 -> 109568 bytes tests/fragment0/div0 | Bin 109568 -> 109568 bytes tests/fragment0/div1 | Bin 109568 -> 109568 bytes tests/fragment0/mod | Bin 109568 -> 109568 bytes tests/fragment0/mult1 | Bin 109568 -> 109568 bytes tests/fragment0/mult2 | Bin 109568 -> 109568 bytes tests/fragment0/paren | Bin 109568 -> 109568 bytes tests/fragment0/priority1 | Bin 109568 -> 109568 bytes tests/fragment0/priority2 | Bin 109568 -> 109568 bytes tests/fragment0/sub0 | Bin 109568 -> 109568 bytes tests/fragment0/sub1 | Bin 109568 -> 109568 bytes tests/fragment1/assign1 | Bin 109568 -> 109568 bytes tests/fragment1/assign2 | Bin 109568 -> 109568 bytes tests/fragment1/block | Bin 109568 -> 109568 bytes tests/fragment1/decl | Bin 109568 -> 109568 bytes tests/fragment1/hello_world | Bin 137216 -> 137216 bytes tests/fragment1/if1 | Bin 109568 -> 109568 bytes tests/fragment1/if2 | Bin 109568 -> 109568 bytes tests/fragment1/print1 | Bin 137216 -> 137216 bytes tests/fragment1/print2 | Bin 137216 -> 137216 bytes tests/fragment1/print3 | Bin 137216 -> 137216 bytes tests/fragment1/print4 | Bin 137728 -> 137728 bytes tests/fragment1/sequence | Bin 137728 -> 137728 bytes tests/fragment1/while1 | Bin 109568 -> 109568 bytes tests/fragment1/while2 | Bin 109568 -> 109568 bytes tests/fragment2/call | Bin 137728 -> 137728 bytes tests/fragment2/call2 | Bin 137728 -> 137728 bytes tests/fragment2/call3expr | Bin 137728 -> 137728 bytes tests/fragment2/call4if | Bin 137728 -> 137728 bytes tests/fragment2/proto1 | Bin 109568 -> 109568 bytes tests/fragment2/proto2 | Bin 137728 -> 137728 bytes tests/testsAdvanced/carre | Bin 137728 -> 137728 bytes tests/testsAdvanced/diverge | Bin 137728 -> 137728 bytes tests/testsAdvanced/divergeDifficile | Bin 137728 -> 137728 bytes 41 files changed, 28 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 5153d64..6b5de33 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,9 @@ Type ::= INT | VOID ## Etat +Nous sommes arrivés jusqu'au segment 2, nous avons commencé le segment 3 mais celui-ci ne marche pas encore complètement +Au niveau de la détection de type, nous l'avons directement intégré à l'intérieur du visitor toLLVM au lieu de le faire dans un bloc séparé, par manque de temps. + ## Compatibilité Pour construire le compilateur : diff --git a/src/main/java/TP2/Error/TypeChecking.java b/src/main/java/TP2/Error/TypeChecking.java index d169e75..a7706a6 100644 --- a/src/main/java/TP2/Error/TypeChecking.java +++ b/src/main/java/TP2/Error/TypeChecking.java @@ -1,3 +1,4 @@ +//TypeChecking implémenté à l'intèrieur de toLLVM... /*package TP2.Error; import TP2.asd.SymTable; @@ -158,10 +159,9 @@ public class TypeChecking { } @Override - public TypeCheckExprDiag visitAppeal(AppealImp instr, SymTable h) { + public TypeCheckExprDiag visitCall(CallImp instr, SymTable h) { // TODO Auto-generated method stub - throw new UnsupportedOperationException("Unimplemented method 'visitAppeal'"); + throw new UnsupportedOperationException("Unimplemented method 'visitCall'"); } } -} -*/ \ No newline at end of file +}*/ diff --git a/src/main/java/TP2/Main.java b/src/main/java/TP2/Main.java index 701f93b..27b8478 100644 --- a/src/main/java/TP2/Main.java +++ b/src/main/java/TP2/Main.java @@ -30,14 +30,15 @@ java -jar build/libs/TP2.jar tests/fragment0/priority2.vsl java -jar build/libs/TP2.jar tests/aLaMain.vsl -(/!\ pas besoin, le main le fait tout seul /!\) java -jar build/libs/TP2.jar tests/fragment1/while2.vsl > tests/fragment1/while2.ll +(pas besoin, pour les test à la main) java -jar build/libs/TP2.jar tests/fragment1/while2.vsl > tests/fragment1/while2.ll clang tests/aLaMain.ll -o tests/aLaMain */ public class Main { - static Boolean TESTAUTOMOD = false; + static Boolean TESTAUTOMOD = true; //pour les tests python mettre à true + static Boolean AFFICHAGE = true; public static void main(String[] args) { try { // Set input @@ -62,19 +63,22 @@ public class Main { // Pretty-print the program (to debug parsing) - if(!TESTAUTOMOD) System.out.println("\nVSL:\n"); + if(!TESTAUTOMOD && AFFICHAGE) System.out.println("\nVSL:\n"); - if(!TESTAUTOMOD) System.out.println(ast.prettyprinter()); + if(!TESTAUTOMOD && AFFICHAGE) System.out.println(ast.prettyprinter()); // Verify the program semantic + //Par manque de temps la vérification sémantique se fait uniquement dans toLLVM // Generate the intermediate representation - if(!TESTAUTOMOD) System.out.println("\nLLVM:\n"); + if(!TESTAUTOMOD && AFFICHAGE) System.out.println("\nLLVM:\n"); ProgramLLVMImp astLLVM = ast.toLLVM(); String llvmStr = astLLVM.prettyprinter(); - System.out.println(llvmStr); + if(TESTAUTOMOD || AFFICHAGE){ + System.out.println(llvmStr); + } /* utiliser la commande : @@ -89,9 +93,11 @@ public class Main { llvmStr.getBytes(StandardCharsets.UTF_8) ); - System.out.println("\n[VSL compile succes] : " + args[0] + " -> " + sortieLLVM); - System.out.println("Pour compiler en bin utilisez :"); - System.out.println("clang " + sortieLLVM + " -o " + sortieLLVM.replace(".ll", "") + "\n"); + if(AFFICHAGE){ + System.out.println("\n[VSL compile succes] : " + args[0] + " -> " + sortieLLVM); + System.out.println("Pour compiler en bin utilisez :"); + System.out.println("clang " + sortieLLVM + " -o " + sortieLLVM.replace(".ll", "") + "\n"); + } } } catch (IOException | RecognitionException e) { diff --git a/src/main/java/TP2/asd/Program.java b/src/main/java/TP2/asd/Program.java index df38e65..4b9516d 100644 --- a/src/main/java/TP2/asd/Program.java +++ b/src/main/java/TP2/asd/Program.java @@ -1,6 +1,7 @@ package TP2.asd; import java.util.ArrayList; + import TP2.asd.Interface.*; import TP2.llvm.ProgramLLVM.*; @@ -17,7 +18,11 @@ public class Program{ return this.accept(ppVisitor, ""); } - @Override + //public TypeCheckExprDiag typeChecking(){ + // TypeChecking tcVisitor = new TypeChecking(); + // return this.accept(tcVisitor, new SymTable()); + //} + public ProgramLLVMImp toLLVM() { toLLVM_Visitor llvmVisitor = new toLLVM_Visitor(); return this.accept(llvmVisitor,new SymTable()); diff --git a/tests/fragment0/add0 b/tests/fragment0/add0 index 1fe91491c382b70918608594cef30c1553a17daa..eb8aeb01c836c616f76fae9bbebefc548e9d7bd8 100755 GIT binary patch delta 30 kcmZp;!PantZ371*)5D-Irl7vpv=MnIrl7vpv=MnIrl7vpv=Mnw*F$&ItOHJS3A#m%L4$st_@!R delta 27 icmZqJz|pXQW5N%nJg>%ITYoWXoddGAtDR@O!GSt6gNg!GSt6gNg6Y delta 27 icmZqJ!qKpWW5N%nBCp0@TYoWXT>!GSt6gNg!GSt6gNg!GSt6gNg!GSt6gNg!GSt6gNg!GSt6gNg!GSt6gNg!GSt6gNg