19.05.2013 Views

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 ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

46 CHAPTER 3. CONTEXT-FREE GRAMMARS AND LANGUAGES<br />

Applying the first phase of the method of lemma 3.3.3 to the grammar G ′ 3,wegetthe<br />

rules<br />

E −→ EX+T,<br />

E −→ TX∗F,<br />

E −→ X(EX),<br />

E −→ a,<br />

T −→ TX∗F,<br />

T −→ X(EX),<br />

T −→ a,<br />

F −→ X(EX),<br />

F −→ a,<br />

X+ −→ +,<br />

X∗ −→ ∗,<br />

X( −→ (,<br />

X) −→).<br />

After applying the second phase of the method, we get the following grammar in Chomsky<br />

Normal Form:<br />

E −→ [EX+]T,<br />

[EX+] −→ EX+,<br />

E −→ [TX∗]F,<br />

[TX∗] −→ TX∗,<br />

E −→ [X(E]X),<br />

[X(E] −→ X(E,<br />

E −→ a,<br />

T −→ [TX∗]F,<br />

T −→ [X(E]X),<br />

T −→ a,<br />

F −→ [X(E]X),<br />

F −→ a,<br />

X+ −→ +,<br />

X∗ −→ ∗,<br />

X( −→ (,<br />

X) −→).<br />

For large grammars, it is often convenient to use the abbreviation which consists in grouping<br />

productions having a common left-hand side, and listing the right-hand sides separated

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

Saved successfully!

Ooh no, something went wrong!