top of page
  • Writer's pictureLaila Alahaideb

CS445-Compilers Cours(Exercises!)

Here I will attach some Lectures Exercise:


1-Lexical Analyzer CHAPTER 03 (PART 02) Exercise:

  • Describe the language expressed by: a * (b|c) b

  • Draw the NFA of the given language above using Thompson construction rules

  • Then, convert your NFA into DFA

Here you go:

Laila M AL-Ahaideb CS-445 -371
.pdf
Download PDF • 181KB

--


2-Lexical Analyzer CHAPTER 03 (PART 03) Exercise:

Draw the syntax tree of the following regular expressions

◦ a * (b | c)

◦ a (b | c) d


Here you go:

*I did some extra exercise on it: I define all their followpos, firstpos, and lastpos, then I draw the final DFA states


Laila M AL-Ahaideb(2) CS-445 -371
.pdf
Download PDF • 474KB

--


3-Syntax Parser CHAPTER 04 (PART 02) Exercise:


Derive at least one string from the shown language grammars below, as they specified in CFG ◦ L(G1 ) = {S, {S->A, A->aa}, {S,A}, {a}}

◦ L(G2 ) = {S, {S->*AB, A->aa, B->bb}, {S, A, B}, {a,b}}

◦ L(G3 ) = {S, {S->+A, A->Bb, A->aa}, {S, A, B}, {a,b}}

And:

Derive the string “aabbabba” for the leftmost derivation (LL) and rightmost derivation (LR) using the following context-free grammar L(G)

◦ S → aB | bA

◦ A → a | aS | bAA

◦ B → b | bS | aBB

And :

Consider the following grammar and eliminate left recursion for the two problems below

A → ABd / Aa / a

B → Be / b

----

E → E + E / E x E / a


Here you go:

Exercise 3 -Laila M AL-Ahaideb (371)
.pdf
Download PDF • 206KB

--


1 view0 comments

Recent Posts

See All
bottom of page