Context Free Gramcccmar Introduction
Context Free Gramcccmar Introduction
http://www.tutorialspoint.com/automata_theory/context_free_grammar_introduction.htm
Copyright © tutorialspoint.com
P is a set of rules, P: N → N ∪ T *, i.e., the left-hand side of the production rule P does have
any right context or left context.
Example
The grammar A, a, b, c, P, A, P : A → aA, A → abc.
The grammar S, a, b, a, b, P, S, P: S → aSa, S → bSb, S → ε
The grammar S, F, 0, 1, P, S, P: S → 00S | 11F, F → 00F | ε
Representation Technique
Root vertex − Must be labeled by the start symbol.
If S → x1 x2 …… xn is a production rule in a CFG, then the parse tree / derivation tree will be as
follows −
Top-down Approach −
Bottom-up Approach −
Example
Example
Example