Expressions

- Added enum type `NumberLiteralEncoding` mimicking that of D's integer literals encoding variations
- Added an instance of `NumberLiteralEncoding` to `NumberLiteral` along with a `getEncoding()` method to fetch said field

Parser

- Added TODO
This commit is contained in:
Tristan B. Velloza Kildaire 2023-01-29 13:36:48 +02:00
parent 9d33b05817
commit d26435b529
2 changed files with 16 additions and 1 deletions

View File

@ -1114,6 +1114,7 @@ public final class Parser
if (symbol == SymbolType.NUMBER_LITERAL) if (symbol == SymbolType.NUMBER_LITERAL)
{ {
/* TODO: Do number checking here to get correct NUmberLiteral */ /* TODO: Do number checking here to get correct NUmberLiteral */
// TODO: Insert code here for handling various different encodings
NumberLiteral numberLiteral = new NumberLiteral(getCurrentToken().getToken()); NumberLiteral numberLiteral = new NumberLiteral(getCurrentToken().getToken());
/* Add expression to stack */ /* Add expression to stack */

View File

@ -85,9 +85,18 @@ public class BinaryOperatorExpression : OperatorExpression
} }
} }
public enum NumberLiteralEncoding
{
SIGNED_INTEGER,
UNSIGNED_INTEGER,
SIGNED_LONG,
UNSIGNED_LONG
}
public class NumberLiteral : Expression public class NumberLiteral : Expression
{ {
private string numberLiteral; private string numberLiteral;
private NumberLiteralEncoding encoding;
/* TODO: Take in info like tyoe */ /* TODO: Take in info like tyoe */
this(string numberLiteral) this(string numberLiteral)
@ -100,9 +109,14 @@ public class NumberLiteral : Expression
return numberLiteral; return numberLiteral;
} }
public NumberLiteralEncoding getEncoding()
{
return encoding;
}
public override string toString() public override string toString()
{ {
return "[numberLiteral: "~numberLiteral~"]"; return "[numberLiteral: "~numberLiteral~" ("~to!(string)(encoding)~")]";
} }
} }