mirror of
https://github.com/JonathanFleischmann/CompilerULTIMATE.git
synced 2024-12-28 16:48:03 +00:00
minor change in ExpressionGenerator
This commit is contained in:
parent
f74ba50caa
commit
8318defd30
@ -53,10 +53,12 @@ public class ExpressionGenerator extends DecafBaseVisitor<Expression> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Expression generateConstant(DecafParser.LiteralContext ctx) {
|
public static Expression generateConstant(DecafParser.LiteralContext ctx) {
|
||||||
if (ctx.NUMBER() != null)
|
if (ctx.NUMBER() != null) {
|
||||||
return new IntLiteral(Integer.valueOf(ctx.NUMBER().getText()));
|
return new IntLiteral(Integer.valueOf(ctx.NUMBER().getText()));
|
||||||
if (ctx.BOOLEANLITERAL() != null)
|
}
|
||||||
|
if (ctx.BOOLEANLITERAL() != null) {
|
||||||
return new BoolLiteral(Boolean.valueOf(ctx.BOOLEANLITERAL().getText()));
|
return new BoolLiteral(Boolean.valueOf(ctx.BOOLEANLITERAL().getText()));
|
||||||
|
}
|
||||||
if (ctx.CHARLITERAL() != null) {
|
if (ctx.CHARLITERAL() != null) {
|
||||||
if (ctx.CHARLITERAL().getText().length() != 3) {
|
if (ctx.CHARLITERAL().getText().length() != 3) {
|
||||||
throw new RuntimeException("Wrong format for Char literal. Good format: 'c' Bad format: " + ctx.CHARLITERAL().getText());
|
throw new RuntimeException("Wrong format for Char literal. Good format: 'c' Bad format: " + ctx.CHARLITERAL().getText());
|
||||||
|
Loading…
Reference in New Issue
Block a user