Slide 2.3: The Chomsky hierarchy (cont.)
Slide 2.5: Context-free grammars
Home

Context-Free Grammars vs Regular Grammars


A regular grammar of natural numbers could be
   <number> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
             |  0<number> | 1<number> | 2<number>
             |  3<number> | 4<number> | 5<number>
             |  6<number> | 7<number> | 8<number>
             |  9<number>
A context-free grammar of simple arithmetic expressions could be
   <E> ::= <E> + <T> | <E>  <T> | <T>
   <T> ::= <T> * <F> | <T> / <F> | <F>
   <F> ::= ( <E> ) | <number>
The Chmosky hierarchy shows every regular set is a context-free language.

Why Using Regular Grammars When to Use Regular Grammars and Context-Free Grammars