• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

Lexical analysis

Question 1

The number of tokens in the following C statement is

printf("HELLO WORLD");
  • 3

  • 5

  • 9

  • 8

Question 2

In a compiler, keywords of a language are recognized during
  • parsing of the program
  • the code generation
  • the lexical analysis of the program
  • dataflow analysis

Question 3

The lexical analysis for a modern computer language such as Java needs the power of which one of the following machine models in a necessary and sufficient sense?

  • Finite state automata

  • Deterministic pushdown automata

  • Non-Deterministic pushdown automata

  • Turing Machine

Question 4

Consider the following statements: (I) The output of a lexical analyzer is groups of characters. (II) Total number of tokens in printf("i=%d, &i=%x", i, &i); are 11. (III) Symbol table can be implementation by using array and hash table but not tree. Which of the following statement(s) is/are correct?
  • Only (I)
  • Only (II) and (III)
  • All (I), (II), and (III)
  • None of these

Question 5

Which one of the following statements is FALSE?
  • Context-free grammar can be used to specify both lexical and syntax rules.
  • Type checking is done before parsing.
  • High-level language programs can be translated to different Intermediate Representations.
  • Arguments to a function can be passed using the program stack.

Question 6

A lexical analyzer uses the following patterns to recognize three tokens T1, T2, and T3 over the alphabet {a,b,c}. T1: a?(b∣c)*a T2: b?(a∣c)*b T3: c?(b∣a)*c Note that ‘x?’ means 0 or 1 occurrence of the symbol x. Note also that the analyzer outputs the token that matches the longest possible prefix. If the string bbaacabc is processes by the analyzer, which one of the following is the sequence of tokens it outputs?

  • T1T2T3

  • T1T1T3

  • T2T1T3

  • T3T3

Question 7

Match the description of several parts of a classic optimizing compiler in List - I, with the names of those parts in List - II: \"Capture11\"

  • (1)

  • (2)

  • (3)

  • (4)

Question 8

The output of a lexical analyzer is
  • A parse tree
  • Intermediate code
  • Machine code
  • A stream of tokens

Question 9

Consider the following statements related to compiler construction : 

I. Lexical Analysis is specified by context-free grammars and implemented by pushdown automata. 

II. Syntax Analysis is specified by regular expressions and implemented by finite-state machine.

Which of the above statement(s) is/are correct ?

  • Only I

  • Only II

  • Both I and II

  • Neither I nor II

Question 10

Which of the following statement(s) regarding a linker software is/are true ? I A function of a linker is to combine several object modules into a single load module. II A function of a linker is to replace absolute references in an object module by symbolic references to locations in other modules.
  • Only I
  • Only II
  • Both I and II
  • Neither I nor II

There are 15 questions to complete.

Last Updated :
Take a part in the ongoing discussion