A contex free grammar, CFG, (synonyms: Backus-Naur Firm of BNF) is a common notation for specifying the syntax of a languages
For example, an "IF-ELSE" statement in c-language has the form
IF
(Expr) stmt
ELSE stmt
In other words, it is the concatenation of:
The syntax of an 'IF-ELSE' statement can be specified by the following
'production rule' in the CFG.
stmt → IF (Expr) stmt ELSE stmt
The arrow ( → ) is read as "can have the form".
A context-free grammar (CFG) has four components:
Multiple production with the same nonterminal on the left like:
list → + digit
list → - digit
list →
may be grouped together separated by vertical bars, like:
list → list + digit | list - digit | digit