Skip to content

Commit

Permalink
ezrSquared prerelease-1.3.2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Uralstech committed Feb 15, 2023
1 parent 5f2c246 commit ad337a4
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 11 deletions.
21 changes: 15 additions & 6 deletions Classes/Errors.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
using ezrSquared.General;
using static ezrSquared.Constants.constants;
using System;

namespace ezrSquared.Errors
{
public abstract class error
{
public string name;
public string details;
public position startPos;
public position endPos;
internal string name;
internal string details;
internal position startPos;
internal position endPos;

public error(string name, string details, position startPos, position endPos)
{
Expand Down Expand Up @@ -52,12 +53,12 @@ public class overflowError : error

public class runtimeError : error
{
public context context;
private context context;
public runtimeError(position startPos, position endPos, string tag, string details, context context) : base(tag, details, startPos, endPos) { this.context = context; }

public override string asString() { return $"{generateTraceback()}(runtime error) : {details} -> tag '{name}'\n\n{stringWithUnderline(startPos.text, startPos, endPos)}"; }

private string generateTraceback()
internal string generateTraceback()
{
string result = "";
position? pos = startPos;
Expand All @@ -73,4 +74,12 @@ private string generateTraceback()
return $"Traceback - most recent call last:\n{result}";
}
}

public class runtimeRunError : runtimeError
{
private string runError;
public runtimeRunError(position startPos, position endPos, string details, string runError, context context) : base(startPos, endPos, RT_RUN, details, context) { this.runError = runError; }

public override string asString() { return $"{generateTraceback()}(runtime error) : {details} -> tag '{name}'\n\n{stringWithUnderline(startPos.text, startPos, endPos)}\n\n{runError}"; }
}
}
2 changes: 1 addition & 1 deletion Classes/Values.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2272,7 +2272,7 @@ private runtimeResult _run(context context)

error? error = run(Path.GetFileName(path), script, runtimeContext, 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.failure(new runtimeRunError(startPos, endPos, $"Failed to execute script \"{path}\"", error.asString(), context));
return result.success(new nothing());
}

Expand Down
2 changes: 1 addition & 1 deletion Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace ezrSquared.Constants
{
public static class constants
{
public const string VERSION = "prerelease-1.3.1.0.0";
public const string VERSION = "prerelease-1.3.2.0.0";
public const string VERSION_DATE = "14.02.2023";

public static readonly string[] KEYWORDS = { "item", "and", "or", "invert", "if", "else", "do", "count", "from", "as", "to", "step", "while", "function", "special", "with", "end", "return", "skip", "stop", "try", "error", "in", "object", "global", "include" };
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ I just need to finish the documentation! If you find any bugs, report them [here
### Released
**Check the [GitHub Commits](https://github.com/Uralstech/ezrSquared/commits) for all changes in source code**

* **prerelease-1.3.2.0.0** - [15-02-23]
* New runtimeRunError error class!

* **prerelease-1.3.1.0.0** - [14-02-23]
* Fixed a count loop error message
* Better error message for else if statements
Expand Down
6 changes: 3 additions & 3 deletions ezr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3381,7 +3381,7 @@ private runtimeResult visit_includeNode(includeNode node, context context)
}
catch (Exception exception)
{
return result.failure(new runtimeError(node.startPos, node.endPos, RT_RUN, $"Failed to execute script \"{file}\"\n{exception.Message}", context));
return result.failure(new runtimeRunError(node.startPos, node.endPos, $"Failed to execute script \"{file}\"", exception.Message, context));
}
}
else
Expand All @@ -3398,11 +3398,11 @@ private runtimeResult visit_includeNode(includeNode node, context context)

token[] tokens = new lexer(file, script).compileTokens(out error? error);
if (error != null)
return result.failure(new runtimeError(node.startPos, node.endPos, RT_RUN, $"Failed to execute script \"{file}\"\n\n{error.asString()}", context));
return result.failure(new runtimeRunError(node.startPos, node.endPos, $"Failed to execute script \"{file}\"", error.asString(), context));

parseResult parseResult = new parser(tokens).parse();
if (parseResult.error != null)
return result.failure(new runtimeError(node.startPos, node.endPos, RT_RUN, $"Failed to execute script \"{file}\"\n\n{parseResult.error.asString()}", context));
return result.failure(new runtimeRunError(node.startPos, node.endPos, $"Failed to execute script \"{file}\"", parseResult.error.asString(), context));

value = result.register(new @class(formattedFileName, null, parseResult.node, new string[0]).setPosition(node.startPos, node.endPos).setContext(context).execute(new item[0]));
if (result.shouldReturn()) return result;
Expand Down

0 comments on commit ad337a4

Please sign in to comment.