Advertisement
MaksNew

operand.cs

Oct 7th, 2021
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.28 KB | None | 0 0
  1. using System.Text.RegularExpressions;
  2. using System.Collections.Generic;
  3.  
  4. namespace MH
  5. {
  6.     static class Operands
  7.     {
  8.         public static List<Operator> operands = new List<Operator>();
  9.         private static Regex mainRegex = new Regex(@"[\s*](\w+)[\s*;]="); //original only this one
  10.         private static Regex newMainRegex = new Regex(@"[\s*](\w+)[\s*;]=");
  11.         public static void Add(string text)
  12.         {
  13.             string buf;
  14.             bool isNotFind;
  15.             int j;
  16.             MatchCollection mcol = mainRegex.Matches(text);
  17.             for (int i = 0; i < mcol.Count; i++)
  18.             {
  19.                 buf = mcol[i].Value.Trim(new char[] { ' ', '=' });
  20.                 j = 0;
  21.                 isNotFind = true;
  22.                 while ((j < operands.Count) && isNotFind)
  23.                 {
  24.                     if (buf == operands[j].value)
  25.                         isNotFind = false;
  26.                     j++;
  27.                 }
  28.                 if (isNotFind)
  29.                 {
  30.                     operands.Add(new Operator(buf, @"[\( *\+{2}\-{2}]" + @buf + @"[*;\+{ 2}\-{ 2}\)\.]"));
  31.                     operands[operands.Count - 1].count = (ushort)operands[operands.Count - 1].regex.Matches(text).Count;
  32.                 }
  33.             }
  34.         }
  35.     }
  36. }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement