Professional Documents
Culture Documents
Assignment 1 ch2-1
Assignment 1 ch2-1
1. S -> 0 S 1 | 0 1
2. S -> + S S | - S S | a
3. S -> S ( S ) S | ε
4. S -> a S b S | b S a S | ε
5. S -> a | S + S | S S | S * | ( S )
Q3 (exercise 2.2.1and 2.2.3) Construct unambiguous context-free grammars for each of the
following languages. In each case show that your grammar is correct.
Q5 (exercise 2.4.1) Construct recursive-descent parsers, starting with the following grammars:
1. S -> + S S | - S S | a
2. S -> S ( S ) S | ε
3. S -> 0 S 1 | 0 1