Skip to content

Commit

Permalink
update to ev0.3.0.12 (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
Matto58 authored Feb 16, 2023
1 parent e8b2494 commit d9fc6fc
Show file tree
Hide file tree
Showing 11 changed files with 450 additions and 369 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ Scripting programming language

| Version | Engine version | Engine revision | .NET version | Release date (supported) | Supported until |
|:-:|:-:|:-:|:-:|:-:|:-:|
| v1 | v0.2.2 | 11 | 7.0 | 2023-01-24 (yes) | 2023-02-20 |
| v1 | v0.3.0 | 12 | 7.0 | 2023-02-16 (yes) | 2023-04-16 |
3 changes: 3 additions & 0 deletions examples/consttest.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
var $!constant=Constant variable
con.out nl $!constant
var $!constant=Changing variable # should error with code MTS-a (VarIsConst)
5 changes: 5 additions & 0 deletions examples/funcargs_test.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
func.start print $msg
con.out nl $msg
func.end

call print hi
5 changes: 5 additions & 0 deletions examples/return_test.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
func.start functionAsdf $text
return $text
func.end

con.out nl >functionAsdf/HelloWorld
15 changes: 13 additions & 2 deletions mts-build/InterLang.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public static string[] toInterLang(string[] lns, string fileName)
case "func.start":
try
{
oc.Add($"{i};FUNC:START,{ln[1]}");
oc.Add($"{i};FUNC:START,{string.Join(",", ln[1..])}");
}
catch (IndexOutOfRangeException)
{
Expand All @@ -149,7 +149,18 @@ public static string[] toInterLang(string[] lns, string fileName)
case "func.call" or "call":
try
{
oc.Add($"{i};FUNC:CALL,{ln[1]}");
oc.Add($"{i};FUNC:CALL,{string.Join(",", ln[1..])}");
}
catch (IndexOutOfRangeException)
{
oc.Add($"{i};INTERNAL:ERR_THROW,TooLittleArgs,{fileName},{i},{ln.Length}");
goto end;
}
break;
case "return" or "func.return":
try
{
oc.Add($"{i};FUNC:RETURN,{ln[1]}");
}
catch (IndexOutOfRangeException)
{
Expand Down
94 changes: 49 additions & 45 deletions mts-build/Program.cs
Original file line number Diff line number Diff line change
@@ -1,53 +1,57 @@
using Mattodev.MattoScript.Engine;
using System.Diagnostics;
using Mattodev.MattoScript.Engine;
using static Mattodev.MattoScript.Engine.CoreEng;

namespace Mattodev.MattoScript.Builder
{
internal class Program
{
static int Main(string[] args)
{
MTSConsole c = new();
Console.Title = c.title;
internal class Program
{
static int Main(string[] args)
{
MTSConsole c = new();
Console.Title = c.title;

if (args.Length == 0)
{
MTSError.TooLittleArgs err = new();
err.message += args.Length;
err.ThrowErr("<build>", -1, ref c);
c.exitCode = err.code;
goto end;
}
string[] code;
try
{
code = File.ReadAllLines(args[0]);
}
catch (FileNotFoundException)
{
MTSError.FileNotFound err = new();
err.message += args[0];
err.ThrowErr("<build>", -1, ref c);
c.exitCode = err.code;
goto end;
}
catch (Exception e)
{
MTSError.InternalError err = new(e);
err.message += $"\n\t{e.Message}";
err.ThrowErr("<build>", -1, ref c);
c.exitCode = err.code;
goto end;
}
Stopwatch s = new();
s.Start();
if (args.Length == 0)
{
MTSError.TooLittleArgs err = new();
err.message += args.Length;
err.ThrowErr("<build>", -1, ref c);
c.exitCode = err.code;
goto end;
}
string[] code;
try
{
code = File.ReadAllLines(args[0]);
}
catch (FileNotFoundException)
{
MTSError.FileNotFound err = new();
err.message += args[0];
err.ThrowErr("<build>", -1, ref c);
c.exitCode = err.code;
goto end;
}
catch (Exception e)
{
MTSError.InternalError err = new(e);
err.message += $"\n\t{e.Message}";
err.ThrowErr("<build>", -1, ref c);
c.exitCode = err.code;
goto end;
}

c = Runner.runFromCode(code, args[0]);
Runner.runFromCode(code, args[0], ref c);

end:
c.disp();
Console.ForegroundColor = ConsoleColor.DarkGray;
Console.WriteLine($"(exit code {c.exitCode})");
Console.ResetColor();
return c.exitCode;
}
}
end:
s.Stop();
c.disp();
Console.ForegroundColor = ConsoleColor.DarkGray;
Console.WriteLine($"(exit code {c.exitCode}, execution time {s.ElapsedMilliseconds}ms)");
Console.ResetColor();
return c.exitCode;
}
}
}
Loading

0 comments on commit d9fc6fc

Please sign in to comment.