mirror of
https://github.com/Stone-Red-Code/YesNt-Interpreter.git
synced 2026-09-09 07:56:06 +02:00
Change logic of some changes
- `%rnd` now returns a random integer between `32767` and `int.MaxValue` - Fix syntax hyglighing problems when using comments - Remove the `mod` statement
This commit is contained in:
@@ -20,6 +20,13 @@ namespace YesNt.CodeEditor
|
|||||||
public void Write(string input)
|
public void Write(string input)
|
||||||
{
|
{
|
||||||
input = input.Replace("\0", string.Empty);
|
input = input.Replace("\0", string.Empty);
|
||||||
|
|
||||||
|
if (input.StartsWith('#'))
|
||||||
|
{
|
||||||
|
input = AddColorInformation(input, input, ConsoleColor.Gray, SearchMode.Exact);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
foreach (StatementInformation statement in statementInformation)
|
foreach (StatementInformation statement in statementInformation)
|
||||||
{
|
{
|
||||||
if (statement.IgnoreSyntaxHighlighting)
|
if (statement.IgnoreSyntaxHighlighting)
|
||||||
@@ -102,10 +109,6 @@ namespace YesNt.CodeEditor
|
|||||||
{
|
{
|
||||||
input = AddColorInformation(input, matches[i].Value, ConsoleColor.Blue, SearchMode.StartOfLine);
|
input = AddColorInformation(input, matches[i].Value, ConsoleColor.Blue, SearchMode.StartOfLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input.StartsWith('#'))
|
|
||||||
{
|
|
||||||
input = AddColorInformation(input, input, ConsoleColor.Gray, SearchMode.Exact);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (string part in input.Split("\0"))
|
foreach (string part in input.Split("\0"))
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ namespace YesNt.Interpreter.Statements
|
|||||||
|
|
||||||
while (args.Contains("%rnd "))
|
while (args.Contains("%rnd "))
|
||||||
{
|
{
|
||||||
args = args.ReplaceFirstOccurrence("%rnd ", $"{random.Next() % 2} ");
|
args = args.ReplaceFirstOccurrence("%rnd ", $"{random.Next(32767, int.MaxValue)} ");
|
||||||
}
|
}
|
||||||
|
|
||||||
RuntimeInfo.CurrentLine = args.TrimEnd();
|
RuntimeInfo.CurrentLine = args.TrimEnd();
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ namespace YesNt.Interpreter.Statements
|
|||||||
|
|
||||||
for (int i = 0; i < lines.Length; i++)
|
for (int i = 0; i < lines.Length; i++)
|
||||||
{
|
{
|
||||||
RuntimeInfo.Lines.Add(new Line(lines[i], Path.GetFileName(path), i));
|
RuntimeInfo.Lines.Insert(RuntimeInfo.LineNumber + i, new Line(lines[i], Path.GetFileName(path), i));
|
||||||
}
|
}
|
||||||
RuntimeInfo.LineNumber--;
|
RuntimeInfo.LineNumber--;
|
||||||
}
|
}
|
||||||
@@ -99,41 +99,5 @@ namespace YesNt.Interpreter.Statements
|
|||||||
RuntimeInfo.Exit($"Could not find file \"{path}\"", true);
|
RuntimeInfo.Exit($"Could not find file \"{path}\"", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Statement("mod", SearchMode.StartOfLine, SpaceAround.End, ConsoleColor.DarkYellow, Priority = Priority.VeryLow, Seperator = "|")]
|
|
||||||
public void GetModulo(string args)
|
|
||||||
{
|
|
||||||
string[] parts = args.Split('|');
|
|
||||||
if (parts.Length != 2)
|
|
||||||
{
|
|
||||||
RuntimeInfo.Exit("Invalid syntax", true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
string[] nums = parts[1].Split(',');
|
|
||||||
if (nums.Length != 2)
|
|
||||||
{
|
|
||||||
RuntimeInfo.Exit("Invalid arguments", true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
string variableName = parts[0].Trim();
|
|
||||||
|
|
||||||
if (ulong.TryParse(nums[0], out ulong num1) && ulong.TryParse(nums[1], out ulong num2))
|
|
||||||
{
|
|
||||||
if (RuntimeInfo.Variables.ContainsKey(variableName))
|
|
||||||
{
|
|
||||||
RuntimeInfo.Variables[variableName] = (num1 % num2).ToString();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
RuntimeInfo.Variables.Add(variableName, (num1 % num2).ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
RuntimeInfo.Exit("Invalid arguments", true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user