mirror of
https://github.com/JonathanFleischmann/CompilerULTIMATE.git
synced 2024-12-28 09:28:04 +00:00
added unary operations to ast
This commit is contained in:
parent
24c3a26136
commit
8cc109275a
@ -46,9 +46,9 @@ public class ExpressionGenerator extends DecafBaseVisitor<Expression> {
|
||||
|
||||
public static Expression generateConstant(DecafParser.LiteralContext ctx){
|
||||
if(ctx.NUMBER() != null)
|
||||
return new IntConstant(Integer.valueOf(ctx.NUMBER().getText()));
|
||||
return new IntLiteral(Integer.valueOf(ctx.NUMBER().getText()));
|
||||
if(ctx.boolean_() != null)
|
||||
return new BoolConstant(Boolean.valueOf(ctx.boolean_().getText()));
|
||||
return new BoolLiteral(Boolean.valueOf(ctx.boolean_().getText()));
|
||||
throw new RuntimeException();
|
||||
}
|
||||
|
||||
|
6
src/main/java/de/maishai/ast/UnaryOperator.java
Normal file
6
src/main/java/de/maishai/ast/UnaryOperator.java
Normal file
@ -0,0 +1,6 @@
|
||||
package de.maishai.ast;
|
||||
|
||||
public enum UnaryOperator {
|
||||
SUB,
|
||||
NOT
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
package de.maishai.ast.records;
|
||||
|
||||
|
||||
public record BoolConstant(Boolean value) implements Expression {
|
||||
}
|
5
src/main/java/de/maishai/ast/records/BoolLiteral.java
Normal file
5
src/main/java/de/maishai/ast/records/BoolLiteral.java
Normal file
@ -0,0 +1,5 @@
|
||||
package de.maishai.ast.records;
|
||||
|
||||
|
||||
public record BoolLiteral(Boolean value) implements Expression {
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
package de.maishai.ast.records;
|
||||
|
||||
|
||||
public record CharConstant(char value) implements Expression {
|
||||
}
|
5
src/main/java/de/maishai/ast/records/CharLiteral.java
Normal file
5
src/main/java/de/maishai/ast/records/CharLiteral.java
Normal file
@ -0,0 +1,5 @@
|
||||
package de.maishai.ast.records;
|
||||
|
||||
|
||||
public record CharLiteral(char value) implements Expression {
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
package de.maishai.ast.records;
|
||||
|
||||
|
||||
public sealed interface Expression extends Node permits Assignment, Binary, BoolConstant, CharConstant, Id, IntConstant, MethodCall, New {
|
||||
public sealed interface Expression extends Node permits Assignment, Binary, BoolLiteral, CharLiteral, Id, IntLiteral, MethodCall, New, Unary {
|
||||
}
|
||||
|
@ -1,5 +0,0 @@
|
||||
package de.maishai.ast.records;
|
||||
|
||||
|
||||
public record IntConstant(Integer value) implements Expression {
|
||||
}
|
5
src/main/java/de/maishai/ast/records/IntLiteral.java
Normal file
5
src/main/java/de/maishai/ast/records/IntLiteral.java
Normal file
@ -0,0 +1,5 @@
|
||||
package de.maishai.ast.records;
|
||||
|
||||
|
||||
public record IntLiteral(Integer value) implements Expression {
|
||||
}
|
@ -12,5 +12,5 @@ import de.maishai.ast.records.Return;
|
||||
import de.maishai.ast.records.ReturnVoid;
|
||||
import de.maishai.ast.records.While;
|
||||
|
||||
public sealed interface Statement extends Node permits Break, Continue, DoWhile, For, IfElse, MethodCall, New, Return, ReturnVoid, While {
|
||||
public sealed interface Statement extends Node permits Assignment, Break, Continue, DoWhile, For, IfElse, MethodCall, New, Return, ReturnVoid, While {
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user