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

View File

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