4

Context Free Grammars and Context Free Languages

  • Syntax of high-level languages is defined with Context Free Grammars. Hence, these are used as a powerful tool by the parsers in verifying the syntax of any highlevel language.

In this chapter, we will discuss (1) context free grammar, (2) Language, (3) derivation tree, (4) leftmost derivation and (5) rightmost derivation. We also discuss ambiguous grammars, simplification of grammars and normal forms.

4.1  Context Free Grammars

For a regular grammar, the productions are restricted in two ways: the left side must be a single variable, while the right side can be any string of terminals and non-terminals. To create grammars that are very powerful, we must ease off some of the restrictions. ...

Get Formal Languages and Automata Theory now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.