Syntax is an aspect of grammar. It primarily involves word order. In the sentence he gave John the book the order of the direct object (book) and the indirect object (John) is a matter of syntax but the transformation of the infinitive give to the past tense gave is not.