A grammar is a formal description of the syntactic rules and constraints that determine how words or other symbols can be combined to form larger structures, such as sentences. Formal grammars can be used to describe both natural and artificial languages, and are classified into different groups depending on their degree of complexity.