Unit III Regular Grammar
Unit III Regular Grammar
Unit III Regular Grammar
1. Terminal symbols
2. Non-terminal symbols
1. Terminal Symbols-
• Terminals are the basic symbols from which strings are formed.
• Terminal symbols are denoted by using small case letters such as a,
b, c etc.
2. Non-Terminal Symbols-
• Non-terminals are syntactic variables that denote sets of strings.
• The non-terminals define sets of strings that help define the
language generated by the grammar.
• Non-Terminal symbols are also called as auxiliary
symbols or variables.
• Non-Terminal symbols are denoted by using capital letters such as
A, B, C etc.
REGULAR GRAMMAR
• A regular grammar is a formal grammar that
is right-regular or left-regular.
a) aaabbbbbb
b) aabbb
c) abbabbba
d) aaaabbbabb
3. Let the class of language accepted by finite
state machine be L1 and the class of
languages represented by regular expressions
be L2 then?
a) L1<l2
b) L1>=L2
c) L1 U L2 = .*
d) L1=L2
Chomsky Classification of Grammars
• According to Noam Chomosky, there are four types of
grammars − Type 0, Type 1, Type 2, and Type 3.
Scope of Each Grammar
Type - 3 Grammar
• Type-3 grammars generate regular languages. Type-3
grammars must have a single non-terminal on the left-
hand side and a right-hand side consisting of a single
terminal or single terminal followed by a single non-
terminal.
• The productions must be in the form
X → a or X → aY
• where X, Y ∈ N (Non terminal) and a ∈ T (Terminal)
• The rule S → ε is allowed if S does not appear on the
right side of any rule.
Example
• X→ε
• X → a | aY
• Y→b
Type - 2 Grammar
• Type-2 grammars generate context-free languages.
• The productions must be in the form
A→γ
• where A ∈ N (Non terminal) and γ ∈ (T ∪ N)* (String of
terminals and non-terminals).
a) Type 0 language
b) Type 1 language
c) Type 2 language
d) Type 3 language
2. Which of the following strings is not
generated by the following grammar?
S → SaSbS|ε
a) aabb
b) abab
c) aababb
d) aaabbb
3. What is the Regular Expression Matching Zero
or More Specific Characters
a) x
b) #
c) *
d) &
4. The production Grammar is {S->aSbb,S->abb}
is
a) Type-3 grammar
b) Type-2 grammar
c) Type-1 grammar
d) Type-0 grammar
5. Regular expression (x|y)(x|y) denotes the set
a) {xy,xy}
b) {xx,xy,yx,yy}
c) {x,y}
d) {x,y,xy}
6. Consider the following regular expression
R = ( ab + abb )* bbab
Which of the following is not a set denoted by R?
A) abababab
B) ababbabbbab
C)abbbab
D)abbabbbab.
7. Every grammar in Chomsky Normal Form is:
a) regular
b) context sensitive
c) context free
d) all of the mentioned
Conversion of RE to Regular
Grammar
• A.Type 0
• B.Type 1
• C.Type 2
• D.Type 3
3. The context free grammar
S → A111|S1, A → A0 | 00 is equivalent
to