From ecbaa5d4deaeb5b4995040d4c8886f92e24a3c89 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Mon, 30 Jan 2023 19:05:31 +0200 Subject: [PATCH] Expressions - Added a second parameter to the constructor for `IntegerLiteral`, this takes in the encoding of type `IntegerLiteralEncoding` Parser - Updated the `SymbolType.NUMBER_LITERAL` handling code to handle the new constructor for `IntegerLiteral` --- source/tlang/compiler/parsing/core.d | 6 +++++- source/tlang/compiler/symbols/expressions.d | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/source/tlang/compiler/parsing/core.d b/source/tlang/compiler/parsing/core.d index bf69485a..efadd047 100644 --- a/source/tlang/compiler/parsing/core.d +++ b/source/tlang/compiler/parsing/core.d @@ -1133,12 +1133,16 @@ public final class Parser // If floating point literal if(isFloatLiteral(numberLiteralStr)) { + // TODO: Issue #94, siiliar to below for integers numberLiteral = new FloatingLiteral(getCurrentToken().getToken()); } // Else, then an integer literal else { - numberLiteral = new IntegerLiteral(getCurrentToken().getToken()); + // TODO: Issue #94, we should be checking the range here + // ... along with any explicit encoders and setting it + // ... for now default to SIGNED_INTEGER. + numberLiteral = new IntegerLiteral(getCurrentToken().getToken(), IntegerLiteralEncoding.SIGNED_INTEGER); } /* Add expression to stack */ diff --git a/source/tlang/compiler/symbols/expressions.d b/source/tlang/compiler/symbols/expressions.d index 4717adee..19883ef1 100644 --- a/source/tlang/compiler/symbols/expressions.d +++ b/source/tlang/compiler/symbols/expressions.d @@ -97,9 +97,10 @@ public final class IntegerLiteral : NumberLiteral { private IntegerLiteralEncoding encoding; - this(string integerLiteral) + this(string integerLiteral, IntegerLiteralEncoding encoding) { super(integerLiteral); + this.encoding = encoding; } public IntegerLiteralEncoding getEncoding()