Compare commits

...

2 Commits

Author SHA1 Message Date
i22011
56c32fe9d3 Merge remote-tracking branch 'origin/main' 2024-05-02 16:10:47 +02:00
i22011
fe689b7253 Tests 2024-05-02 16:09:24 +02:00
4 changed files with 88 additions and 1 deletions

2
.idea/misc.xml generated
View File

@ -40,7 +40,7 @@
</list> </list>
</option> </option>
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="openjdk-21" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_19" default="true" project-jdk-name="19" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" /> <output url="file://$PROJECT_DIR$/out" />
</component> </component>
</project> </project>

21
pom.xml
View File

@ -14,4 +14,25 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
<dependencies>
<!-- JUnit dependency -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.9.3</version> <!-- Change the version as needed -->
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Add the Maven Surefire plugin to run tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version> <!-- Change the version as needed -->
</plugin>
</plugins>
</build>
</project> </project>

View File

@ -0,0 +1,18 @@
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class MainTest {
@Test
void testAdd() {
//Calculator calculator = new Calculator();
//int result = calculator.add(2, 3);
//assertEquals(5, result, "2 + 3 should equal 5");
}
}
/**
* run: mvn test
*/

View File

@ -0,0 +1,48 @@
# Scanner
## Scanner Input
### Beispiel 1: Empty Class
String empty class = "class name {}";
### Beispiel 2: Filled Class
String filled class =
"class Example {" +
"if (x < 5) {" +
"for (int i = 0; i < 10; i++) {" +
"while (true) {" +
"x = 5;" +
"}"
## Scanner Output
### Beispiel 1: Empty Class
[TokClass,TokIdentifier "name",TokLeftBrace,TokRightBrace]
### Beispiel 2: Filled Class
[TokClass,TokIdentifier "Example",TokLeftBrace]
[TokIf,TokLeftParen,TokIdentifier "x",TokLessThan,TokNumber 5,TokRightParen,TokLeftBrace]
[TokFor,TokLeftParen,TokIdentifier "int",TokIdentifier "i",TokAssign,TokNumber 0,TokSemicolon,TokIdentifier "i",TokLessThan,TokNumber 10,TokSemicolon,TokIdentifier "i",TokPlus,TokPlus,TokRightParen,TokLeftBrace]
[TokWhile,TokLeftParen,TokIdentifier "true",TokRightParen,TokLeftBrace]
[TokIdentifier "x",TokAssign,TokNumber 5,TokSemicolon]
[TokRightBrace]
# Parser
## Parser Input
(Scanner Output)
## Parser Output -> AST
### Beispiel 1: Empty Class
### Beispiel 2: Filled Class
# Semantische Analyse / Typcheck
# Bytecodegenerierung