COMPUTER FUNDAMENTALS

COMPUTER SOFTWARE

PROGRAMMING LANGUAGES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
What is the first step in a compiler?
A
Syntax analyzer
B
Lexical analyzer
C
Code generator
D
Optimizer
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: Lexical analysis or Lexical analyzer is the initial stage or phase of the compiler. This phase scans the source code and transforms the input program into a series of a token.

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

Detailed explanation-5: -Lexical Analysis. The first phase of scanner works as a text scanner. Syntax Analysis. The next phase is called the syntax analysis or parsing. Semantic Analysis. Intermediate Code Generation. Code Optimization. Code Generation. Symbol Table.

There is 1 question to complete.