COMPILER DESIGN

LEXICAL ANALYSIS

ROLE OF THE LEXICAL ANALYZER

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Which concept of FSA is used in the compiler?
A
Lexical analysis
B
Parser
C
Code generation
D
Code optimization
Explanation: 

Detailed explanation-1: -An FSA is usually used to do lexical analysis. An FSA consists of states, starting state, accept state and transition table. The automaton reads an input symbol and moves the state accordingly.

Detailed explanation-2: -What is Lexical Analysis? 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: -Explanation: The concept of grammar is much used in the parser phase of the compiler. The parser phase is next to the lexical analysis phase in the compiler. Parser generated the parse tree using the predefined grammar.

Detailed explanation-4: -Explanation: Lexical analysis is done using few tools such as lex, flex and jflex. Jflex is a computer program that generates lexical analyzers (also known as lexers or scanners) and works apparently like lex and flex.

There is 1 question to complete.