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.

Parse Tree (Abstract Sintax Tree)<br />

I nodi non foglie dell’albero sintattico sono simboli non-terminal, le foglie simboli<br />

terminali.<br />

E ⇒ -E<br />

-<br />

-<br />

E<br />

E<br />

E<br />

E<br />

⇒ -(E) E<br />

⇒ -(E+E)<br />

- E<br />

( E )<br />

⇒ -(id+E) ⇒ -(id+id)<br />

( E )<br />

E +<br />

id<br />

E<br />

-<br />

E<br />

E<br />

( E )<br />

E +<br />

id<br />

E<br />

id<br />

-<br />

E<br />

( E )<br />

Un albero sintattico è una rappresentazione grafica di una derivazione.<br />

Per esempio partendo da Prog possiamo generate,<br />

aplicando ripetutamente le produzione le seguenti<br />

stringhe:<br />

Prog<br />

{ Seq }<br />

{ Seq ;Istr}<br />

Seq<br />

{Istr;Istr}<br />

{ id = Expr ;Istr}<br />

Seq Istr<br />

{ id = id ;Istr}<br />

{ id = id ; id = Expr }<br />

{ id = id ; id = Expr + id}<br />

{ id = id ; id = id + id}<br />

Istr<br />

E<br />

E<br />

+<br />

E<br />

8

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

Saved successfully!

Ooh no, something went wrong!