I do sure that grammar and syntax is two different thing in CS, e.gSyntax of Java language is defined by a context-free grammar.My question areWhat is different in definitions of grammar and syntax in CS?What is relation between them, can we describe it by using set theory?
Relation between syntax and grammar in CS
terminology;context free;formal grammars;programming languages;syntax
Your quote has the following operational meaning for syntax in the context of programming languages:The syntax of a programming language is the set of all syntactically valid programs.The syntax only describes what the valid programs look like; semantics gives them meaning  tells you how to execute them.The set of all valid programs is an example of a formal language; a formal language is just a collection of strings. There are many ways of describing formal languages. One of them is through formal grammars, which you can think of as a type of formula that describes a formal language. Context-free grammars are a restricted type of formal grammars. As such, they cannot describe all formal languages, but only context-free languages. (General grammars also describe only some of the formal languages; this is due to the fact that there are countably many grammars but uncountably many formal languages.) Summarizing:A grammar is one way to specify a formal language.Finally, let me mention that the set of syntactically valid Java programs actually cannot be described by a context-free grammar; only some features can be described. Context-free grammars cannot enforce, for example, that a variable not be defined twice in the same context. However, once we abstract away such details (for example, by replacing variable names with generic placeholders), the resulting set of syntactically valid Java programs does lend itself (perhaps) to being captured by a context-free grammar.Parsing (in our context) is the process of reading the source code of a Java program and constructing its parse tree, which is its structure as seen from the perspective of the context-free grammar. The parse tree captures the semantics of the program in a form amenable to further manipulation in the compilation process. Abstracting away details such as variable names and values of constants relegates this information into the form of parameters, but doesn't obstruct the control structure of the program.