














Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The process of testing membership and reconstructing parse trees for strings given a context-free grammar. It covers topics such as derivations, unit productions, ε-productions, and chomsky normal form. The document also includes an exercise and algorithms for testing membership and parse tree reconstruction.
Typology: Slides
1 / 22
This page cannot be seen from the preview
Don't miss anything!















when do we stop?
1 3 7 6 5
grammar: unit productions:
S T
T → S | R | ε R → 0SR
S → R | ε R → 0SR
T is replaced by S in the {S, T} cycle
Find all nullable variables N 1 , ..., N k For i = 1 to k For every production of the form A → αN i β, add another production A → αβ If N i → ε is a production, remove it If S is nullable, add the special production S → ε
A→ a B → ε C → ED | ε D → BC | b E → b
grammar nullable variables
^ Find all nullable variables^ N 1 , ..., N k
A→ a B → ε C → ED | ε D → BC | b E → b
nullable variables: B, C, D
For i = 1 to k For every production of the form A → αN i β, add another production A → αβ If N i → ε is a production, remove it
D → ε S → AC S → A C → E
Eliminate all ε-productions and unit productions If x = ε and S → ε, accept; else delete S → ε Let X := S While some new production P can be applied to X Apply P to X If X = x , accept If | X | > | x |, backtrack If no more productions can be applied to X , reject
G = CFG of the java programming language x = code for a 200-line java program
algorithm might take about 10200 steps!
S → ε |ADDA A → a C → c D → bCb
A → BA | a B → CC | b C → AB | a
Idea: We generate each substring of x bottom up
b a a b a