Syntax is a form of grammar. It is concerned primarily with word order in a sentence and with the agreement of words when they are used together. So it is, in a sense, acting as a kind of ‘ police officer ’ for the way in which sentences are constructed.
Semantics is the aspect of language function that relates to understanding the meanings of words, phrases and sentences, and using words appropriately when we speak.
Pragmatics is the area of language function that embraces the use of language in social contexts (knowing what to say, how to say it, and when to say it - and how to "be" with other people). Depending on the circumstances and the posture of the tone speaker.