Simplifications Context-Free Grammars - WPI

Simplifications of

Context-Free Grammars

Fall 2004

COMP 335

1

A Substitution Rule

S aB A aaA A abBc B aA Bb

Substitute

Bb

Fall 2004

COMP 335

Equivalent grammar

S aB | ab A aaA A abBc | abbc B aA

2

A Substitution Rule

S aB | ab A aaA A abBc | abbc B aA

Substitute

B aA

Fall 2004

S aB | ab | aaA A aaA A abBc | abbc | abaAc

COMP 335

Equivalent grammar

3

In general:

A xBz

B y1

Substitute

B y1

A xBz | xy1z

equivalent grammar

Fall 2004

COMP 335

4

Nullable Variables

- production :

A

Nullable Variable:

AK

Fall 2004

COMP 335

5

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download