Lexical-Analyzer
Question 1 |
A particular BNF definition for a “word” is given by the following rules.
<word> ::= <letter> | <letter><pairlet> | <letter><pairdig>
<pairlet> ::= <letter><letter> | <pairlet><letter><letter>
<pairdig> ::= <digit><digit> | <pairdig><digit><digit>
<letter> ::= a | b | c | ... | y | | z
<digit> ::= 0 | 1 | 2 | ... | 9
Which of the following lexical entries can be derived from < word > ?
I. pick
II. picks
III. c44
<word> ::= <letter> | <letter><pairlet> | <letter><pairdig>
<pairlet> ::= <letter><letter> | <pairlet><letter><letter>
<pairdig> ::= <digit><digit> | <pairdig><digit><digit>
<letter> ::= a | b | c | ... | y | | z
<digit> ::= 0 | 1 | 2 | ... | 9
Which of the following lexical entries can be derived from < word > ?
I. pick
II. picks
III. c44
I, II and III | |
I and II only | |
l and III only | |
lI and III only |
Question 1 Explanation:
Step-1: Both < letter > and < digit > produce only a single character
Step-2: Both < pairlet > and < pairdig > produce even number of characters
Step-3: < word > produces odd number of characters.
Step-4: As per the statements I, II and III. I statement having even number of characters
So, a statement I is wrong. Statement II and III are having odd number of characters.
Step-2: Both < pairlet > and < pairdig > produce even number of characters
Step-3: < word > produces odd number of characters.
Step-4: As per the statements I, II and III. I statement having even number of characters
So, a statement I is wrong. Statement II and III are having odd number of characters.
There is 1 question to complete.
