Canonical formulation of nonholonomic constrained systems