MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

COMPILER DESIGN

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
In this phase, token arrangements are checked against the source code grammar.
A
Lexical Analyzer
B
Syntax Analyzer
C
Semantic Analyzer
D
Code Generator
Explanation: 

Detailed explanation-1: -Explanation: Lexical analysis or scanning is the process of parsing the source code into proper syntactic classes. It gets things ready for the parser with lexemes to built the parse tree.

Detailed explanation-2: -Token: A token is a group of characters having collective meaning: typically a word or punctuation mark, separated by a lexical analyzer and passed to a parser. A lexeme is an actual character sequence forming a specific instance of a token, such as num. The pattern matches each string in the set.

Detailed explanation-3: -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-4: -In programming language, keywords, constants, identifiers, strings, numbers, operators and punctuations symbols can be considered as tokens. int value = 100; contains the tokens: int (keyword), value (identifier), = (operator), 100 (constant) and; (symbol).

There is 1 question to complete.