Compare commits

..

1 Commits

Author SHA1 Message Date
d0c24b9ac8 Fix StatementGeneratorTest 2024-03-20 12:58:17 +00:00
8 changed files with 2 additions and 95 deletions

10
.idea/.gitignore generated vendored
View File

@ -1,10 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
../target/

14
.idea/compiler.xml generated
View File

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="Uebungsblatt2" />
<module name="decaf" />
</profile>
</annotationProcessing>
</component>
</project>

7
.idea/encodings.xml generated
View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>

View File

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
</component>
</project>

28
.idea/misc.xml generated
View File

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ANTLRGenerationPreferences">
<option name="perGrammarGenerationSettings">
<list>
<PerGrammarGenerationSettings>
<option name="fileName" value="$PROJECT_DIR$/src/main/antlr4/de/dhbw/horb/Decaf.g4" />
<option name="autoGen" value="true" />
<option name="outputDir" value="C:\eigene Dateien\Duales Studium\Compilerbau\Uebungsblatt2\src\main\java" />
<option name="libDir" value="" />
<option name="encoding" value="" />
<option name="pkg" value="de.dhbw.horb.ast" />
<option name="language" value="" />
<option name="generateVisitor" value="true" />
</PerGrammarGenerationSettings>
</list>
</option>
</component>
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="openjdk-21" project-jdk-type="JavaSDK" />
</project>

6
.idea/vcs.xml generated
View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@ -2,9 +2,6 @@ package de.dhbw.horb;
import de.dhbw.horb.ast.*; import de.dhbw.horb.ast.*;
import java.util.ArrayList;
import java.util.List;
public class ExpressionGenerator extends DecafBaseVisitor<Expression> { public class ExpressionGenerator extends DecafBaseVisitor<Expression> {
@Override @Override
public Expression visitBinaryOperation(DecafParser.BinaryOperationContext ctx) { public Expression visitBinaryOperation(DecafParser.BinaryOperationContext ctx) {
@ -13,12 +10,7 @@ public class ExpressionGenerator extends DecafBaseVisitor<Expression> {
@Override @Override
public Expression visitFunCallExpression(DecafParser.FunCallExpressionContext ctx) { public Expression visitFunCallExpression(DecafParser.FunCallExpressionContext ctx) {
String functionName = ctx.funcCall().id().getText(); throw new RuntimeException("TODO");
List<Expression> exprList = new ArrayList<>();
for (var expr: ctx.funcCall().args().expr()) {
exprList.add(expr.accept(this));
}
return new FunctionCall(functionName, exprList);
} }
@Override @Override

View File

@ -27,6 +27,6 @@ public class StatementGeneratorTest
DecafLexer lexer = new DecafLexer(input); DecafLexer lexer = new DecafLexer(input);
CommonTokenStream tokens = new CommonTokenStream(lexer); CommonTokenStream tokens = new CommonTokenStream(lexer);
DecafParser parser = new DecafParser(tokens); DecafParser parser = new DecafParser(tokens);
return new StatementGenerator().visit(parser.stmt()); return parser.stmt().accept(new StatementGenerator());
} }
} }