1 / 11

Context-Free Grammars – Regular Grammars

Context-Free Grammars – Regular Grammars. Lecture 14 Section 2.1 Fri, Sep 21, 2007. Regular Grammars. Yet another way to describe regular languages is through regular grammars . Start symbol S . Set of variables V . Set of terminal symbols  . Set of rules R. Regular Grammars.

darena
Download Presentation

Context-Free Grammars – Regular Grammars

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Context-Free Grammars – Regular Grammars Lecture 14 Section 2.1 Fri, Sep 21, 2007

  2. Regular Grammars • Yet another way to describe regular languages is through regular grammars. • Start symbolS. • Set of variablesV. • Set of terminal symbols. • Set of rulesR.

  3. Regular Grammars • Each rule is of one of the following forms: • A aB • A  where A and B are variables and a is a terminal.

  4. Regular Grammars • Then we begin with the start symbol and apply rules until we obtain a string of all terminals.

  5. Example • Let the rules be • S aX • S  bY • S   • X  aS • X  bZ • X   • :

  6. Example • Y  aY • Y  bY • Y   • Z  aY • Z  bX

  7. Example • What strings can be obtained by these rules? • One example: • S aX  aaS  aabY  aab. • Another example: • S bY  bbY  bbaY  bba.

  8. The Language of a Grammar • The set of all strings obtainable from the grammar, by starting with the start symbol, is called the language of the grammar.

  9. Regular Grammars and Regular Languages • It is easy to derive a regular grammar from a DFA, and vice versa.

  10. Regular Grammars and Regular Languages • Given a DFA, • Let V be the set of states Q. • The start symbol is the start state. • For each transition (p, a) = q, write a rule p  aq. • For each accept state q, write a rule q  . • This process is reversible.

  11. Example • Construct a DFA from the previous example. • What is the language of the grammar?

More Related