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, Crespi Reghizzi, Morzenti Written exam1: laboratory question 04/09/2015 SURNAME: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
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 04/09/2015 SURNAME: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
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, 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…
First page of the document.