CError CNullBinaryOperationValidator::Validate(C_OPERATION_SYNTAX& syntax, C_CONTEXT& context) const
{
  CError result;
  auto operationType = COperationTypeEnum(syntax.GetOperationType()).ToString();

  if (syntax.GetLeftOperandID() == NONE_ID)
  {
    result.SetSource(EErrorSource::Producing);
    result.SetLiveLine(syntax.GetLiveLine());
    result.SetDescription(CWStringTemplate(L"Left operand of operation:[%x] is invalid").Format(operationType));
  }

  if (syntax.GetRightOperandID() == NONE_ID)
  {
    result.SetSource(EErrorSource::Producing);
    result.SetLiveLine(syntax.GetLiveLine());
    result.SetDescription(CWStringTemplate(L"Right operand of operation:[%x] is invalid").Format(operationType));
  }

  return move(result);
}
CError CUndefinedReferenceValidator::Validate(C_FUNCTION_SYNTAX& syntax, C_CONTEXT& context) const
{
  CError result;

  if (!ValidateReference(syntax.GetLiveNamespace(), syntax.GetName(), EIdentifierType::Function, context))
  {
    result.SetSource(EErrorSource::Producing);
    result.SetLiveLine(syntax.GetLiveLine());
    result.SetDescription(CWStringTemplate(L"Funtion:'%x' has not been defined").Format(syntax.GetName()));
  }

  return move(result);
}
CError CDuplicationValidator::Validate(C_DEFINE_FUNCTION_SYNTAX& syntax, C_CONTEXT& context) const
{
  CError result;

  if (context.HasDefinedIdentifier(syntax.GetLiveNamespace(), syntax.GetName(), EIdentifierType::Function))
  {
    auto description = CWStringTemplate(L"Duplicated definition of function:'%x.%x'").Format(syntax.GetLiveNamespace().ToString(), syntax.GetName());

    result.SetSource(EErrorSource::Producing);
    result.SetLiveLine(syntax.GetLiveLine());
    result.SetDescription(description);
  }

  return move(result);
}