Chapter 3 Context-Free Grammars, Context-Free Languages, Parse ...
Chapter 3 Context-Free Grammars, Context-Free Languages, Parse ...
Chapter 3 Context-Free Grammars, Context-Free Languages, Parse ...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
3.11. DERIVATIONS TREES 65<br />
Tree t2<br />
g<br />
↙ ↘<br />
a b<br />
The tree t1[22 ← t2] is defined by the following diagram:<br />
f<br />
↙ ↘<br />
h g<br />
↙ ↙ ↘<br />
a a g<br />
↙ ↘<br />
a b<br />
We can now define derivation trees and relate derivations to derivation trees.<br />
3.11 Derivations Trees<br />
Definition 3.11.1 Given a context-free grammar G = (V,Σ,P,S), for any A ∈ N, an<br />
A-derivation tree for G is a (V ∪{ɛ})-tree t (a tree with set of labels (V ∪{ɛ})) such that:<br />
(1) t(ɛ) =A;<br />
(2) For every nonleaf node u ∈ dom(t), if u1,...,uk are the successors of u, then either<br />
there is a production B → X1 ···Xk in P such that t(u) =B and t(ui) =Xi for all<br />
i, 1≤ i ≤ k, orB → ɛ ∈ P , t(u) =B and t(u1) = ɛ. Acomplete derivation (or parse<br />
tree) is an S-tree whose yield belongs to Σ ∗ .<br />
A derivation tree for the grammar<br />
where P is the set of rules<br />
G3 =({E,T,F,+, ∗, (, ),a}, {+, ∗, (, ),a},P,E),<br />
E −→ E + T,<br />
E −→ T,<br />
T −→ T ∗ F,<br />
T −→ F,<br />
F −→ (E),<br />
F −→ a,