← Indietro
Altro

Tema 040216

Altro di Formal Languages and Compilers per il corso di Computer Engineering presso Politecnico di Milano. Materiale proveniente dall’archivio storico Studwiz e classificato per la consultazione online.

Formal Languages and CompilersAltro

Informazioni sul documento

Cosa trovi in questo materiale

Altro di Formal Languages and Compilers per il corso di Computer Engineering presso Politecnico di Milano. Materiale proveniente dall’archivio storico Studwiz e classificato per la consultazione online.

Qualità dell’importazione: il testo è stato estratto direttamente dal documento originale.

Contenuti estratti dal documento

Passaggi rappresentativi riconosciuti nelle diverse parti del materiale. Il testo completo resta presente nella pagina per la ricerca, mentre l’anteprima compatta rende più semplice la lettura.

Pagina 1

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…

Anteprima

Prima pagina del documento.

Prima pagina: Tema 040216