COMPILER DESIGN

TOOLS AND TECHNIQUES FOR COMPILER DESIGN

MISCELLENOUS

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
The number of token generated by the lexical analyzer for the following program:void main (){ print ("Hello world")// To tell the world “hello"}
A
9
B
10
C
11
D
17
Explanation: 

Detailed explanation-1: -To read the input character in the source code and produce a token is the most important task of a lexical analyzer. The lexical analyzer goes through with the entire source code and identifies each token one by one. The scanner is responsible to produce tokens when it is requested by the parser.

Detailed explanation-2: -The lexical analyzer is the part of the compiler that detects the token of the program and sends it to the syntax analyzer. Token is the smallest entity of the code, it is either a keyword, identifier, constant, string literal, symbol. Examples of different types of tokens in C.

Detailed explanation-3: -There are 6 types of C tokens : identifiers, keywords, constants, operators, string literals and other separators.

There is 1 question to complete.