Back
Other

Tema 080715

University study material for Formal Languages and Compilers in the Computer Engineering degree programme at Politecnico di Milano. The document covers: Formal Languages and Compilers Proff. Breveglieri, Crespi Reghizzi, Morzenti Written exam1: laboratory question 08/07/2015 SURNAME: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Formal Languages and CompilersOther

Document information

What's included in this study material

University study material for Formal Languages and Compilers in the Computer Engineering degree programme at Politecnico di Milano. The document covers: Formal Languages and Compilers Proff. Breveglieri, Crespi Reghizzi, Morzenti Written exam1: laboratory question 08/07/2015 SURNAME: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Import quality: text was extracted directly from the original document.

Extracted content from the document

Representative passages recognised in different parts of the material. The full extracted text remains available to search, while this compact preview makes the page easier to read.

Page 1

Formal Languages and Compilers Proff. Breveglieri, Crespi Reghizzi, Morzenti Written exam1: laboratory question 08/07/2015 SURNAME: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . NAME: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Student ID:. . . . . . . . . . . . . . . . Course: ◦ Laurea Specialistica ◦ V. O. ◦ Laurea Triennale ◦ Other: . . . Instructor: ◦ Prof. Breveglieri ◦ Prof Morzenti The laboratory question must be answered taking into account the implementation of the Acse compiler given with the exam text. Modify the specification of the lexical analyser ( flex input) and the syntactic analyser (bison input) and any other source file required to extend theLance language with permutate construct for arrays. An example is provided in the following. int arr[10]; // arr = [ 10, 11, 12, 13, 14, 15 ] permutate( arr, q[ 4, 2, 0 ]p ); // arr = [ 12, 11, 14, 13, 10, 15 ] The permutation is expressed as constant vector of indices, i.e. integer constants, that must be interpred as source-destination indices pairs. For example the chain q[4, 2, 0]p: • element in position 4 of the input array goes into position 2 of the output array • element in position 2 of the input array goes into position 0 of the output array • element in position 0 of the input array goes into position 4 of the output array A graphical representation of the semantic is the following: 10 11 12 13 14 15 12 11 14 13 10 15 The permutation must be inplace, meaning that the input array is modified to obtain the output array without the need of a temporary array. Note that the vector of indices can be shorter or longer than the length of the array. Indeed…

Preview

First page of the document.

First page: Tema 080715