• Non ci sono risultati.

Laurea Magistrale in INFORMATICA Principi di Linguaggi di Programmazione Compilatori

N/A
N/A
Protected

Academic year: 2021

Condividi "Laurea Magistrale in INFORMATICA Principi di Linguaggi di Programmazione Compilatori"

Copied!
1
0
0

Testo completo

(1)

Laurea Magistrale in INFORMATICA Principi di Linguaggi di Programmazione

Compilatori

prof. M. Bellia Appello III - june 4th, 2013

(Timing: 2 hours – Grading: (pts n-m) is the score range to be obtained in each exercise)

Exercise 1. (pts 3 – 5) Let E≡ a (a* | b*) b be a regular expression.

(a) Give the dotted automaton of E (show the computation and the set od items of each state);

(b) By using the minimization algorithm, prove the minimality of the automaton that has been obtained in (a).

Exercise 2. (pts 5 - 10)

(a) Compute the Canonical Collection, Coll(1), of the LR(1) parser of the grammar G below:

S::= aSS | Sb | c

(b) Give the Parsing Table of the LALR(1) parser of G

(c) Show the behaviour of the shift/reduce automaton during the analysis of: acacbc.

Exercise 3. (pts 7 - 15) Let G be an LR grammar for Boolean expressions with disjunction, _or_, negation, not_, conditional, _?_:_, grouping, variables and the literals true, e false. All the operators have left associativity and precedence as follow: ? > not > or.

(a) Define G and show that it recognize the expression: x or not y ? not not y : z

(b) Give an oblivious, ascendant, translation scheme for the generation of 3AC code with loc as the invariant.

(c) Give an oblivious, ascendant, translation scheme for the generation of 3AC code with target- uncomplete statement lists (short-circuit)

(d) Apply the scheme in (b) in order to provide the code generation of the expression:

x or not y ? not not y : z.

(e) Apply the scheme in (c) in order to provide the code generation of the expression:

x or not y ? not not y : z,

also showing the value of the list the two attributes of the root of the expression parse-tree.

Assume that the following operators and constants be available in 3AC: [or] for _or_, [not] for not_, #T for true and #F for false. Finally, assume the following association in symbol table: locx for x.loc, locy for y.loc, locz for z.loc.

Riferimenti

Documenti correlati

The results proved so far in this paper together with previously known results are enough to settle Problem 3 for transitive permutation groups of degree at most 7 with the exception

In [7], Gian Pietro Pirola proves that the generic Abelian variety of dimension greater than 2 does not contain hyperelliptic curve of any genus, where elliptic curves are consi-

Solution proposed by Roberto Tauraso, Dipartimento di Matematica, Universit`a di Roma “Tor Vergata”, via della Ricerca Scientifica, 00133 Roma,

Solution proposed by Roberto Tauraso, Dipartimento di Matematica, Universit`a di Roma “Tor Vergata”, via della Ricerca Scientifica, 00133 Roma,

[r]

Also, let ω be a primitive nth root

Leggi x e S=s1 s2...sn. Assegna true ad

● Can learn any Petri net without duplicate tasks and without more than one place with the same input and output tasks. ● New models formalism, called