Back
Other

Tema 300916

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 30/09/2016 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 30/09/2016 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 30/09/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 merge operator. The merge operator is a ternary operator, having precedence lower than all the operators, save for the assignment one. The syntax of the merge operator is the following: the expression involving it starts with themerge keyword followed by the three operands, separated by commas. The result of the expression containing the merge operator coincides with its first operand, if its third operand equals one, while it coincides with the second operand if the third one equals zero. Note that the result of any expression, including constant ones must be admissible as an operand of the merge operator. The implementation must handle properly constant folding. The following code provides an example of the syntax of the said operator. 1 int a,b,c; 2 3 a=7; 4 b=2; 5 c = merge a,b,a>b; 6 write(c); /* this will print 7 */ 7 8 c = merge 2,3,0; 9 write(c); /* this will print 3 */ 1Time 60’. Textbooks and notes can be used. Pencil writing…

Preview

First page of the document.

First page: Tema 300916