private bool DoIfInOutOperation(string element)
        {
            string[] ioOperation =
            {
                "read", "write"
            };

            // If element isn`t io operation returns false.
            bool result = ioOperation.Contains(element);

            if (result == false)
            {
                return(false);
            }

            string           operandName = stack.Pop();
            IdentificatorRow operand     = IdentificatorsTable.First(x => x.Name == operandName);

            switch (element)
            {
            case "read":
                Terminal.Read(ref operand);
                break;

            case "write":
                Terminal.Write(operand);
                break;
            }

            // If element is io operation returns true.
            return(true);
        }
        public static void Read(ref IdentificatorRow val)
        {
            Console.Write($"{val.Name}=");
            string str = Console.ReadLine();

            string sPattern = "^[a-zE0-9\\.\\+\\-]*$";

            if (System.Text.RegularExpressions.Regex.IsMatch(str, sPattern) != true)
            {
                throw new Exception("Error, недопустимий формат вводу");
            }
            val.Value = str;
        }
Ejemplo n.º 3
0
        private void GenerateRjTable(int index)
        {
            rTable.Add("r" + index);
            string           str   = rTable[rTable.Count - 1];
            IdentificatorRow idRow = new IdentificatorRow
            {
                Name  = str,
                Index = IdentificatorTable.Count - 1,
                Value = "0"
            };

            IdentificatorTable.Add(idRow);

            Polir.Add(new OutputRow()
            {
                Name = str,
                Id   = identificatorId
            });
            polirRow.Polir.Add(str);
            //AddToPolir(rTable[rTable.Count - 1]);
        }
 public static void Write(IdentificatorRow val)
 {
     Console.WriteLine($"{val.Name}={val.Value}");
 }