edited by
8,861 views
9 9 votes

A particular BNF definition for a "word is given by the following rules.

<word>      :: = <letter> | <letter> <charpair> | <letter> <intpair>
<charpair>  :: = <letter> <letter> | <charpair> <letter> <letter>
<intpair>   :: = <integer> <integer> | <intpair> <integer> <integer>
<letter>    :: = a | b | c | ...... | Y | Z
<integer>   :: = 0 | 1 | 2 | ...... | 9

Which of the following lexical entries can be derived from $\textsf{< word >}?$

  1. pick
  2. picks
  3. $\textsf{c44}$
  1. I, II and III
  2. I and II only
  3. I and III only
  4. II and III only

4 Answers

1 1 vote
Ans: D.

What I thought, "word" is having only 4 char. Which can't be derived from the grammar.

"words" is having 5 char, which is odd, so can be derived from the grammar.

Also c22 can be drived.

So ans is II and III, implies option D.
0 0 votes

Given grammar :  < word > :: =< letter > I < letter > < charpair > I < letter >< intpair >

Which means every word must start with a letter.

 

< charpair > :: =< letter >< letter > I < charpair >< letter >< letter >

Adds 2 letters at a time

Hence, Only odd number of letters are allowed.

 

< intpair > :: = < integer >< integer > I < intpair >< integer >< integer >

Adds 2 digits at a time.

Hence, Only even number of digits are allowed.

 

Hence, Ans  (D) II and III only 

Answer:
Position:
Show:

Related questions

3 3 votes
3 3 answers
4.3k
4.3k views
Arjun asked Apr 22, 2018
4,313 views
A $CFG$ (Context Free Grammar) is said to be in Chomsky Normal Form $(CNF)$, if all the productions are of the form A$\to$ BC or A$\to$ a. Let $G$ be a $CFG$ in $CNF$. To...
3 3 votes
1 answers 1 answer
3.0k
3.0k views
Arjun asked Apr 22, 2018
3,043 views
Incremental-Compiler is a compiler:which is written in a language that is different from the source languagecompiles the whole source code to generate object code afreshc...
0 0 votes
2 2 answers
3.4k
3.4k views
Arjun asked Apr 22, 2018
3,392 views
DU-chains(Definition-Use) in compiler design:consist of a definition of a variable and all its uses, reachable from that definitionare created using a form static code an...
5 5 votes
2 answers 2 answers
6.3k
6.3k views
Arjun asked Apr 22, 2018
6,319 views
Which of the following comment about peep-hole optimization is true?It is applied to small part of the code and applied repeatedlyIt can be used to optimize intermediate ...