CFG $G$ is 4-tuple of:
$V = V_t \cup V_n$ is vocabulary
If $S \rightarrow^* \beta$, $\beta$ is a sentential form of $S$
Backus-Naur form (BNF):
code
font or underlineWe use REs for numbers, keywords, etc.
However, grammars are used for parsing (brackets, if-else, etc.)
Leftmost derivation: left-most nonterminal replaced at each step
Rightmost: respective
We can introduce extra non-terminals (and derivations) to ensure an appropriate order.