0% found this document useful (0 votes)
4 views1 page

Tutorial 1 Compiler

The document is a tutorial for Compiler Design from Jamia Hamdard's Department of Computer Science & Engineering. It contains exercises on eliminating left recursion, left-factoring grammars, and deriving strings using leftmost and rightmost derivations. Specific grammar examples and questions are provided for students to solve.

Uploaded by

Ruddraksh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Tutorial 1 Compiler

The document is a tutorial for Compiler Design from Jamia Hamdard's Department of Computer Science & Engineering. It contains exercises on eliminating left recursion, left-factoring grammars, and deriving strings using leftmost and rightmost derivations. Specific grammar examples and questions are provided for students to solve.

Uploaded by

Ruddraksh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

JAMIA HAMDARD

Department of Computer Science & Engineering


School of Engineering Sciences & Technology

Tutorial 1- Compiler Design

Question 1. Eliminate left recursion from the following grammar:


S→Sa|bS|b

Question 2. Eliminate left recursion from the following grammar:


exp→ exp addop term | term
addop→ + | -
term → term mulop factor | factor
mulop → *
factor → (exp) | number

Question 3. Left-factor the following grammar:


S → if E then S else S
S → if E then S
S → other
Question 4. For the grammar:
E→E+T|T
T→T*F|F
F → ( E ) | id
Write the leftmost derivation & rightmost derivation of the string id + id * id.

Question 5. From the grammar below S -> SS+ | SS* | a derive the string aa+a* using both
leftmost derivation & rightmost derivation.

You might also like