Capabilities of Context-Free Grammar
The capabilities of Context free Grammars are:
- Most of the programming languages are designed using context-free grammars.
- An efficient parser can be easily constructed automatically if the grammar is properly written.
- Balanced parentheses, matching begin-end, corresponding if-then-else’s, etc. A context-free grammar is capable of describing nested structures.
- Suitable grammars for expressions can be constructed, Using the features of associatively & precedence information.
Difference between Context Free Grammer and Regular Expressions
Regular Expressions:
- In the case of Regular expressions, Lexical Rules are very simple.
- It is not easy to understand the notations in Regular Expressions.
- Regular expressions are defined using a set of Strings.
- Efficient Recognizers are easy to construct from Regular Expressions.
- There are guidelines to be followed for Lexical analysis and Syntactical analysis in Regular Expressions.
Context-Free Grammar:
- In the case of Context-Free Grammar, Lexical Rules are difficult.
- It is quite simple and easy to understand the notations in Context-Free Grammer.
- Regular expressions are defined using a collection of productions.
- Efficient Recognizers are tough to construct from Context free grammars.
- There are no guidelines to be followed for Lexical analysis and Syntactical analysis in Context-Free Grammar.
Reference Link
