Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
9 views3 pages

Compiler Exercises

The summary analyzes the solved exercises by a student on formal languages and compilers. The student describes regular languages through regular expressions, provides state transition diagrams and derivations for grammars, and calculates FIRST and FOLLOW to analyze grammars in a predictive manner.
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)
9 views3 pages

Compiler Exercises

The summary analyzes the solved exercises by a student on formal languages and compilers. The student describes regular languages through regular expressions, provides state transition diagrams and derivations for grammars, and calculates FIRST and FOLLOW to analyze grammars in a predictive manner.
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/ 3

CENTRAL UNIVERSITY OF ECUADOR

SCHOOL OF ENGINEERING, PHYSICAL SCIENCES AND MATHEMATICS

COMPUTER ENGINEERING DEGREE

EXERCISES OF LANGUAGES AND COMPILERS

OLIVER SÁNCHEZ ESTRADA

EXERCISE 3.3.2

Describe the languages denoted by the following regular expressions:

a(a|b)*a

a string of a and b that starts with a and ends with a

EXERCISE 3.3.5

Write regular definitions for the following languages:

a. all strings of lowercase letters that contain the five vowels in order.

→∗( | ∗
) ( | )∗ ( | )∗ ( | )∗ ( | )∗

→[ ℎ ]
EXERCISE 3.4.1

Provide the state transition diagrams to recognize the same languages as


in each of the regular expressions in exercise 3.3.2.

e. (aa|bb)*((ab|ba)(aa|bb)*(ab|ba)(aa|bb)*)*

EXERCISE 4.2.2

Repeat exercise 4.2.1 for each of the following grammars and strings:

f. → | | ∈ with the chain

Provide a left derivation for the string







Provide a right derivation for the string






Provide a syntactic parse tree for the string.

Is the grammar ambiguous or not? Justify your answer.

The grammar is ambiguous since more than one derivation can be made, that is, from the left.
to the right, the same string is obtained.

Describe the language generated by this grammar.

The set of all strings of a's and b's with the same number of a's and b's.

EXERCISE 4.4.1

For each of the following grammars, devise predictive syntax analyzers and
show the parse tables. You can factor out the left or eliminate it.
left recursion of their grammars first.

a. The grammar of exercise 4.2.2 (a)

S → 0S1 | 01with the chain000111

Left factorization

S → 0A
A → S1|1
Eliminate left recursion

S → 0A
A → 0A1 | 1

Syntactic analysis table

Input symbol
Non-terminal symbol
0 1 $$
S S→0A
A A→0A1 1

EXERCISE 4.4.4

Calculate FIRST and FOLLOW for each of the grammars in exercise 4.2.2

f. → | | ∈ with the chain

primero (S) [a,b,ϵ]

next(s)

we use rule 3


( )→ ( )
( )( →
) ( )
We use the case (→) ( ) ( )

Next(S) = first(S) U next(S)

Next(s) = [a, b, $]

EXERCISE 4.5.1

For the grammarS → 0S1 | 01from exercise 4.2.2(a), indicate the handle in each of the
following right sentence forms.

a. 000111

Right sentence Mango Reduction


000111 01 S→01
00S11 0S1 →0S1
0S1 0S1 S→0S1

01

You might also like