diff --git a/Changelog.txt b/Changelog.txt
index fc4f3f2..040512a 100644
--- a/Changelog.txt
+++ b/Changelog.txt
@@ -3,6 +3,10 @@ CHANGELOG - What's new?
See the GitHub releases for more detailed info:
https://github.com/Uralstech/ezrSquared/releases
+* ezr² RE - v0.4.0 [27-09-24]
+ * Text objects (strings, characters, character lists), now implement a common interface `IEzrString`.
+ * Runtime errors now implement a common interface `IEzrRuntimeError`.
+
* ezr² RE - v0.3.1 [14-08-24]
* Updated shell with new version.
diff --git a/README.md b/README.md
index 37310ec..70ecfe1 100644
--- a/README.md
+++ b/README.md
@@ -6,9 +6,6 @@ More information, documentation and the reference manual for ezr² is available
## What's the 'ezrSquared-re' branch?
ezr² is being rewritten from the ground up! Expect more features, better performance and better code documentation!
-## Update!
-The development status of ezr² is now available on [***the ezr² project***](https://github.com/users/Uralstech/projects/3) and [***my blog***](https://uralstech.github.io/).
-
## Contributing
ezr² is an open source project and welcomes contributions from anyone who wants to improve it.
diff --git a/src/EzrSquared.csproj b/src/EzrSquared.csproj
index bb4220f..66b3129 100644
--- a/src/EzrSquared.csproj
+++ b/src/EzrSquared.csproj
@@ -28,7 +28,7 @@
ezr² Portable Library
The ezr² programming language, as a portable class library! This can be used to integrate ezr² as an embedded scripting language in your apps, websites and more!
- 0.3.1
+ 0.4.0
Udayshankar Ravikumar
URAV ADVANCED LEARNING SYSTEMS PRIVATE LIMITED
diff --git a/src/Runtime/Collections/RuntimeEzrObjectDictionary.cs b/src/Runtime/Collections/RuntimeEzrObjectDictionary.cs
index a9d9358..e9d0d2a 100644
--- a/src/Runtime/Collections/RuntimeEzrObjectDictionary.cs
+++ b/src/Runtime/Collections/RuntimeEzrObjectDictionary.cs
@@ -15,20 +15,20 @@ public class RuntimeEzrObjectDictionary : IMutable
///
/// The collection of s stored in the , in the format Dictionary<hashOfKey, KeyValuePair<key, valueReference>>.
///
- private readonly Dictionary> _items;
+ private readonly IDictionary> _items;
///
/// Creates a new .
///
public RuntimeEzrObjectDictionary()
{
- _items = [];
+ _items = new Dictionary>();
}
///
/// Creates a new from an existing .
///
- public RuntimeEzrObjectDictionary(Dictionary> items)
+ public RuntimeEzrObjectDictionary(IDictionary> items)
{
_items = items;
}
@@ -273,7 +273,6 @@ public void Release()
}
_items.Clear();
- _items.TrimExcess();
}
/// Destructor.
diff --git a/src/Runtime/Interpreter.cs b/src/Runtime/Interpreter.cs
index d2be250..c59ed38 100644
--- a/src/Runtime/Interpreter.cs
+++ b/src/Runtime/Interpreter.cs
@@ -1069,7 +1069,7 @@ private void VisitTryNode(TryNode node, Context executionContext, Context callin
if (RuntimeResult.ShouldReturnTryCatch || RuntimeResult.Error is null)
return;
- EzrRuntimeError error = RuntimeResult.Error!;
+ IEzrRuntimeError error = RuntimeResult.Error!;
RuntimeResult.Reset();
for (int i = 0; i < node.Cases.Count; i++)
@@ -1081,7 +1081,7 @@ private void VisitTryNode(TryNode node, Context executionContext, Context callin
return;
IEzrObject targetObject = RuntimeResult.Reference.Object;
- if (targetObject is not EzrSharpSourceTypeWrapper target || !typeof(EzrRuntimeError).IsAssignableFrom(target.SharpType))
+ if (targetObject is not EzrSharpSourceTypeWrapper target || !typeof(IEzrRuntimeError).IsAssignableFrom(target.SharpType))
{
RuntimeResult.Failure(new EzrUnexpectedTypeError($"Expected error type, but got object of type \"{targetObject.TypeName}\"!", executionContext, errorType.StartPosition, errorType.EndPosition));
return;
diff --git a/src/Runtime/RuntimeResult.cs b/src/Runtime/RuntimeResult.cs
index 8f10396..6333be4 100644
--- a/src/Runtime/RuntimeResult.cs
+++ b/src/Runtime/RuntimeResult.cs
@@ -16,7 +16,7 @@ public class RuntimeResult
///
/// The error that occured in interpretation, if none occured, this is .
///
- public EzrRuntimeError? Error;
+ public IEzrRuntimeError? Error;
///
/// Should the interpreter return from the current execution?
@@ -164,7 +164,7 @@ public void Success(Reference reference)
/// Sets a failed expression execution.
///
/// The error that caused the failure.
- public void Failure(EzrRuntimeError error)
+ public void Failure(IEzrRuntimeError error)
{
Reset();
Error = error;
diff --git a/src/Runtime/Types/CSharpWrappers/Builtins/EzrBuiltinFunctions.cs b/src/Runtime/Types/CSharpWrappers/Builtins/EzrBuiltinFunctions.cs
index 720b807..8af0c6e 100644
--- a/src/Runtime/Types/CSharpWrappers/Builtins/EzrBuiltinFunctions.cs
+++ b/src/Runtime/Types/CSharpWrappers/Builtins/EzrBuiltinFunctions.cs
@@ -67,14 +67,14 @@ public static void Show(SharpMethodParameters arguments)
}
///
- /// Basic error throwing function. Implements .
+ /// Basic error throwing function. Implements .
///
///
/// ezr² parameters:
///
/// -
/// error
- /// () The error to throw.
+ /// () The error to throw.
///
///
///
@@ -97,7 +97,7 @@ public static void ThrowError(SharpMethodParameters arguments)
Reference reference = arguments.ArgumentReferences["error"];
IEzrObject referenceObject = reference.Object;
- if (referenceObject is not EzrRuntimeError error)
+ if (referenceObject is not IEzrRuntimeError error)
arguments.Result.Failure(new EzrUnexpectedTypeError($"Expected runtime error, but got object of type \"{referenceObject.TypeName}\"!", arguments.ExecutionContext, referenceObject.StartPosition, referenceObject.EndPosition));
else
arguments.Result.Failure(error);
diff --git a/src/Runtime/Types/Core/RuntimeErrors/EzrRuntimeError.cs b/src/Runtime/Types/Core/RuntimeErrors/EzrRuntimeError.cs
index 7d07311..3267bb8 100644
--- a/src/Runtime/Types/Core/RuntimeErrors/EzrRuntimeError.cs
+++ b/src/Runtime/Types/Core/RuntimeErrors/EzrRuntimeError.cs
@@ -7,10 +7,10 @@
namespace EzrSquared.Runtime.Types.Core.Errors;
///
-/// Base of all error type objects.
+/// Implementation of with some utility methods.
///
[SharpTypeWrapper("runtime_error")]
-public class EzrRuntimeError : EzrObject
+public class EzrRuntimeError : EzrObject, IEzrRuntimeError
{
///
public override string TypeName { get; protected internal set; } = "runtime error";
@@ -18,30 +18,20 @@ public class EzrRuntimeError : EzrObject
///
public override string Tag { get; protected internal set; } = "ezrSquared.RuntimeError";
- ///
- /// The name of the .
- ///
- public readonly string Title;
+ ///
+ public string Title { get; }
- ///
- /// The reason why the occurred.
- ///
- public readonly string Details;
+ ///
+ public string Details { get; }
- ///
- /// The context where the error occurred.
- ///
- public readonly Context ErrorContext;
+ ///
+ public Context ErrorContext { get; }
- ///
- /// The starting position of the error.
- ///
- public readonly Position ErrorStartPosition;
+ ///
+ public Position ErrorStartPosition { get; }
- ///
- /// The ending position of the error.
- ///
- public readonly Position ErrorEndPosition;
+ ///
+ public Position ErrorEndPosition { get; }
///
/// Creates a new runtime error object.
@@ -94,17 +84,11 @@ protected internal static string GetStringArgument(string argumentName, IEzrObje
switch (ezrObject)
{
- case EzrString ezrString:
- return ezrString.Value;
-
- case EzrCharacter ezrCharacter:
- return ezrCharacter.Value.ToString();
-
- case EzrCharacterList ezrCharacterList:
- return ezrCharacterList.StringValue;
+ case IEzrString ezrString:
+ return ezrString.StringValue;
default:
- result.Failure(new EzrUnexpectedTypeError($"Expected {argumentName} of type string, character or character list, but got object of type \"{ezrObject.TypeName}\"!", context, ezrObject.StartPosition, ezrObject.EndPosition));
+ result.Failure(new EzrUnexpectedTypeError($"Expected {argumentName} to be text, but got object of type \"{ezrObject.TypeName}\"!", context, ezrObject.StartPosition, ezrObject.EndPosition));
return string.Empty;
}
}
diff --git a/src/Runtime/Types/Core/RuntimeErrors/IEzrRuntimeError.cs b/src/Runtime/Types/Core/RuntimeErrors/IEzrRuntimeError.cs
new file mode 100644
index 0000000..8e1cb18
--- /dev/null
+++ b/src/Runtime/Types/Core/RuntimeErrors/IEzrRuntimeError.cs
@@ -0,0 +1,32 @@
+namespace EzrSquared.Runtime.Types.Core.Errors;
+
+///
+/// Base of all error types.
+///
+public interface IEzrRuntimeError : IEzrObject
+{
+ ///
+ /// The title of the error.
+ ///
+ public string Title { get; }
+
+ ///
+ /// The reason why the error occurred.
+ ///
+ public string Details { get; }
+
+ ///
+ /// The context where the error occurred.
+ ///
+ public Context ErrorContext { get; }
+
+ ///
+ /// The starting position of the error.
+ ///
+ public Position ErrorStartPosition { get; }
+
+ ///
+ /// The ending position of the error.
+ ///
+ public Position ErrorEndPosition { get; }
+}
diff --git a/src/Runtime/Types/Core/Text/EzrCharacter.cs b/src/Runtime/Types/Core/Text/EzrCharacter.cs
index 2a040d0..d28a577 100644
--- a/src/Runtime/Types/Core/Text/EzrCharacter.cs
+++ b/src/Runtime/Types/Core/Text/EzrCharacter.cs
@@ -13,7 +13,7 @@ namespace EzrSquared.Runtime.Types.Core.Text;
/// The parent context.
/// The starting position of the object.
/// The ending position of the object.
-public class EzrCharacter(char value, Context parentContext, Position startPosition, Position endPosition) : EzrObject(parentContext, startPosition, endPosition)
+public class EzrCharacter(char value, Context parentContext, Position startPosition, Position endPosition) : EzrObject(parentContext, startPosition, endPosition), IEzrString
{
///
public override string TypeName { get; protected internal set; } = "character";
@@ -26,6 +26,9 @@ public class EzrCharacter(char value, Context parentContext, Position startPosit
///
public readonly char Value = value;
+ ///
+ public string StringValue => Value.ToString();
+
///
public override void ComparisonEqual(IEzrObject other, RuntimeResult result)
{
@@ -37,10 +40,8 @@ public override void ComparisonEqual(IEzrObject other, RuntimeResult result)
result.Success(NewBooleanConstant(Value == otherInteger.Value)); break;
case EzrFloat otherFloat:
result.Success(NewBooleanConstant(Value == otherFloat.Value)); break;
- case EzrString otherString:
- result.Success(NewBooleanConstant(Value.ToString() == otherString.Value)); break;
- case EzrCharacterList otherCharacterList:
- result.Success(NewBooleanConstant(Value.ToString() == otherCharacterList.StringValue)); break;
+ case IEzrString otherString:
+ result.Success(NewBooleanConstant(StringValue == otherString.StringValue)); break;
default:
result.Success(NewBooleanConstant(false)); break;
}
@@ -57,10 +58,8 @@ public override void ComparisonNotEqual(IEzrObject other, RuntimeResult result)
result.Success(NewBooleanConstant(Value != otherInteger.Value)); break;
case EzrFloat otherFloat:
result.Success(NewBooleanConstant(Value != otherFloat.Value)); break;
- case EzrString otherString:
- result.Success(NewBooleanConstant(Value.ToString() != otherString.Value)); break;
- case EzrCharacterList otherCharacterList:
- result.Success(NewBooleanConstant(Value.ToString() != otherCharacterList.StringValue)); break;
+ case IEzrString otherString:
+ result.Success(NewBooleanConstant(StringValue != otherString.StringValue)); break;
default:
result.Success(NewBooleanConstant(true)); break;
}
@@ -77,10 +76,8 @@ public override void ComparisonLessThan(IEzrObject other, RuntimeResult result)
result.Success(NewBooleanConstant(Value < otherInteger.Value)); break;
case EzrFloat otherFloat:
result.Success(NewBooleanConstant(Value < otherFloat.Value)); break;
- case EzrString otherString:
- result.Success(NewBooleanConstant(Value.CompareTo(otherString.Value) < 0)); break;
- case EzrCharacterList otherCharacterList:
- result.Success(NewBooleanConstant(Value.CompareTo(otherCharacterList.StringValue) < 0)); break;
+ case IEzrString otherString:
+ result.Success(NewBooleanConstant(Value.CompareTo(otherString.StringValue) < 0)); break;
default:
result.Failure(IllegalOperation(other)); break;
}
@@ -97,10 +94,8 @@ public override void ComparisonGreaterThan(IEzrObject other, RuntimeResult resul
result.Success(NewBooleanConstant(Value > otherInteger.Value)); break;
case EzrFloat otherFloat:
result.Success(NewBooleanConstant(Value > otherFloat.Value)); break;
- case EzrString otherString:
- result.Success(NewBooleanConstant(Value.CompareTo(otherString.Value) > 0)); break;
- case EzrCharacterList otherCharacterList:
- result.Success(NewBooleanConstant(Value.CompareTo(otherCharacterList.StringValue) > 0)); break;
+ case IEzrString otherString:
+ result.Success(NewBooleanConstant(Value.CompareTo(otherString.StringValue) > 0)); break;
default:
result.Failure(IllegalOperation(other)); break;
}
@@ -117,10 +112,8 @@ public override void ComparisonLessThanOrEqual(IEzrObject other, RuntimeResult r
result.Success(NewBooleanConstant(Value <= otherInteger.Value)); break;
case EzrFloat otherFloat:
result.Success(NewBooleanConstant(Value <= otherFloat.Value)); break;
- case EzrString otherString:
- result.Success(NewBooleanConstant(Value.CompareTo(otherString.Value) <= 0)); break;
- case EzrCharacterList otherCharacterList:
- result.Success(NewBooleanConstant(Value.CompareTo(otherCharacterList.StringValue) <= 0)); break;
+ case IEzrString otherString:
+ result.Success(NewBooleanConstant(Value.CompareTo(otherString.StringValue) <= 0)); break;
default:
result.Failure(IllegalOperation(other)); break;
}
@@ -137,10 +130,8 @@ public override void ComparisonGreaterThanOrEqual(IEzrObject other, RuntimeResul
result.Success(NewBooleanConstant(Value >= otherInteger.Value)); break;
case EzrFloat otherFloat:
result.Success(NewBooleanConstant(Value >= otherFloat.Value)); break;
- case EzrString otherString:
- result.Success(NewBooleanConstant(Value.CompareTo(otherString.Value) >= 0)); break;
- case EzrCharacterList otherCharacterList:
- result.Success(NewBooleanConstant(Value.CompareTo(otherCharacterList.StringValue) >= 0)); break;
+ case IEzrString otherString:
+ result.Success(NewBooleanConstant(Value.CompareTo(otherString.StringValue) >= 0)); break;
default:
result.Failure(IllegalOperation(other)); break;
}
diff --git a/src/Runtime/Types/Core/Text/EzrCharacterList.cs b/src/Runtime/Types/Core/Text/EzrCharacterList.cs
index 1c63ade..a92ca5c 100644
--- a/src/Runtime/Types/Core/Text/EzrCharacterList.cs
+++ b/src/Runtime/Types/Core/Text/EzrCharacterList.cs
@@ -14,7 +14,7 @@ namespace EzrSquared.Runtime.Types.Core.Text;
/// The parent context.
/// The starting position of the object.
/// The ending position of the object.
-public class EzrCharacterList(string value, Context parentContext, Position startPosition, Position endPosition) : EzrObject(parentContext, startPosition, endPosition), IEzrMutableObject
+public class EzrCharacterList(string value, Context parentContext, Position startPosition, Position endPosition) : EzrObject(parentContext, startPosition, endPosition), IEzrMutableObject, IEzrString
{
///
public override string TypeName { get; protected internal set; } = "character list";
@@ -37,12 +37,8 @@ public override void ComparisonEqual(IEzrObject other, RuntimeResult result)
{
switch (other)
{
- case EzrString otherString:
- result.Success(NewBooleanConstant(StringValue == otherString.Value)); break;
- case EzrCharacterList otherCharacterList:
- result.Success(NewBooleanConstant(StringValue == otherCharacterList.StringValue)); break;
- case EzrCharacter otherCharacter:
- result.Success(NewBooleanConstant(StringValue == otherCharacter.Value.ToString())); break;
+ case IEzrString otherString:
+ result.Success(NewBooleanConstant(StringValue == otherString.StringValue)); break;
default:
result.Success(NewBooleanConstant(false)); break;
}
@@ -53,12 +49,8 @@ public override void ComparisonNotEqual(IEzrObject other, RuntimeResult result)
{
switch (other)
{
- case EzrString otherString:
- result.Success(NewBooleanConstant(StringValue != otherString.Value)); break;
- case EzrCharacterList otherCharacterList:
- result.Success(NewBooleanConstant(StringValue != otherCharacterList.StringValue)); break;
- case EzrCharacter otherCharacter:
- result.Success(NewBooleanConstant(StringValue != otherCharacter.Value.ToString())); break;
+ case IEzrString otherString:
+ result.Success(NewBooleanConstant(StringValue != otherString.StringValue)); break;
default:
result.Success(NewBooleanConstant(true)); break;
}
@@ -138,12 +130,8 @@ public override void ComparisonLessThan(IEzrObject other, RuntimeResult result)
result.Success(NewCharacterListConstant(StringValue[startIndexInt..(endIndexInt + 1)]));
break;
- case EzrString otherString:
- result.Success(NewBooleanConstant(string.CompareOrdinal(StringValue, otherString.Value) < 0)); break;
- case EzrCharacterList otherCharacterList:
- result.Success(NewBooleanConstant(string.CompareOrdinal(StringValue, otherCharacterList.StringValue) < 0)); break;
- case EzrCharacter otherCharacter:
- result.Success(NewBooleanConstant(string.CompareOrdinal(StringValue, otherCharacter.Value.ToString()) < 0)); break;
+ case IEzrString otherString:
+ result.Success(NewBooleanConstant(string.CompareOrdinal(StringValue, otherString.StringValue) < 0)); break;
default:
result.Failure(IllegalOperation(other)); break;
}
@@ -154,12 +142,8 @@ public override void ComparisonGreaterThan(IEzrObject other, RuntimeResult resul
{
switch (other)
{
- case EzrString otherString:
- result.Success(NewBooleanConstant(string.CompareOrdinal(StringValue, otherString.Value) > 0)); break;
- case EzrCharacterList otherCharacterList:
- result.Success(NewBooleanConstant(string.CompareOrdinal(StringValue, otherCharacterList.StringValue) > 0)); break;
- case EzrCharacter otherCharacter:
- result.Success(NewBooleanConstant(string.CompareOrdinal(StringValue, otherCharacter.Value.ToString()) > 0)); break;
+ case IEzrString otherString:
+ result.Success(NewBooleanConstant(string.CompareOrdinal(StringValue, otherString.StringValue) > 0)); break;
default:
result.Failure(IllegalOperation(other)); break;
}
@@ -178,12 +162,8 @@ public override void ComparisonLessThanOrEqual(IEzrObject other, RuntimeResult r
ComparisonLessThan(other, result);
break;
- case EzrString otherString:
- result.Success(NewBooleanConstant(string.CompareOrdinal(StringValue, otherString.Value) <= 0)); break;
- case EzrCharacterList otherCharacterList:
- result.Success(NewBooleanConstant(string.CompareOrdinal(StringValue, otherCharacterList.StringValue) <= 0)); break;
- case EzrCharacter otherCharacter:
- result.Success(NewBooleanConstant(string.CompareOrdinal(StringValue, otherCharacter.Value.ToString()) <= 0)); break;
+ case IEzrString otherString:
+ result.Success(NewBooleanConstant(string.CompareOrdinal(StringValue, otherString.StringValue) <= 0)); break;
default:
result.Failure(IllegalOperation(other)); break;
}
@@ -194,12 +174,8 @@ public override void ComparisonGreaterThanOrEqual(IEzrObject other, RuntimeResul
{
switch (other)
{
- case EzrString otherString:
- result.Success(NewBooleanConstant(string.CompareOrdinal(StringValue, otherString.Value) >= 0)); break;
- case EzrCharacterList otherCharacterList:
- result.Success(NewBooleanConstant(string.CompareOrdinal(StringValue, otherCharacterList.StringValue) >= 0)); break;
- case EzrCharacter otherCharacter:
- result.Success(NewBooleanConstant(string.CompareOrdinal(StringValue, otherCharacter.Value.ToString()) >= 0)); break;
+ case IEzrString otherString:
+ result.Success(NewBooleanConstant(string.CompareOrdinal(StringValue, otherString.StringValue) >= 0)); break;
default:
result.Failure(IllegalOperation(other)); break;
}
@@ -213,12 +189,8 @@ public override void Addition(IEzrObject other, RuntimeResult result)
{
switch (other)
{
- case EzrCharacterList otherCharacterList:
- Value.Append(otherCharacterList.Value); break;
- case EzrString otherString:
- Value.Append(otherString.Value); break;
- case EzrCharacter otherCharacter:
- Value.Append(otherCharacter.Value); break;
+ case IEzrString otherString:
+ Value.Append(otherString.StringValue); break;
default:
string otherStringValue = other.ToPureString(result);
if (result.ShouldReturn)
@@ -426,10 +398,8 @@ public override void HasValueContained(IEzrObject other, RuntimeResult result)
{
switch (other)
{
- case EzrString otherString:
- result.Success(NewBooleanConstant(StringValue.Contains(otherString.Value))); break;
- case EzrCharacterList otherCharacterList:
- result.Success(NewBooleanConstant(StringValue.Contains(otherCharacterList.StringValue))); break;
+ case IEzrString otherString:
+ result.Success(NewBooleanConstant(StringValue.Contains(otherString.StringValue))); break;
default:
result.Failure(IllegalOperation(other, false)); break;
}
@@ -440,10 +410,8 @@ public override void NotHasValueContained(IEzrObject other, RuntimeResult result
{
switch (other)
{
- case EzrString otherString:
- result.Success(NewBooleanConstant(!StringValue.Contains(otherString.Value))); break;
- case EzrCharacterList otherCharacterList:
- result.Success(NewBooleanConstant(!StringValue.Contains(otherCharacterList.StringValue))); break;
+ case IEzrString otherString:
+ result.Success(NewBooleanConstant(!StringValue.Contains(otherString.StringValue))); break;
default:
result.Failure(IllegalOperation(other, false)); break;
}
diff --git a/src/Runtime/Types/Core/Text/EzrString.cs b/src/Runtime/Types/Core/Text/EzrString.cs
index 1e3c130..b878ad2 100644
--- a/src/Runtime/Types/Core/Text/EzrString.cs
+++ b/src/Runtime/Types/Core/Text/EzrString.cs
@@ -14,7 +14,7 @@ namespace EzrSquared.Runtime.Types.Core.Text;
/// The parent context.
/// The starting position of the object.
/// The ending position of the object.
-public class EzrString(string value, Context parentContext, Position startPosition, Position endPosition) : EzrObject(parentContext, startPosition, endPosition)
+public class EzrString(string value, Context parentContext, Position startPosition, Position endPosition) : EzrObject(parentContext, startPosition, endPosition), IEzrString
{
///
public override string TypeName { get; protected internal set; } = "string";
@@ -27,17 +27,16 @@ public class EzrString(string value, Context parentContext, Position startPositi
///
public readonly string Value = value;
+ ///
+ public string StringValue => Value;
+
///
public override void ComparisonEqual(IEzrObject other, RuntimeResult result)
{
switch (other)
{
- case EzrString otherString:
- result.Success(NewBooleanConstant(Value == otherString.Value)); break;
- case EzrCharacterList otherCharacterList:
- result.Success(NewBooleanConstant(Value == otherCharacterList.StringValue)); break;
- case EzrCharacter otherCharacter:
- result.Success(NewBooleanConstant(Value == otherCharacter.Value.ToString())); break;
+ case IEzrString otherString:
+ result.Success(NewBooleanConstant(Value == otherString.StringValue)); break;
default:
result.Success(NewBooleanConstant(false)); break;
}
@@ -48,12 +47,8 @@ public override void ComparisonNotEqual(IEzrObject other, RuntimeResult result)
{
switch (other)
{
- case EzrString otherString:
- result.Success(NewBooleanConstant(Value != otherString.Value)); break;
- case EzrCharacterList otherCharacterList:
- result.Success(NewBooleanConstant(Value != otherCharacterList.StringValue)); break;
- case EzrCharacter otherCharacter:
- result.Success(NewBooleanConstant(Value != otherCharacter.Value.ToString())); break;
+ case IEzrString otherString:
+ result.Success(NewBooleanConstant(Value != otherString.StringValue)); break;
default:
result.Success(NewBooleanConstant(true)); break;
}
@@ -133,12 +128,8 @@ public override void ComparisonLessThan(IEzrObject other, RuntimeResult result)
result.Success(NewStringConstant(Value[startIndexInt..(endIndexInt + 1)]));
break;
- case EzrString otherString:
- result.Success(NewBooleanConstant(string.CompareOrdinal(Value, otherString.Value) < 0)); break;
- case EzrCharacterList otherCharacterList:
- result.Success(NewBooleanConstant(string.CompareOrdinal(Value, otherCharacterList.StringValue) < 0)); break;
- case EzrCharacter otherCharacter:
- result.Success(NewBooleanConstant(string.CompareOrdinal(Value, otherCharacter.Value.ToString()) < 0)); break;
+ case IEzrString otherString:
+ result.Success(NewBooleanConstant(string.CompareOrdinal(Value, otherString.StringValue) < 0)); break;
default:
result.Failure(IllegalOperation(other)); break;
}
@@ -149,12 +140,8 @@ public override void ComparisonGreaterThan(IEzrObject other, RuntimeResult resul
{
switch (other)
{
- case EzrString otherString:
- result.Success(NewBooleanConstant(string.CompareOrdinal(Value, otherString.Value) > 0)); break;
- case EzrCharacterList otherCharacterList:
- result.Success(NewBooleanConstant(string.CompareOrdinal(Value, otherCharacterList.StringValue) > 0)); break;
- case EzrCharacter otherCharacter:
- result.Success(NewBooleanConstant(string.CompareOrdinal(Value, otherCharacter.Value.ToString()) > 0)); break;
+ case IEzrString otherString:
+ result.Success(NewBooleanConstant(string.CompareOrdinal(Value, otherString.StringValue) > 0)); break;
default:
result.Failure(IllegalOperation(other)); break;
}
@@ -173,12 +160,8 @@ public override void ComparisonLessThanOrEqual(IEzrObject other, RuntimeResult r
ComparisonLessThan(other, result);
break;
- case EzrString otherString:
- result.Success(NewBooleanConstant(string.CompareOrdinal(Value, otherString.Value) <= 0)); break;
- case EzrCharacterList otherCharacterList:
- result.Success(NewBooleanConstant(string.CompareOrdinal(Value, otherCharacterList.StringValue) <= 0)); break;
- case EzrCharacter otherCharacter:
- result.Success(NewBooleanConstant(string.CompareOrdinal(Value, otherCharacter.Value.ToString()) <= 0)); break;
+ case IEzrString otherString:
+ result.Success(NewBooleanConstant(string.CompareOrdinal(Value, otherString.StringValue) <= 0)); break;
default:
result.Failure(IllegalOperation(other)); break;
}
@@ -189,12 +172,8 @@ public override void ComparisonGreaterThanOrEqual(IEzrObject other, RuntimeResul
{
switch (other)
{
- case EzrString otherString:
- result.Success(NewBooleanConstant(string.CompareOrdinal(Value, otherString.Value) >= 0)); break;
- case EzrCharacterList otherCharacterList:
- result.Success(NewBooleanConstant(string.CompareOrdinal(Value, otherCharacterList.StringValue) >= 0)); break;
- case EzrCharacter otherCharacter:
- result.Success(NewBooleanConstant(string.CompareOrdinal(Value, otherCharacter.Value.ToString()) >= 0)); break;
+ case IEzrString otherString:
+ result.Success(NewBooleanConstant(string.CompareOrdinal(Value, otherString.StringValue) >= 0)); break;
default:
result.Failure(IllegalOperation(other)); break;
}
@@ -209,12 +188,8 @@ public override void Addition(IEzrObject other, RuntimeResult result)
string newValue = Value;
switch (other)
{
- case EzrCharacterList otherCharacterList:
- newValue += otherCharacterList.StringValue; break;
- case EzrString otherString:
- newValue += otherString.Value; break;
- case EzrCharacter otherCharacter:
- newValue += otherCharacter.Value; break;
+ case IEzrString otherString:
+ newValue += otherString.StringValue; break;
default:
newValue += other.ToPureString(result);
if (result.ShouldReturn)
@@ -416,10 +391,8 @@ public override void HasValueContained(IEzrObject other, RuntimeResult result)
{
switch (other)
{
- case EzrString otherString:
- result.Success(NewBooleanConstant(Value.Contains(otherString.Value))); break;
- case EzrCharacterList otherCharacterList:
- result.Success(NewBooleanConstant(Value.Contains(otherCharacterList.StringValue))); break;
+ case IEzrString otherString:
+ result.Success(NewBooleanConstant(Value.Contains(otherString.StringValue))); break;
default:
result.Failure(IllegalOperation(other, false)); break;
}
@@ -430,10 +403,8 @@ public override void NotHasValueContained(IEzrObject other, RuntimeResult result
{
switch (other)
{
- case EzrString otherString:
- result.Success(NewBooleanConstant(!Value.Contains(otherString.Value))); break;
- case EzrCharacterList otherCharacterList:
- result.Success(NewBooleanConstant(!Value.Contains(otherCharacterList.StringValue))); break;
+ case IEzrString otherString:
+ result.Success(NewBooleanConstant(!Value.Contains(otherString.StringValue))); break;
default:
result.Failure(IllegalOperation(other, false)); break;
}
diff --git a/src/Runtime/Types/Core/Text/IEzrString.cs b/src/Runtime/Types/Core/Text/IEzrString.cs
new file mode 100644
index 0000000..9e0602c
--- /dev/null
+++ b/src/Runtime/Types/Core/Text/IEzrString.cs
@@ -0,0 +1,12 @@
+namespace EzrSquared.Runtime.Types.Core.Text;
+
+///
+/// Interface for getting the value of string-like ezr² objects as C# strings.
+///
+public interface IEzrString : IEzrObject
+{
+ ///
+ /// The string value.
+ ///
+ public string StringValue { get; }
+}
diff --git a/src/Shell/EzrShell.cs b/src/Shell/EzrShell.cs
index 8c623c5..ce2ce3c 100644
--- a/src/Shell/EzrShell.cs
+++ b/src/Shell/EzrShell.cs
@@ -12,7 +12,7 @@ namespace EzrSquaredCli;
///
internal class Shell
{
- private const string Version = "0.3.1";
+ private const string Version = "0.4.0";
private static bool s_showLexerOutput;
private static bool s_showParserOutput;
diff --git a/src/Shell/InstallerSrc/ezrSquared 32-bit.iss b/src/Shell/InstallerSrc/ezrSquared 32-bit.iss
index 8ab836e..4bbc145 100644
--- a/src/Shell/InstallerSrc/ezrSquared 32-bit.iss
+++ b/src/Shell/InstallerSrc/ezrSquared 32-bit.iss
@@ -4,7 +4,7 @@
#include "environment.iss"
#define MyAppName "ezr²"
-#define MyAppVersion "0.3.1"
+#define MyAppVersion "0.4.0"
#define MyAppPublisher "Uralstech"
#define MyAppURL "https://uralstech.github.io/ezrSquared/"
#define MyAppExeName "ezrSquared.exe"
diff --git a/src/Shell/InstallerSrc/ezrSquared 64-bit.iss b/src/Shell/InstallerSrc/ezrSquared 64-bit.iss
index ff40a67..c45a3bd 100644
--- a/src/Shell/InstallerSrc/ezrSquared 64-bit.iss
+++ b/src/Shell/InstallerSrc/ezrSquared 64-bit.iss
@@ -4,7 +4,7 @@
#include "environment.iss"
#define MyAppName "ezr²"
-#define MyAppVersion "0.3.1"
+#define MyAppVersion "0.4.0"
#define MyAppPublisher "Uralstech"
#define MyAppURL "https://uralstech.github.io/ezrSquared/"
#define MyAppExeName "ezrSquared.exe"
diff --git a/src/Shell/Shell.csproj b/src/Shell/Shell.csproj
index 80a62f8..94c3b95 100644
--- a/src/Shell/Shell.csproj
+++ b/src/Shell/Shell.csproj
@@ -24,7 +24,7 @@
The ezrSquared Command Line Interface
The Command Line Interface for the ezrSquared programming language.
- 0.3.1
+ 0.4.0
Udayshankar Ravikumar
URAV ADVANCED LEARNING SYSTEMS PRIVATE LIMITED