Sie sind auf Seite 1von 4

2CMP – SCE

Languages and Translators - Compilation

Objectives
COMPILATION

Automata
Lexical analysis
Parser

Version 1.0
Last update: 04/15/2018
Use: Students/Staff
Author: Cyril-Alexandre Pachon
2CMP – SCE
Languages and Translators - Compilation

Table of contents

1 PREAMBLE: GENERAL INSTRUCTIONS ................................................................................................................ 3


2 EXERCISE 1: QUESTIONS (4 POINTS) .................................................................................................................. 3
3 EXERCISE 2: AUTOMATA/EXPRESSIONS (6 POINTS) ............................................................................................ 3
4 EXERCISE 3: GRAMMARS (6 POINTS) .................................................................................................................. 4
5 EXERCISE 4: THE LEX/YACC ANALYSIS (4 POINTS) ............................................................................................... 4

Page 2 sur 4
© SUPINFO International University – http://www.supinfo.com
2CMP – SCE
Languages and Translators - Compilation

1 PREAMBLE: GENERAL INSTRUCTIONS


Your response should be in a .pdf file.

You cannot use your courses and internet.


You can use a C compiler (Gcc tool), Flex (Lex tool), Yacc (Bison tool) and a graph editor (Yed tool).
If you do not follow the instructions, you will be adjourned for this certification.

To become certified, you need to get the average in each of the 4 parts.

2 EXERCISE 1: QUESTIONS (4 POINTS)


Question 1.1: Write the rational language definition. Give an example. How to indicate that two rational languages L1
and L2 are equivalent?

Question 1.2: There is advantages to make the compilation with a typed language, which? Give 4 advantages.

Question 1.3: Define the notions of treatment to preprocessor, compilation, assembling and link editing. Give the file
type produces to each treatment.

Question 1.4: Write the derivation tree definition. Why do we use it?

3 EXERCISE 2: AUTOMATA/EXPRESSIONS (6 POINTS)


n n
Question 2.1: With the alphabet  = {u, v} and the language L = {u v | where n is integers}, draw the deterministic
pushdown automaton of the L language.

+ +
Question 2.2: Draw the deterministic automaton of the following expression: (v(b)* |(f|d)|a(b) )|ad(g) d(g)*

Question 2.3: Write the regular expression for the following automaton:

Page 3 sur 4
© SUPINFO International University – http://www.supinfo.com
2CMP – SCE
Languages and Translators - Compilation

4 EXERCISE 3: GRAMMARS (6 POINTS)


Question 3.1: Let the G grammar = (S  aX | abZ | b, X  S | x, T t | Z  S | z | t).
1. The locution t = ababzab, belongs it to the G language? Write a reduction tree.
2. The locution u = aaabaaabxaat, belongs it to the G language? Write a derivation tree.

Question 3.2: Write the G grammar in the Chomsky Normal Form: G = (SbA | aB, AbAA | aS | a, BaBB | bS | b).

5 EXERCISE 4: THE LEX/YACC ANALYSIS (4 POINTS)


We have the G grammar:

S  A | "e" | S"t""t""r" | B
A  A"a"
B  "b"B | "i""h"

Question 4: Write the lexical analyzer (Lex) and parser (Yacc), using the G grammar.

Page 4 sur 4
© SUPINFO International University – http://www.supinfo.com

Das könnte Ihnen auch gefallen