Specification of Programming languages

1. Explain context-free grammar (CFG) and its four components with the help of an example.

Ans: The context-free grammar (CFG) was developed by Chomsky in 1965. A CFG is used to specify the syntactic structure of a programming language constructs like expressions and statements. The CFG is also known as Backus-Naur Form (BNF). A CFG comprises four components, namely, nonterminals, terminals, productions, and start symbol.

images The non-terminals (also known as syntactic variables) represent the set of strings in a language.

The terminals (also known as tokens) represent the symbols of the language.

The ...

Get Express Learning: Principles of Compiler Design now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.