Question

3. Briefly describe the phases ofcompiling. For each phase, use a few sentences, Also escribe the input and output for each p (25 pts)
0 0
Add a comment Improve this question Transcribed image text
Answer #1

ANSWER:

Phases of Compiling include:

1. Lexical Analysis: This phase works as a text scanner. It is the first phase of compiling. Input in this phase is a stream of characters which are converted into meaningful lexemes.

Input: Stream of characters

Output: Token

Token here is referred to the sequence representing the lexical unit matching the pattern.

2. Syntax Analysis: This is second phase of compiler and also referred to as parsing.

It generates the parse tree from the tokens received from lexical analysis. It also checks whether the expression made from tokens is correct or not. This is performed by the parser.

Input: Tokens

Output: Syntax Tree

3. Semantic Analysis: This third phase of compiler checks whether the parse tree constructed follows the language rules. The output is in form of annotated syntax tree.

Input: Syntax tree

Output: Annotated Syntax tree

4. Intermediate Code generator: It produces the intermediate representations of source program either in Postfix notation, three address code or syntax tree. This lies between high level language and machine language.

5. Code Optimization: It is used to remove unnecessary code and aligns the sequence of statements in such a way that the execution becomes faster.

Input: Intermediate Code

Output: Optimized Intermediate Code

All the temporary unwanted variables are removed; redundant code is removed resulting in a faster executing code.

6. Code Generation: This is the final phase of the compiler. It takes the optimized intermediate code and maps to the machine language. Task performed in this phase includes allocating registers and memory, generating correct data types, references and missing code.

Input: Optimized Intermediate Code

Output: Target code or Object code

bol Optimizes code

Add a comment
Know the answer?
Add Answer to:
Briefly describe the phases of compiling. For each phase, use a few sentences. Also describe the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT