Initial commit
This commit is contained in:
51
src/main/java/TP2/Main.java
Normal file
51
src/main/java/TP2/Main.java
Normal 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");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user