Compare commits
No commits in common. "d0448b01cd995e76d1664a14820e63e07e4933e6" and "d93d11c1e3ad39228ef8791bb99b99734c1860df" have entirely different histories.
d0448b01cd
...
d93d11c1e3
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@ -40,7 +40,7 @@
|
|||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_22" default="true" project-jdk-name="openjdk-21" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="openjdk-21" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
@ -1,5 +0,0 @@
|
|||||||
public class Tester {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
new Test();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +1,5 @@
|
|||||||
package parser;
|
package parser;
|
||||||
|
|
||||||
import bytecode.ByteCodeGenerator;
|
|
||||||
import org.antlr.v4.runtime.CharStream;
|
import org.antlr.v4.runtime.CharStream;
|
||||||
import org.antlr.v4.runtime.CharStreams;
|
import org.antlr.v4.runtime.CharStreams;
|
||||||
import org.antlr.v4.runtime.CommonTokenStream;
|
import org.antlr.v4.runtime.CommonTokenStream;
|
||||||
@ -11,7 +10,7 @@ import parser.generated.SimpleJavaParser;
|
|||||||
public class Main {
|
public class Main {
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
// Assuming args[0] contains the path to the input file
|
// Assuming args[0] contains the path to the input file
|
||||||
CharStream codeCharStream = CharStreams.fromString("class Example { }");
|
CharStream codeCharStream = CharStreams.fromString("class Test { }");
|
||||||
SimpleJavaLexer lexer = new SimpleJavaLexer(codeCharStream);
|
SimpleJavaLexer lexer = new SimpleJavaLexer(codeCharStream);
|
||||||
CommonTokenStream tokens = new CommonTokenStream(lexer);
|
CommonTokenStream tokens = new CommonTokenStream(lexer);
|
||||||
SimpleJavaParser parser = new SimpleJavaParser(tokens);
|
SimpleJavaParser parser = new SimpleJavaParser(tokens);
|
||||||
@ -23,9 +22,9 @@ public class Main {
|
|||||||
|
|
||||||
// Optionally print or process the AST
|
// Optionally print or process the AST
|
||||||
System.out.println("Parsed " + ast.classes.size() + " classes.");
|
System.out.println("Parsed " + ast.classes.size() + " classes.");
|
||||||
System.out.println(ast.classes.getFirst().identifier);
|
System.out.println(ast.classes.get(0).identifier);
|
||||||
|
|
||||||
ByteCodeGenerator byteCodeGenerator = new ByteCodeGenerator();
|
//ByteCodeGenerator byteCodeGenerator = new ByteCodeGenerator();
|
||||||
byteCodeGenerator.generateByteCode(ast);
|
//byteCodeGenerator.generateByteCode(ast);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,7 +2,7 @@
|
|||||||
## Scanner Input
|
## Scanner Input
|
||||||
### Beispiel 1: Empty Class
|
### Beispiel 1: Empty Class
|
||||||
|
|
||||||
String empty class = "public class Name {}";
|
String empty class = "class name {}";
|
||||||
|
|
||||||
### Beispiel 2: Filled Class
|
### Beispiel 2: Filled Class
|
||||||
|
|
||||||
@ -17,7 +17,7 @@
|
|||||||
## Scanner Output
|
## Scanner Output
|
||||||
### Beispiel 1: Empty Class
|
### Beispiel 1: Empty Class
|
||||||
|
|
||||||
[TokPublic,TokClass,TokIdentifier "Name",TokLeftBrace,TokRightBrace]
|
[TokClass,TokIdentifier "name",TokLeftBrace,TokRightBrace]
|
||||||
|
|
||||||
### Beispiel 2: Filled Class
|
### Beispiel 2: Filled Class
|
||||||
|
|
||||||
@ -29,10 +29,9 @@
|
|||||||
[TokRightBrace]
|
[TokRightBrace]
|
||||||
|
|
||||||
# Parser
|
# Parser
|
||||||
## Parser Input
|
## Parser Input (Scanner Output)
|
||||||
(Scanner Output)
|
|
||||||
|
|
||||||
## Parser Output (AST)
|
## Parser Output -> AST
|
||||||
### Beispiel 1: Empty Class
|
### Beispiel 1: Empty Class
|
||||||
|
|
||||||
|
|
||||||
@ -42,8 +41,7 @@
|
|||||||
|
|
||||||
|
|
||||||
# Semantische Analyse / Typcheck
|
# Semantische Analyse / Typcheck
|
||||||
## Typcheck Input
|
## Typcheck Input (Parser Output)
|
||||||
(Parser Output = AST)
|
|
||||||
|
|
||||||
## Typcheck Output
|
## Typcheck Output
|
||||||
|
|
||||||
@ -55,18 +53,5 @@
|
|||||||
|
|
||||||
|
|
||||||
# Bytecodegenerierung
|
# Bytecodegenerierung
|
||||||
## Bytecodegenerierung Input
|
|
||||||
(Typcheck Output = vom Typcheck eventuell manipulierter AST)
|
|
||||||
|
|
||||||
## Bytecodegenerierung Output
|
|
||||||
|
|
||||||
### Beispiel 1: Empty Class
|
|
||||||
Compiled Classfile
|
|
||||||
|
|
||||||
public class Example {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Beispiel 2: Filled Class
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user