This commit is contained in:
Lucas 2024-05-31 09:58:07 +02:00
parent dd424cda99
commit 5a28d88f6a
3 changed files with 7 additions and 12 deletions

View File

@ -29,7 +29,7 @@ public class Main {
static void parsefile(CharStream codeCharStream) {
/* ------------------------- Scanner -> tokens ------------------------- */
/*------------------------- Scanner -> tokens -------------------------*/
SimpleJavaLexer lexer = new SimpleJavaLexer(codeCharStream);
CommonTokenStream tokenStream = new CommonTokenStream(lexer);
@ -46,7 +46,7 @@ public class Main {
}
System.out.println();
/* ------------------------- Parser -> Parsetree ------------------------- */
/*------------------------- Parser -> Parsetree -------------------------*/
SimpleJavaParser parser = new SimpleJavaParser(tokenStream);
ParseTree parseTree = parser.program(); // parse the input
@ -56,7 +56,7 @@ public class Main {
printTree(parseTree, parser, 0);
System.out.println();
/* ------------------------- AST builder -> AST ------------------------- */
/*------------------------- AST builder -> AST -------------------------*/
ASTBuilder astBuilder = new ASTBuilder();
ProgramNode abstractSyntaxTree = (ProgramNode) astBuilder.visit(parseTree);
@ -66,19 +66,14 @@ public class Main {
printAST(abstractSyntaxTree, 0);
System.out.println();
/*
* ------------------------- Semantic Analyzer -> Tast -------------------------
*/
/*------------------------- Semantic Analyzer -> Tast -------------------------*/
SemanticAnalyzer.generateTast(abstractSyntaxTree);
ProgramNode typedAst = (ProgramNode) SemanticAnalyzer.generateTast(abstractSyntaxTree);
// Printing the Tast
System.out.println("Tast generated");
/*
* ------------------------- Bytecode Generator -> Bytecode
* -------------------------
*/
/*------------------------- Bytecode Generator -> Bytecode -------------------------*/
ByteCodeGenerator byteCodeGenerator = new ByteCodeGenerator();
//byteCodeGenerator.generateByteCode(abstractSyntaxTree);
byteCodeGenerator.visit(typedAst);

View File

@ -5,7 +5,7 @@ public class Tester {
}
}
// java -jar pfadtocompiler.jar EmptyClass.java
//mit bash scipt ode rmakefile test automatisieren
//mvn package
// mit bash scipt ode rmakefile test automatisieren
// mvn package
// javac tester // tester compilen
// java tester // tester ausführen