idk if that was the right thing to do

This commit is contained in:
laurenz 2024-03-13 19:10:06 +01:00
parent 2b90f84c1e
commit 998174b5fa
10 changed files with 115 additions and 10 deletions

8
.idea/.gitignore generated vendored Normal file
View File

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

13
.idea/compiler.xml generated Normal file
View File

@ -0,0 +1,13 @@
<?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="decaf" />
</profile>
</annotationProcessing>
</component>
</project>

7
.idea/encodings.xml generated Normal file
View File

@ -0,0 +1,7 @@
<?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

@ -0,0 +1,23 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PyPep8Inspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredErrors">
<list>
<option value="E501" />
<option value="E302" />
<option value="E303" />
</list>
</option>
</inspection_tool>
<inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredErrors">
<list>
<option value="N806" />
<option value="N803" />
<option value="N802" />
</list>
</option>
</inspection_tool>
</profile>
</component>

20
.idea/jarRepositories.xml generated Normal file
View File

@ -0,0 +1,20 @@
<?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>

12
.idea/misc.xml generated Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<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" languageLevel="JDK_20" default="true" project-jdk-name="20" project-jdk-type="JavaSDK" />
</project>

8
.idea/modules.xml generated Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/decaf.iml" filepath="$PROJECT_DIR$/decaf.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml generated Normal file
View File

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

8
decaf.iml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="AdditionalModuleElements">
<content url="file://$MODULE_DIR$" dumb="true">
<sourceFolder url="file://$MODULE_DIR$/target/generated-sources" isTestSource="false" />
</content>
</component>
</module>

View File

@ -2,54 +2,54 @@ package de.dhbw.horb;
import de.dhbw.horb.ast.*;
public class ExpressionGenerator extends DecafBaseVisitor<Expression> {
public class ExpressionGenerator extends de.dhbw.horb.DecafBaseVisitor<Expression> {
@Override
public Expression visitBinaryOperation(DecafParser.BinaryOperationContext ctx) {
public Expression visitBinaryOperation(de.dhbw.horb.DecafParser.BinaryOperationContext ctx) {
return generateBinary(ctx);
}
@Override
public Expression visitFunCallExpression(DecafParser.FunCallExpressionContext ctx) {
public Expression visitFunCallExpression(de.dhbw.horb.DecafParser.FunCallExpressionContext ctx) {
throw new RuntimeException("TODO");
}
@Override
public Expression visitConstant(DecafParser.ConstantContext ctx) {
public Expression visitConstant(de.dhbw.horb.DecafParser.ConstantContext ctx) {
return generateConstant(ctx.literal());
}
@Override
public Expression visitExpression(DecafParser.ExpressionContext ctx) {
public Expression visitExpression(de.dhbw.horb.DecafParser.ExpressionContext ctx) {
//ParseTree for ( expr )
//Just pass it down to the inner expr:
return this.visit(ctx.expr());
}
@Override
public Expression visitLocation(DecafParser.LocationContext ctx) {
public Expression visitLocation(de.dhbw.horb.DecafParser.LocationContext ctx) {
return generateLocation(ctx.loc());
}
public static Expression generateConstant(DecafParser.LiteralContext ctx){
public static Expression generateConstant(de.dhbw.horb.DecafParser.LiteralContext ctx){
if(ctx.number() != null)
return new IntConstant(Integer.valueOf(ctx.number().getText()));
if(ctx.boolean_() != null)
return new BoolConstant(Boolean.valueOf(ctx.boolean_().getText()));
throw new RuntimeException();
}
public static Operator generateOperator(DecafParser.BinaryOpContext ctx){
public static Operator generateOperator(de.dhbw.horb.DecafParser.BinaryOpContext ctx){
if(ctx.ADD() != null)return Operator.ADD;
if(ctx.SUB() != null)return Operator.SUB;
if(ctx.MUL() != null)return Operator.MUL;
throw new RuntimeException();
}
public static Binary generateBinary(DecafParser.BinaryOperationContext ctx){
public static Binary generateBinary(de.dhbw.horb.DecafParser.BinaryOperationContext ctx){
ExpressionGenerator eGen = new ExpressionGenerator();
return new Binary(eGen.visit(ctx.expr().get(0)) // left side
, generateOperator(ctx.binaryOp()) //operator
, eGen.visit(ctx.expr().get(1))); //right side
}
public static Location generateLocation(DecafParser.LocContext loc) {
public static Location generateLocation(de.dhbw.horb.DecafParser.LocContext loc) {
return new Location(loc.id().getText());
}
}