Thursday, March 24, 2016

What is CFG?Advantages of CFG

 Context Free Grammar :  A CFG is a way of describing language by recursive rules. A CFG consists four tuples, denoted G = {V, T, P,  S}
Where,
              V = Finite set of variables.  [Eg. {S, E}etc.]
              T = Finite set of terminals.  [Eg. {a, b, c,+}etc.]
              P = Finite set of productions.  [Eg. E E+E]
              S = Start symbol. 
Example :
                    Let a CFG which is given :
Here, V = {E}
T = {+, *, id}
S = E
So, the grammar notation is written as;  G = (E, {+, *, id}, P, E) 
Advantages of context free grammar : 
  • A grammar give a precise, yet easy to understand, syntactic specification of a programming language.
  • An efficient parser can be constructed automatically from a properly designed grammar.
  • A grammar imparts a structure to a program that is useful for its translation into object code for the detection of errors.
  • Language ecvolved over a period of time.acquiring new constructs & performing additional tasks.
If You want to learn about the technology, computer science & engineering, web programming, freelancing, earning please click here :CSE SOLVE

0 comments:

Post a Comment