← Indietro
Altro

Tema 040915

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, Crespi Reghizzi, Morzenti Written exam1: laboratory question 04/09/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 the operator brange. The semantic of this operation is to extract any bit-sequence specified by the two indices lo and hi that respectively indicate the index of the lowest and the highest bits to be extracted during the operation. Note that the least significant bit is indexed with 0, while the most significant bit is indexed with 31. Indeed if it does not hold that lo≤ hi∧ lo≥ 0∧ hi≤ 31, the result must be zero. An example is provided in the following. int v, r; // let assume that v = 11584 r = 42 + brange(v, 2, 12); // r = 42 + 848 = 890 write(r); The operator syntax is brange(value, lo, hi) . In the example, brange(v, 2, 12) extracts the bits in the range [2 , 12] from the value v. Assuming that v = 11584 we have that 12 2 0 v = 0 0 1 0 1 1 0 1 0 1 0 0 0 0 0 0 brange(v, 2, 12) = 0 0 0 0 0 0 1 1 0 1 0 1 0 0 0 0 10 0 bits bits Note that brange operator can take a generic expression for any of its operands. 1Time 60’. Textbooks and notes can be…

Anteprima

Prima pagina del documento.

Prima pagina: Tema 040915