COMPILER DESIGN

LEXICAL ANALYSIS

ROLE OF THE LEXICAL ANALYZER

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Which phase of the compiler is Lexical Analyser?
A
First
B
Second
C
Third
D
Fourth
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 first phase of a compiler. It takes modified source code from language preprocessors that are written in the form of sentences. The lexical analyzer breaks these syntaxes into a series of tokens, by removing any whitespace or comments in the source code.

Detailed explanation-3: -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.

Detailed explanation-4: -Lexical Analysis is the very first phase in the compiler designing. A Lexer takes the modified source code which is written in the form of sentences . In other words, it helps you to convert a sequence of characters into a sequence of tokens. The lexical analyzer breaks this syntax into a series of tokens.

Detailed explanation-5: -Stripping out comments and white spaces from the program. Read the input program and divide it into valid tokens. Find lexical errors. Return the Sequence of valid tokens to the syntax analyzer. When it finds an identifier, it has to make an entry into the symbol table.

There is 1 question to complete.