0% found this document useful (0 votes)
46 views

Compiler Design: Assignment: S S L L A L S

1) The document provides instructions for several compiler design assignments involving regular expressions, transition diagrams, grammars, ambiguity, parsing, nullable/FIRST/FOLLOW sets. 2) It asks to write regular expressions for number strings with specific values, construct transition diagrams with given alphabets and languages, write grammars for languages matching As and Bs, show ambiguity in a given grammar, and calculate parsing sets. 3) It also provides context-free grammars and asks to generate/parse strings, and construct leftmost and rightmost derivations.

Uploaded by

Fitawu Tekola
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views

Compiler Design: Assignment: S S L L A L S

1) The document provides instructions for several compiler design assignments involving regular expressions, transition diagrams, grammars, ambiguity, parsing, nullable/FIRST/FOLLOW sets. 2) It asks to write regular expressions for number strings with specific values, construct transition diagrams with given alphabets and languages, write grammars for languages matching As and Bs, show ambiguity in a given grammar, and calculate parsing sets. 3) It also provides context-free grammars and asks to generate/parse strings, and construct leftmost and rightmost derivations.

Uploaded by

Fitawu Tekola
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

Compiler Design: Assignment

1) In the following, a number-string is a non-empty sequence of decimal digits, i.e., something in the
language defined by the regular expression [0-9]+. The value of a number-string is the usual interpretation
of a number-string as an integer number. Note that leading zeroes are allowed. Make for each of the
following languages a regular expression that describes that language.
a) All number-strings that have the value 42.

b) All number-strings that do not have the value 42.

c) All number-strings that have a value that is strictly greater than 42.

2) Construct Transition diagrams for each of the following regular languages. In all cases the alphabet is
{a, b}.
a) The set of strings that has exactly 3 bs (and any number of as).

b) The set of strings where the number of bs is a multiple of 3 (and there can be any number of as).

3) Write a grammar for the language:


All sequences of as and bs that contain the same number of as and bs (in any order).

4) Show that the grammar


A → -A
A → A -id
A → id
is ambiguous by finding a string that has two different syntax trees.

5) Calculate Nullable, FIRST and FOLLOW for the nonterminals A and B in the grammar
A→ BAa
A→ε
B → bBc
B → AA
6) Consider the context-free grammar S  SS  | SS *| a

a) show that the string aa  a * can be generated by this grammar.

b) construct a parse tree for the string.

7) Consider the grammar

S  ( L )| a
L  L,S |S

a) What are the terminals, non- terminals and start symbol?


b) Find the parse tree for the following sentences
i) ( a, ( a, a )) ii) (a, ((a, a ), (a, a )))
c) Construct the left most derivation for each of the sentences in(b).
d) Construct the right most derivation for each of the sentences in(b).

You might also like