In formal language theory, a grammar (when the context isn't
given, often called a formal grammar for clarity) is a set of
production rules for strings in a formal language. The rules
describe how to form strings from the language's alphabet that
are valid according to the language's syntax. A grammar does not
describe the meaning of the strings or what can be done with
them in whatever context—only their form. Formal language
theory, the discipline which studies formal grammars and
languages, is a branch of applied mathematics. Its applications
are found in theoretical computer science, theoretical
linguistics, formal semantics, mathematical logic, and other
areas. A formal grammar is a set of rules for rewriting strings,
along with a "start symbol" from which rewriting starts.
Therefore, a grammar is usually thought of as a language
generator. However, it can also sometimes be used as the basis
for a "recognizer"—a function in computing that determines
whether a given string belongs to the language or is gr