Skip to content

Commit

Permalink
fixed utils concerning string interpretation
Browse files Browse the repository at this point in the history
  • Loading branch information
janzenisek committed Dec 12, 2024
1 parent 7a88e21 commit ba05298
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Processor/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ public static IEnumerable<string> GetKeywordDisplayNames() {
};

private static string GetAtomicTypeValueText(int typeCode, SeidlParser.ExpressionContext? exp) => typeCode switch {
SeidlLexer.STRING => exp.GetText(),
SeidlLexer.STRING => exp.@string().STRINGLITERAL().GetText(), // CHECK
SeidlLexer.INT => exp.number().INTEGER().GetText(),
SeidlLexer.FLOAT => exp.number().FLOATINGPOINTNUMBER().GetText(),
SeidlLexer.BOOL => exp.boolean().GetText(),
_ => throw new ArgumentException("The given type is unknown.")
};

private static IAtomicType InstanceAtomicType(int typeCode, SeidlParser.ExpressionContext? exp) => typeCode switch {
SeidlLexer.STRING => new Data.String(exp.GetText()),
SeidlLexer.STRING => new Data.String(exp.@string().STRINGLITERAL().GetText()), // CHECK
SeidlLexer.INT => new Data.Integer(exp.number().INTEGER().GetText()),
SeidlLexer.FLOAT => new Data.Float(exp.number().FLOATINGPOINTNUMBER().GetText()),
SeidlLexer.BOOL => new Data.Bool(exp.boolean().GetText()),
Expand All @@ -110,7 +110,7 @@ public static IEnumerable<string> GetKeywordDisplayNames() {
private static int GetExpressionTypeCode(SeidlParser.ExpressionContext? exp) {
int typeCode = int.MaxValue;

if (exp.GetText() != null) typeCode = SeidlLexer.STRING;
if (exp.GetText() != null) typeCode = SeidlLexer.STRING; // CHECK
if (exp.number() != null && exp.number().INTEGER() != null) typeCode = SeidlLexer.INT;
if (exp.number() != null && exp.number().FLOATINGPOINTNUMBER() != null) typeCode = SeidlLexer.FLOAT;
if (exp.boolean() != null) typeCode = SeidlLexer.BOOL;
Expand Down Expand Up @@ -154,7 +154,7 @@ public static IType CreateType(int? typecode, string? typename, ScopedSymbolTabl

public static void TryAssignExpression(IType target, SeidlParser.ExpressionContext? exp) {
try {
if (target is Data.String) (target as IAtomicType).Assign(exp.@string().STRINGLITERAL().GetText());
if (target is Data.String) (target as IAtomicType).Assign(exp.@string().STRINGLITERAL().GetText()); // CHECK
else if (target is Data.Integer) (target as IAtomicType).Assign(exp.number().INTEGER().GetText());
else if (target is Data.Float) (target as IAtomicType).Assign(exp.number().FLOATINGPOINTNUMBER().GetText());
else if (target is Data.Bool) (target as IAtomicType).Assign(exp.boolean().GetText());
Expand Down

0 comments on commit ba05298

Please sign in to comment.