Lesson 18 Print
Lesson 18 Print
Trees
As in English language any sentence can be
expressed by parse tree, so any word generated
by the given CFG can also be expressed by the
parse tree, e.g. consider the following CFG
S → AA
A → AAA|bA|Ab|a
Obviously, baab can be generated by the above
CFG.
To express the word baab as a parse tree, start
with S.
Replace S by the string AA, of nonterminals,
Now let the left A be replaced by bA and the right one by Ab
then the tree will be
NOTE
It is to be noted that the only
word in this language is b.
Regular Grammar
Semiword
A semiword is a string of terminals (may
be none) concatenated with exactly one
nonterminal on the right i.e. a semiword,
in general, is of the following form
(terminal)(terminal)… (terminal)
(nonterminal)
Word
A word is a string of terminals. Λ is also a
word.
Theorem
If every production in a CFG is one of the following
forms
Nonterminal → semiword
Nonterminal → word
then the language generated by that CFG is
regular.
A CFG is said to be a regular grammar if it
generates the regular language i.e. a CFG is said to
be a regular grammar in which each production is
one of the two forms
Nonterminal → semiword
Nonterminal → word
Example