private void Hold(SymbolToken val) { _heldInput.Add(val); if (val.Type == SymbolType.OpenBracket) { _parentheses++; } if (val.Type == SymbolType.CloseBracket) { _parentheses--; } if (_parentheses == 0) { // remove parentheses var tv = new TokenValidater(_heldInput.GetRange(1, _heldInput.Count - 2)); // add back in original parentheses Output(_heldInput[0]); Output(tv.PumpAll()); Output(_heldInput[_heldInput.Count - 1]); _heldInput = new List <SymbolToken>(); _holdInput = false; } }
public static List <SymbolToken> Parse(string expression, VariableContext context) { var pipe1 = new StringToPrimitiveTokenPipe(expression, context); var pipe2 = new MatchAllParenthesesProcessor(pipe1); var pipe3 = new NegationProcessor(pipe2); var pipe4 = new RedundantParenthesesProcessor(pipe3); var pipe5 = new TokenValidater(pipe4); return(pipe5.PumpAll()); }