A lattice regularization of chiral gauge theories