diff --git a/Classes/Values.cs b/Classes/Values.cs index a44a428..6efd546 100644 --- a/Classes/Values.cs +++ b/Classes/Values.cs @@ -132,13 +132,6 @@ public item setContext(context? context) return null; } - internal context generateContext() - { - context newContext = new context($"{GetType().Name}-internal", context, startPos, false); - newContext.symbolTable = new symbolTable(newContext.parent.symbolTable); - return newContext; - } - public virtual runtimeResult execute(item[] args) { return new runtimeResult().failure(illegalOperation()); } public virtual runtimeResult retrieve(node node) { return new runtimeResult().failure(illegalOperation()); } @@ -156,7 +149,7 @@ internal error illegalOperation(item? other = null) public override int GetHashCode() { throw new Exception($"No GetHashCode method defined for '{GetType().Name}'!"); } } - public abstract class value: item + public abstract class value : item { public dynamic storedValue; internal context? internalContext; @@ -170,7 +163,7 @@ public value(dynamic storedValue) internal context generateContext() { - context newContext = new context($"{GetType().Name}-internal", context, startPos, false); + context newContext = new context($"<<{GetType().Name}> internal>", context, startPos, false); newContext.symbolTable = new symbolTable(newContext.parent.symbolTable); return newContext; } @@ -770,9 +763,9 @@ public runtimeResult stringSlice(context context) if (startAsInt < 0) return result.failure(new runtimeError(startPos, endPos, RT_TYPE, "Start cannot be less than zero", context)); - else if (endAsInt > storedValue.ToString().Length) + else if (endAsInt > storedValue.ToString().Length) return result.failure(new runtimeError(startPos, endPos, RT_TYPE, "End cannot be greater than length of string", context)); - else if (startAsInt > endAsInt) + else if (startAsInt > endAsInt) return result.failure(new runtimeError(startPos, endPos, RT_TYPE, "Start cannot be greater than end", context)); return result.success(new @string(storedValue.ToString().Substring(startAsInt, endAsInt))); @@ -793,7 +786,7 @@ public runtimeResult stringInsert(context context) if (startAsInt < 0) return result.failure(new runtimeError(startPos, endPos, RT_TYPE, "Index cannot be less than zero", context)); - else if (startAsInt > storedValue.ToString().Length) + else if (startAsInt > storedValue.ToString().Length) return result.failure(new runtimeError(startPos, endPos, RT_TYPE, "Index cannot be greater than length of string", context)); return result.success(new @string(storedValue.ToString().Insert(startAsInt, ((@string)substring).storedValue.ToString()))); @@ -854,7 +847,7 @@ public runtimeResult asInteger(context context) return result.success(new integerNumber(integer)); return result.failure(new runtimeError(startPos, endPos, RT_TYPE, "Could not convert string to integerNumber", context)); } - + public runtimeResult asFloat(context context) { runtimeResult result = new runtimeResult(); @@ -1436,7 +1429,7 @@ public override runtimeResult execute(item[] args) public override string ToString() { string[] elementStrings = new string[storedValue.Count]; - KeyValuePair [] values = ((Dictionary)storedValue).AsEnumerable().ToArray(); + KeyValuePair[] values = ((Dictionary)storedValue).AsEnumerable().ToArray(); for (int i = 0; i < values.Length; i++) elementStrings[i] = $"{values[i].Key} : {values[i].Value}"; return '{' + string.Join(", ", elementStrings) + '}'; @@ -1462,7 +1455,7 @@ public baseFunction(string? name) : base() internal context generateContext() { context newContext = new context(name, context, startPos, false); - newContext.symbolTable = new symbolTable(context.parent.symbolTable); + newContext.symbolTable = new symbolTable(newContext.parent.symbolTable); return newContext; } @@ -1633,7 +1626,7 @@ private runtimeResult _run(context context) return result.failure(new runtimeError(startPos, endPos, RT_IO, $"Failed to load script \"{path}\"\n{exception.Message}", context)); } - error? error = new main.ezr().run(path, script, out item? _); + error? error = new main.ezr().run(Path.GetFileName(path), script, out item? _); if (error != null) return result.failure(new runtimeError(startPos, endPos, RT_RUN, $"Failed to execute script \"{path}\"\n\n{error.asString()}", context)); return result.success(new nothing()); diff --git a/Constants.cs b/Constants.cs index 8f47471..2a4f1a0 100644 --- a/Constants.cs +++ b/Constants.cs @@ -2,7 +2,7 @@ { public static class Constants { - public const string VERSION = "beta-1.0.0.0.1"; + public const string VERSION = "beta-1.0.0.0.2"; public const string VERSION_DATE = "23.12.2022"; public const string LETTERS_UNDERSCORE = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_"; diff --git a/README.md b/README.md index cabf02a..f79582f 100644 --- a/README.md +++ b/README.md @@ -30,4 +30,18 @@ And the differences: * QSyntax is not available in ezr * Count loops are different * All the variable types have had an overhaul in ezr² -* ezr² is much faster \ No newline at end of file +* ezr² is much faster + +## Progress +* **beta-1.0.0.0.2** - [23-12-22] + * Fixed bug in `baseFunction` class - Changed `newContext.symbolTable = new symbolTable(context.parent.symbolTable)` to `newContext.symbolTable = new symbolTable(newContext.parent.symbolTable)` + * For builtin function `run`, changed filename from full path to just file name + * Removed unused `GenerateContext` definition in `item` class + * Fixed bug in `shell` (now `biShell` - builtin shell) for paths given through command line - `Replace("\\", "\\\\")` + +* **beta-1.0.0.0.1** - [23-12-22] + * Fixed bug for builtin function `get` - Changed message output from `Writeline` to `Write` + * Changed `value` class' `execute` function check from `left is not baseFunction` to `left is value` + +* **beta-1.0.0.0.0** - [22-12-22] + * Initial release! \ No newline at end of file diff --git a/ezrShell.cs b/ezrShell.cs index 22639dc..3305c1d 100644 --- a/ezrShell.cs +++ b/ezrShell.cs @@ -12,7 +12,7 @@ public static void Main(string[] args) { string filepath = string.Empty; if (args.Length > 0) - filepath = args[0]; + filepath = args[0].Replace("\\", "\\\\"); ezr instance = new ezr(); Console.WriteLine($"ezrĀ² Shell version- ({VERSION}) release- [{VERSION_DATE}]"); @@ -65,7 +65,7 @@ public static void Main(string[] args) filepath = string.Empty; } - error? error = instance.run("shell", script, out item? result); + error? error = instance.run("", script, out item? result); if (error != null) Console.WriteLine(error.asString()); else if (result != null) { diff --git a/ezrSquared.csproj b/ezrSquared.csproj index b7d3b58..9303949 100644 --- a/ezrSquared.csproj +++ b/ezrSquared.csproj @@ -15,4 +15,8 @@ + + + +