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); }
private double ConvertToDouble(string str) { double value; bool result; //string sPattern = "^[a-zE0-9\\.\\+\\-]*$"; //if (System.Text.RegularExpressions.Regex.IsMatch(str, sPattern)) // result = true; //else // result = false; result = Double.TryParse(str, out value); if (result == true) { return(value); } str = IdentificatorsTable.Find(x => x.Name == str).Value; result = Double.TryParse(str, out value); return(value); }
private bool IsOperand(string element) { bool result = IdentificatorsTable.Exists(x => x.Name == element); if (result == true) { stack.Push(element); return(true); } result = LabelsTable.Exists(x => x.Name == element); if (result == true) { stack.Push(element); return(true); } double value; result = Double.TryParse(element, out value); if (result == true) { stack.Push(element); return(true); } bool value2; result = Boolean.TryParse(element, out value2); if (result == true) { stack.Push(element); return(true); } return(false); }
private void Assignment(string str, double value) { int index = IdentificatorsTable.IndexOf(IdentificatorsTable.Find(x => x.Name == str)); IdentificatorsTable[index].Value = value.ToString(); }