Lecture 3

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Context Free Grammar

Eng. Hager Nady


Context Free Grammar
Context Free Grammar

 G: S → a S b /ab/ A
A→aA/a
 Σ = { a, b}
 N= V = {S , A }
 P = {S → a S b , S → a b , S → A , A → a A , A → a }
 S = S : Start Symbol
Context Free Grammar

 Derivation
 G: S → a S b / SS /ab

S ab
S aSb
S aabb
S aSb
aaSbb
…aa….bb
Context Free Grammar

 Let G be the grammar : S → AA


A → AAA / bA /Ab/a
 Construct the left most and right most derivation of the string “baba”

 Left most derivation Right most derivation


S AA S AA
bA A Aa
baA Ab a
b a bA b A ba
ba ba ba ba
Context Free Grammar
Context Free Grammar
Context Free Grammar
Context Free Grammar
Context Free Grammar
Context Free Grammar

You might also like