Regular Grammar Formal Languages DEFINITION OF A GRAMMAR

  • Slides: 29
Download presentation
Regular Grammar

Regular Grammar

Formal Languages

Formal Languages

DEFINITION OF A GRAMMAR

DEFINITION OF A GRAMMAR

Example

Example

Ex 1: Ex 2:

Ex 1: Ex 2:

Example

Example

Example

Example

CHOMSKY CLASSIFICATION OF LANGUAGES • In the definition of a grammar are the sets

CHOMSKY CLASSIFICATION OF LANGUAGES • In the definition of a grammar are the sets of symbols and So if we want to classify grammars. • We have to do it only by considering the form of productions. • Chomsky classified the grammars into four types in terms of productions (types 0 -3). • A type 0 grammar is any phrase structure grammar without any restrictions. • (All the grammars we have considered are type 0 grammars. )

LANGUAGES AND THEIR RELATION • In this section we discuss the relation between the

LANGUAGES AND THEIR RELATION • In this section we discuss the relation between the classes of languages that we have defined under the Chomsky classification.

 • Some Definitions: • Any set represented by regular expression is called Regular

• Some Definitions: • Any set represented by regular expression is called Regular Set. • The class of Regular sets over ∑ is Regular Language over the terminal set ∑. • Grammar for Regular Expression is Regular Grammar.

 • Converting Regular Expression to Regular Grammar: • Then we construct Grammar as

• Converting Regular Expression to Regular Grammar: • Then we construct Grammar as : - Example 1 : -

 • Converting Regular Grammar to Regular Expression and Transition System: - Then we

• Converting Regular Grammar to Regular Expression and Transition System: - Then we construct a transition system : -

Example : -

Example : -

 • Example:

• Example:

Linear grammars The Linear Grammars are either left or right: Right Linear Grammars: Rules

Linear grammars The Linear Grammars are either left or right: Right Linear Grammars: Rules of the forms A→ε A→a A → a. B A, B: variables and a: terminal Left Linear Grammars: Rules of the forms A→ε A→a A → Ba A, B: variables and a: terminal