From e27dcdb0a036dc408cf370e6d1678f40a6f408d7 Mon Sep 17 00:00:00 2001 From: Rochas Date: Wed, 30 Apr 2025 13:59:25 +0200 Subject: [PATCH] =?UTF-8?q?g=C3=A9n=C3=A9ration=20du=20fichier=20.ll=20san?= =?UTF-8?q?s=20passer=20par=20la=20sorti=20Print,=20pour=20controller=20le?= =?UTF-8?q?=20type=20d'encodage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/TP2/Main.java | 28 +++++++++++++++++++--------- tests/fragment1/while2 | Bin 109568 -> 109568 bytes 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/main/java/TP2/Main.java b/src/main/java/TP2/Main.java index 75af21c..cf65198 100644 --- a/src/main/java/TP2/Main.java +++ b/src/main/java/TP2/Main.java @@ -5,6 +5,9 @@ import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; + import org.antlr.runtime.ANTLRFileStream; import org.antlr.runtime.ANTLRInputStream; import org.antlr.runtime.CharStream; @@ -58,23 +61,30 @@ public class Main { ProgramImp ast = parser.program(); // Pretty-print the program (to debug parsing) - //System.err.println("todo " + ast); - //System.out.println("\n\n PRETTYPRINTER VSL : \n--------------\n"); - //System.out.println(ast.prettyprinter()); - //System.out.println("\n\n PRETTYPRINTER VSL : \n--------------\n"); + System.out.println(ast.prettyprinter()); + // Verify the program semantic // Generate the intermediate representation - //System.out.println("\n\n"); - //PrintWriter out2 = new PrintWriter(new OutputStreamWriter(System.out, StandardCharsets.UTF_8), true); + System.out.println("\n\n"); + PrintWriter out2 = new PrintWriter(new OutputStreamWriter(System.out, StandardCharsets.UTF_8), true); ProgramLLVMImp astLLVM = ast.toLLVM(); - //System.out.println("\n\n PRETTYPRINTER LLVM : \n--------------\n"); - System.out.println(astLLVM.prettyprinter()); - //System.out.println("\n\n PRETTYPRINTER LLVM : \n--------------\n"); + + String llvmStr = astLLVM.prettyprinter(); + out2.println(llvmStr); + String sortieLLVM = args[0].replace(".vsl", ".ll"); + Files.write( + Paths.get(sortieLLVM), + llvmStr.getBytes(StandardCharsets.UTF_8) + ); + + System.out.println("\n[VSL compile Succes] : " + args[0] + " -> " + sortieLLVM +"\n"); + + } catch (IOException | RecognitionException e) { e.printStackTrace(); throw new RuntimeException("Unable to proceed"); diff --git a/tests/fragment1/while2 b/tests/fragment1/while2 index e2fcb9220f5e81e8e7ecbb4ad5b67127bc2ffac1..c903e04bd60c2025e15e680332c2fa0ffdc0bfdb 100755 GIT binary patch delta 30 kcmZp;!PantZ371*lQMrZ7vpv=MnHq)$