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

Related Posts:

  • What is Pass? Pass:         When one or more phase are combined into a module than the module is referred as pass. A pass is read the source program to the output of the previous pass, makes the tra… Read More
  • What is L-value? L-value:  The term "l-value" refers to values that are appropriate on the left of an asignment expression.So, l-values are location.Sometimes, an expression has no l-value. Example:   i:=5;  &n… Read More
  • What is Copy-restore? Copy-restore:  A hybrid between call-by-value & call-by-reference is copy restore linkage. 1.Before the call, the actual parameters are evaluated. The r-values of the actual are passed to the called procedure as i… Read More
  • What is Pre-Processor? Pre-Processor:   Pre-processor produces a input to compilers which are perform the following function:- Macro Processing File Inclusion Rational Preprocessor & Extension of Language If You want to lea… Read More
  • What is Phase? Phase:  A phase is a logically cohesive operation that takes as input one representation of the source & produces as output another representation.These are Six phases are used in compiler design. These are- &nbs… Read More

0 comments:

Post a Comment