Back
Other

Tema 210217

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 and Morzenti Written exam1: laboratory question 21/02/2017 SURNAME: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . NAME: . . . .

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 and Morzenti Written exam1: laboratory question 21/02/2017 SURNAME: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . NAME: . . . .

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 and Morzenti Written exam1: laboratory question 21/02/2017 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 count- when-into construct. An instance of the count-when-into construct is provided in the following code snippet: int a,b; count { when (3){ write(2); }, when (b-5){ if(a+b==7){ b=b+1; } }, when (b<0){ } } into a; The count-when-into construct has the following semantics: the curly braces following the count keyword enclose a comma separated list of when statements which are executed in program order. Each when statement executes the contents enclosed in the curly braces in program order if and only if the expression enclosed in the round braces is true (i.e. different from zero). Finally, when the contents of the curly braces have been executed, the count-when-into statement stores the number of times a when statement has executed the content between his curly braces in the variable following the into keyword. The count-when-into statements may be arbitrarily nested; the statements enclosed between the curly braces of the when statement can be any…

Preview

First page of the document.

First page: Tema 210217