MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

COMPILER DESIGN

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
For a context-free grammar, left hand side of production rules should contain
A
Single nonterminal
B
Set of both terminals and nonterminals
C
Set of terminals
D
None of the other options
Explanation: 

Detailed explanation-1: -Define a left-regular grammar to be a context-free grammar in which the right-hand side of every production rule is of one of the following forms: the empty string; a single non-terminal symbol; or a non-terminal symbol followed by a terminal symbol.

Detailed explanation-2: -A CFG consists of the following components: a set of terminal symbols, which are the characters of the alphabet that appear in the strings generated by the grammar. a set of nonterminal symbols, which are placeholders for patterns of terminal symbols that can be generated by the nonterminal symbols.

Detailed explanation-3: -The left hand side must be a single variable, and the right can be any string of variables and terminals. There are three productions above. The start variable is the one that we begin the derivation process with. It is typically the left hand side of the first production.

Detailed explanation-4: -P is a set of rules, P: N → (N ∪ T)*, i.e., the left-hand side of the production rule P does have any right context or left context. S is the start symbol.

Detailed explanation-5: -Context-free grammars have the following components: A set of terminal symbols which are the characters that appear in the language/strings generated by the grammar. Terminal symbols never appear on the left-hand side of the production rule and are always on the right-hand side.

There is 1 question to complete.