26.04.2013 Views

Analisi sintattica

Analisi sintattica

Analisi sintattica

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Left-Factoring (fattorizzazione<br />

sinistra)<br />

Un parser top down deterministico richiede<br />

una grammatica left-factored.<br />

grammatica grammatica equivalente<br />

istr → if (expr ) istr else istr |<br />

if (expr) istr<br />

Left-Factoring (cont.)<br />

In generale,<br />

A → αβ1 | αβ2 dove α∈(V∪T)* - {ε}, β1∈ (V∪T)* - {ε}, β2∈ (V∪T)* -<br />

{ε}<br />

e β1≠. Noi possiamo riscrivere la grammatica come segue<br />

A → αA ’<br />

A’ →β 1 | β 2<br />

16

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!