In parsing, grammar refers to a set of rules that define the structure of a programming language or natural language. It specifies how different elements of the language, such as keywords, operators, and variables, can be combined to form valid statements and expressions.