COMPILER DESIGN

SYNTAX ANALYSIS

ROLE OF THE PARSER

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
A Context Free Grammar(CFG) contains
A
Only terminals and non-terminals
B
Only a set of productions
C
Only a start symbol
D
All the above
Explanation: 

Detailed explanation-1: -Context-free grammars consist of terminals (w1, w2, …, wV), nonterminals (N1, N 2, …, Nn), a start symbol (N1), and rules. Terminal symbols represent context that appear in the strings generated by the grammar. Nonterminal symbols are placeholders for patterns of terminal symbols that can be generated by nonterminals.

Detailed explanation-2: -A context free grammar has 4 components: – A set of tokens, known as terminal symbols. – A set of nonterminals. nonterminal, called the left side of the production, an arrow, and a sequence of tokens and/or nonterminals, called the right side of the production.

Detailed explanation-3: -In general a context-free grammar G is a 4-tuple (V, , R, S) where V is a set of variables, is an alphabet of terminal symbols, R is a set of rules, and S is a start symbol. The elements of V − are called nonterminals and are analogous to parts of speech.

Detailed explanation-4: -A set of non-terminals (V). Non-terminals are syntactic variables that denote sets of strings. A set of tokens, known as terminal symbols (). A set of productions (P). One of the non-terminals is designated as the start symbol (S); from where the production begins.

There is 1 question to complete.