Phases of a Compiler
only two major phases of compilation
1.Analysis Phase
2.Synthesis Phase

Analysis Phase - An intermediate representation is created from the give source code
* Lexical Analyzer
*Syntax Analyzer
* Semantic Analyzer
* Intermediate Code Generator
lexical analyzer divides the program into tokens
Syntax analyzer recognizes sentences
Semantic analyzer checks static semantics of each construct
Intermediate Code Generator generates abstract code
Synthesis Phase
Equivalent target program is created from the intermediate representation
Code Optimizer optimizes the abstract code
Code Generator translates abstract intermediate code into specific machine instructions
Symbol Table
data structure used while compiling a source code .consist identifier name and their type format .store tokens
1. Lexical Analyzer
reads the source program and converts it into tokens. convert lexems into tokens
tokens
Tokens are defined by regular expressions which are understood by the lexical analyzer
2.Syntax Analyzer
Also called as parser.It develops a parse tree and takes all the tokens one by one from the symbol table and uses Context Free Grammar to construct the parse tree
Syntax error can also be determined at this level
3.Semantic Analyzer
it verifies the parse tree generated in syntax phase .to check the statement is meaningful or not.it also check the type and flow control of program.
4.Intermediate Code Generator
it generate intermediate code in lower level language using the semantics of the source code .it is same for every compiler out there, but after that, it depends on the platform. To build a new compiler we don’t need to build it from scratch. We can take the intermediate code from the already existing compiler and build the last two parts.
5.Code Optimization
transforms the intermediate code so that it consumes fewer resources and produces more speed. optimize the code generated before for better efficiency and better utilization of resources
6.Target Code generator
it writes a code that the machine can understand and also register allocation, instruction selection etc. The output is dependent on the type of assembler. This is the final stage of compilation
Answer the following question Compiling a source program written in a given high level programming language...
1. Which of the following statements is NOT correct about high-level languages? a. A program written in a high-level language is called a source program or source code. b. A source program can be executed directly on computers. c. Other programming tools can be used to translate a source program into machine code for execution. d. A compiler can translate the entire source program into machine-code file.
#1 To execute a correctly written program, you first need to _____. highlight the output commands in the code print the code for reference compile it to machine language compile it from machine language into the programming language of choice #2 Adding capabilities to working software is called the _____ phase. coding maintenance debugging brainstorming #3 A rectangle in a flowchart represents which of the following? One or more I/Os ...
*Java* Given the attached Question class and quiz text, write a driver program to input the questions from the text file, print each quiz question, input the character for the answer, and, after all questions, report the results. Write a Quiz class for the driver, with a main method. There should be a Scanner field for the input file, a field for the array of Questions (initialized to 100 possible questions), and an int field for the actual number of...
C++ Programming Question: This programming assignment is intended to demonstrate your knowledge of the following: ▪ Writing a while loop ▪ Write functions and calling functions Text Processing [50 points] We would like to demonstrate our ability to control strings and use methods. There are times when a program has to search for and replace certain characters in a string with other characters. This program will look for an individual character, called the key character, inside a target string. It...
Using C programming language
Question 1 a) through m)
Exercise #1: Write a C program that contains the following steps (make sure all variables are int). Read carefully each step as they are not only programming steps but also learning topics that explain how functions in C really work. a. Ask the user for a number between 10 and 99. Write an input validation loop to make sure it is within the prescribed range and ask again if not. b....
Explain what enterprise resource planning (ERP) systems. Outline several of their key characteristics. Describe in reasonable detail how a company leverages an ERP system and how its operations are improved after installing an ERP system like SAP. Explain how a supply chain management system helps an organization make its operations more efficient What is Upstream and Downstream management of the supply chain? Explain the concept of “Supply Network”, its benefits, and how technology made this concept available Explain the difference...
1. (p. 2-3.) Which of the following is NOT a reason for studying concepts of programming languages according to Sebesta? a. Increased capacity to express ideas. b. Improved background for choosing appropriate languages. c. Increased ability to design new languages. d. Increased ability to learn new languages. 2. (p. 5-6.) What programming language has dominated scientific computing over the past 50 years? a. FORTRAN b. ALGOL c. SNOBOL d. PL/I 3. (p. 6.) What programming language has dominated artificial intelligence...
pls answer all questions
1) A step-by-step solution to a problem is called a. hardware b. an operating system c. a computer language d. an algorithm 2) separated the programming task from the computer operation tasks. a. Algorithms b. Data processors c. High-level programming languages d. Operating systems 3) is a 16-bit code that can represent symbols in languages other than English. a. ASCII b. Extended ASCII c. EBCDIC d. Unicode 4) When you want to download music to a...
In the lectures about lists we have seen some Python code examples that involve the processing of lists containing weather statistics. The original source of the values shown in the slides was taken from part of the Environment Canada website that serves up historical data: http://climate.weather.gc.ca/historical_data/search_historic_data_e.html Data can be provied by that website using the Comma Separated Value (CSV) format which is stored in text files normally using a CSV suffix. We will not work directly with such files in...
please use python and provide run result, thank you!
click on pic to make it bigger
For this assignment you will have to investigate the use of the Python random library's random generator function, random.randrange(stop), randrange produces a random integer in the range of 0 to stop-1. You will need to import random at the top of your program. You can find this in the text or using the online resources given in the lectures A Slot Machine Simulation Understand...