A grammar in which the left-hand side of each production is a single nonterminal, i.e. productions have the form
(read as ‘rewrite
A as α’), where α is a string of terminals and/or nonterminals. These productions apply irrespective of the context of
A. For brevity one writes
to indicate the separate productions
As an example, the following generates a simple class of arithmetic expressions typified by (
a +
b) ×
c:
The BNF notation used in defining the syntax of programming languages is simply a context-free grammar.
Context-free grammars are a class of phrase-structure grammar (PSG). GPSG represents the principal attempt at constructing context-free grammars capable of characterizing the grammars of natural language.
Compare context-sensitive grammar.