MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

COMPILER DESIGN

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Which phase of the compiler is also known as Scanner?
A
Syntax Analysis
B
Lexical Analysis
C
Semantic Analysis
D
Code generation
Explanation: 

Detailed explanation-1: -The first phase of the compiler is the lexical analyzer, also known as the scanner, which recognizes the basic language units, called tokens. The exact characters in a token is called its lexeme.

Detailed explanation-2: -Lexical analysis is the starting phase of the compiler. It gathers modified source code that is written in the form of sentences from the language preprocessor. The lexical analyzer is responsible for breaking these syntaxes into a series of tokens, by removing whitespace in the source code.

Detailed explanation-3: -The main task of lexical analysis is to read input characters in the code and produce tokens. Lexical analyzer scans the entire source code of the program. It identifies each token one by one.

Detailed explanation-4: -Explanation: Lexical Analyzer is also called “Linear Phase” or “Linear Analysis” or “Scanning“.

Detailed explanation-5: -JavaCC is the standard Java compiler-compiler. Unlike the other tools presented in this chapter, JavaCC is a parser and a scanner (lexer) generator in one. JavaCC takes just one input file (called the grammar file), which is then used to create both classes for lexical analysis, as well as for the parser.

There is 1 question to complete.