Document information
- University
- Politecnico di Milano
- Degree programme
- Computer Engineering
- Subject
- Formal Languages and Compilers
- Academic year
- 2015-2016
- Classification
- Other study material
- Original format
- Text
- Searchable text
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, Morzenti Written exam1: laboratory question 04/02/2016 SURNAME: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . NAME: . . . . . .
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, Morzenti Written exam1: laboratory question 04/02/2016 SURNAME: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . NAME: . . . . . .
Import quality: text was extracted directly from the original 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.
Formal Languages and Compilers Proff. Breveglieri, Morzenti Written exam1: laboratory question 04/02/2016 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 the Lance language with the sum- out of-as construct. This construct allows to iterate the computation of the expression specified after the as keyword over pairs of contiguous elements of a given array. The name of the array is specified after the out of keywords, while the name taken by the variables in the expression to be computed is specified right after the sum keyword. The results should be accumulated via addition in a scalar variable placed as the left hand side of the assign statement, of which the sum-out of-as construct constitutes the right hand side. An example is provided in the following code snippet int i,j,r,v[4]; v[0]=1; v[1]=4; v[2]=5; v[3]=6; r = sum i,j out of v as i+j*2; /* r = 1+4 *2 + 4+5 *2 + 5+6 *2 */ r = sum i,j out of v as 3*2-1; /* r = 5 + 5 + 5 */ In case the variable specified after theout of keywords is not an array, the modified compiler should report a compile-time error, in any fashion preferred by the implementor. The semantic of the construct does…
First page of the document.