Initial commit

This commit is contained in:
Dimitri Lajou
2025-03-21 17:26:31 +01:00
commit 7114c0e978
115 changed files with 1760 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
package TP2;
import java.nio.file.Paths;
import java.util.Optional;
import java.io.IOException;
import org.antlr.runtime.ANTLRFileStream;
import org.antlr.runtime.ANTLRInputStream;
import org.antlr.runtime.CharStream;
import org.antlr.runtime.CommonTokenStream;
import org.antlr.runtime.RecognitionException;
import TP2.asd.Program;
public class Main {
public static void main(String[] args) {
try {
// Set input
CharStream input;
if (args.length == 0) {
// From standard input
input = new ANTLRInputStream(System.in);
} else {
// From file name in first argument
input = new ANTLRFileStream(args[0]);
}
// Instantiate Lexer
VSLLexer lexer = new VSLLexer(input);
CommonTokenStream tokens = new CommonTokenStream(lexer);
// Instantiate Parser
VSLParser parser = new VSLParser(tokens);
// Parse
Program ast = parser.program();
// Pretty-print the program (to debug parsing)
System.err.println("todo");
// Verify the program semantic
// Generate the intermediate representation
System.out.println("todo");
} catch (IOException | RecognitionException e) {
e.printStackTrace();
throw new RuntimeException("Unable to proceed");
}
}
}