Question 48Asked in BEL PE Computer Science, 20 Dec 2025 (5:00 PM)

A lexical analyzer uses the following regular expressions to recognise tokens in a programming language:

A lexical analyzer uses the following regular expressions to recognise tokens in a programming language: Identifier (ID): (letter)(letter|digit)* Number (NUM): (digit)+(\.(digit)+)? Relational Operator (REL_OP): < <= > >= == != Whitespace: (blank|tab|newline)+ Consider the input string: count<=total1 If the lexical analyzer applies maximal munch (longest match rule) and priority-based resolution (in the order: REL_OP > NUM > ID > WHITESPACE), what will be the correct sequence of tokens recognised?
  1. A⟨ID, count⟩ ⟨REL_OP, <=⟩ ⟨ID, total1⟩
  2. B⟨ID, count⟩ ⟨REL_OP, <=⟩ ⟨ID, total⟩ ⟨NUM, 1⟩
  3. C⟨ID, count⟩ ⟨REL_OP, <⟩ ⟨=, invalid⟩ ⟨ID, total1⟩
  4. D⟨ID, count⟩ ⟨REL_OP, <=⟩ ⟨NUM, total1⟩
Show answerHide answer

Correct answer: (A) ⟨ID, count⟩ ⟨REL_OP, <=⟩ ⟨ID, total1⟩

From BEL PE Computer Science PYQ, 20 Dec 2025 (5:00 PM)

This is question 48 of BEL PE Computer Science PYQ, 20 Dec 2025 (5:00 PM). See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.