0
12kviews
State and explain advantages and limitation of regular and context free grammar.
1 Answer
3
2.1kviews

Advantages of Regular Grammar:

  • Lexical rules are quite simple in Regular Grammar.
  • Notations in Regular Grammar are easy to understand.
  • It is easy to construct efficient recognizer from Regular Expressions.
  • There is proper procedure for lexical and syntactical analysis for Regular Grammar.
  • Regular Expressions are most useful for describing the structure of lexical construct such as identifiers, constant etc.

Limitations of Regular Grammar:

  • Regular Grammars are less productive than Context Free Grammar.
  • Regular Languages are the most restricted types of languages that is accepted by finite automata.
  • Regular Expressions are not closed under infinite intersections.
  • All languages are not regular.

Advantages of Context Free Grammar:

  • Context Free Grammar(CFG) is most useful in describing the nested chain structure or syntactic structure such as balanced parenthesis, if else etc. and these can’t be define by Regular Expression.
  • Context Free Grammar is more powerful than Regular Grammar because it allows a wider range of rules than Regular Grammar i.e. they can generate a wider range of structures than Regular Grammar.
  • CFG provide a precise mathematical definition that clearly rules out certain types of language.
  • The formal definition means that Context Free Grammars are computationally TRACTABLE i.e. it is possible to write a computer program which determines whether sentences are grammatical or not.
  • They provide a convenient visual notation for the structure of sentences (the tree).

Limitations of Context Free Grammar:

  • Lexical rules are difficult in case of Context free grammar.
  • Notations in Context free grammar are quite complex.
  • By using the context free grammar, it is very difficult to construct the recognizer.
  • There is no specific guideline for lexical and syntactic analysis in case of Context free grammar.
Please log in to add an answer.