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

Assignment 4 ACD

This document contains 3 questions regarding automata and compiler design. Question 1 involves analyzing a context-free grammar to describe the language and determine if it is ambiguous. Question 2 involves constructing the SLR and LALR parsing tables for a non-SLR grammar and identifying conflicts. Question 3 involves analyzing an SLR parser automaton state diagram for a grammar and providing example strings where SLR/CLR and CLR/LALR parsers would behave differently.

Uploaded by

Shipra Mishra
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)
226 views1 page

Assignment 4 ACD

This document contains 3 questions regarding automata and compiler design. Question 1 involves analyzing a context-free grammar to describe the language and determine if it is ambiguous. Question 2 involves constructing the SLR and LALR parsing tables for a non-SLR grammar and identifying conflicts. Question 3 involves analyzing an SLR parser automaton state diagram for a grammar and providing example strings where SLR/CLR and CLR/LALR parsers would behave differently.

Uploaded by

Shipra Mishra
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
You are on page 1/ 1

Assignment 4

Automata and Compiler Design

Q1. Consider the context-free grammar where *, +, and a are the terminals.

SS S S S + a

a. Describe the language described by this grammar.


b. Is this grammar ambiguous? Explain your answer.

Q2. Consider the following grammar which is not SLR, i.e. the SLR parsing table will have
conflicts:
SM a
Sb M c
Sd c
Sb d a
Md

i. Construct the SLR parse table and answer the following:

a. How many conflicts are there in the resulting parsing table?


b. Show each pair of items that cause a conflict.
c. What are the viable prefixes for the conflicting states.
d. Explain in a clear language the reason behind each of the conflicts.

ii. Construct the LALR parse table

Q3. For the grammar

Sid[ E ] := E
EE + T T
TT F F
F( E ) id

answer the following questions:

a. In the automaton for the SLR parser, there is a state with a self-loop. Identify the state
through all the viable prefixes that takes the automaton to this state. You may represent
the set of viable prefixes by regular expressions over the grammar symbols.
b. Show an example string for which the SLR and CLR parsers for the grammar behave
differently and, in not more than five lines, explain the difference.
c. Show an example string for which the CLR and LALR parsers for the grammar behave
differently and, in not more than five lines, clearly explain the difference.

You might also like