From 719db0f74b53422d82f0043832f39a53c8a50cfb Mon Sep 17 00:00:00 2001 From: Stone_Red <56473591+Stone-Red-Code@users.noreply.github.com> Date: Tue, 11 Jan 2022 22:50:45 +0100 Subject: [PATCH] - Fix another calculation bug --- YesNt.Interpreter/Statements/ProcessingStatements.cs | 4 ++-- YesNt.Interpreter/Utilities/Evaluator.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/YesNt.Interpreter/Statements/ProcessingStatements.cs b/YesNt.Interpreter/Statements/ProcessingStatements.cs index 00649f8..3396163 100644 --- a/YesNt.Interpreter/Statements/ProcessingStatements.cs +++ b/YesNt.Interpreter/Statements/ProcessingStatements.cs @@ -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; diff --git a/YesNt.Interpreter/Utilities/Evaluator.cs b/YesNt.Interpreter/Utilities/Evaluator.cs index c6dfccd..2c6c8e1 100644 --- a/YesNt.Interpreter/Utilities/Evaluator.cs +++ b/YesNt.Interpreter/Utilities/Evaluator.cs @@ -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) {