- Fix another calculation bug

This commit is contained in:
Stone_Red
2022-01-11 22:50:45 +01:00
parent 2522868379
commit 719db0f74b
2 changed files with 4 additions and 4 deletions
@@ -15,7 +15,7 @@ namespace YesNt.Interpreter.Statements
[Statement("!calc", SearchMode.EndOfLine, SpaceAround.Start, ConsoleColor.DarkYellow, Priority = Priority.High, ExecuteInSearchMode = true)]
public void Calculate(string args)
{
MatchCollection matches = Regex.Matches(args, @"((\)?)+(\(?)+[0-9]+(((\s?)+(\)?)(\s?)+\+(\s?)+(\(?)+(\s?)+|(\s?)+(\)?)(\s?)+\-(\s?)+(\(?)+(\s?)+|(\s?)+(\)?)(\s?)+\*(\s?)+(\(?)+(\s?)+|(\s?)+(\)?)(\s?)+\/(\s?)+(\(?)+(\s?)+)|[,.])(?=[0-9])+)+[0-9]+(\)?)+");
MatchCollection matches = Regex.Matches(args.FromSaveString(), @"((\)?)+(\(?)+[0-9]+(((\s?)+(\)?)(\s?)+\+(\s?)+(\(?)+(\s?)+|(\s?)+(\)?)(\s?)+\-(\s?)+(\(?)+(\s?)+|(\s?)+(\)?)(\s?)+\*(\s?)+(\(?)+(\s?)+|(\s?)+(\)?)(\s?)+\/(\s?)+(\(?)+(\s?)+)|[,.])(?=[0-9])+)+[0-9]+(\)?)+");
for (int i = 0; i < matches.Count; i++)
{
@@ -25,7 +25,7 @@ namespace YesNt.Interpreter.Statements
RuntimeInfo.Exit("Invalid operation", true);
return;
}
args = args.Replace(matches[0].Value, res);
args = args.FromSaveString().Replace(matches[0].Value, res);
}
RuntimeInfo.CurrentLine = args;
+2 -2
View File
@@ -74,8 +74,6 @@ namespace YesNt.Interpreter.Utilities
return part1 < part2;
}
return null;
}
@@ -86,6 +84,8 @@ namespace YesNt.Interpreter.Utilities
return null;
}
input = input.FromSaveString();
MatchCollection matches = Regex.Matches(input, @"\(([^()]+)\)");
while (matches.Count > 0)
{