public static void EnsureExpectedSymbol(this Token value, IOperationFactory operationFactory) { if (value == null) { throw new ArgumentNullException(nameof(value)); } if (operationFactory == null) { throw new ArgumentNullException(nameof(operationFactory)); } var expectedSymbols = new[] { Symbols.Eof, Symbols.RightBracket }; var symbol = value.Symbols.First(); if (!expectedSymbols.Contains(symbol) && !operationFactory.IsSupportedOperation(symbol)) { throw new ExpressionParseException($"Unexpected symbol: {value}"); } }