public void Interpret(string infix) { _stToLex = new StringToLexem(infix); while ((_lexems = _stToLex.ToLexems()).Count > 0 || _lexems.Any(x => x.LexemType == LexemType.EndOfExpr || x.LexemType == LexemType.Brace)) { if (_skipToCloseBrace) { int opennedBraces = 0; while (!_lexems.Any(x => x.LexemType == LexemType.Brace && x.Content.ToString() == "}" && opennedBraces == 0)) { if (_lexems.Any(x => x.LexemType == LexemType.Brace)) { var brace = _lexems.Single(x => x.LexemType == LexemType.Brace); if (brace.Content.ToString() == "{") { opennedBraces++; } else { opennedBraces--; } } _lexems = _stToLex.ToLexems(); } } Output.Clear(); ToRPN(); Stack.Clear(); Eval(); } }
public void Interpret(string infix) { _stToLex = new StringToLexem(infix); while ((_lexems = _stToLex.ToLexems()).Count > 0 || _lexems.Any(x => x.LexemType == LexemType.EndOfExpr || x.LexemType == LexemType.Brace)) { if (_skipToCloseBrace) { int opennedBraces = 0; while (!_lexems.Any(x => x.LexemType == LexemType.Brace && x.Content.ToString() == "}" && opennedBraces == 0)) { if (_lexems.Any(x => x.LexemType == LexemType.Brace)) { var brace = _lexems.Single(x => x.LexemType == LexemType.Brace); if (brace.Content.ToString() == "{") opennedBraces++; else opennedBraces--; } _lexems = _stToLex.ToLexems(); } } Output.Clear(); ToRPN(); Stack.Clear(); Eval(); } }