The document discusses the different phases of a compiler:
1. Lexical analysis scans the source code and groups characters into tokens like keywords, identifiers, and punctuation.
2. Syntax analysis checks that the tokens are combined according to the rules of the language.
3. Code generation translates the intermediate representation into the target machine code.
THIS PPT CONTAINS THE DETAILS ABOUT THE VARIOUS LANGUAGE PROCESSORS/LANGUAGE TRANSLATORS- THE COMPILER & THE INTERPRETER, OPERATING SYSTEMS & ITS FUNCTION, PARALLEL & CLOUD COMPUTING
THIS PPT CONTAINS THE DETAILS ABOUT THE VARIOUS LANGUAGE PROCESSORS/LANGUAGE TRANSLATORS- THE COMPILER & THE INTERPRETER, OPERATING SYSTEMS & ITS FUNCTION, PARALLEL & CLOUD COMPUTING
This Slide will clear all the Question Regarding compiler development and will also help to understand how a compiler works and how the phases are connected to each one
LANGUAGE PROCESSING SYSTEM
COMPILER DESIGN- ARCHITECTURE
INTERPRETER
ROLE OF COMPILER & INTERPRETER
COMPARISION OF INTERPRETER & COMPILER
PURE AND IMPUTER INTERPRETER
P-CODE COMPILERS
Introduction to Programming Concepts By Aamir Saleem AnsariTech
Get the free powerpoint slide of introduction to programming concepts from Techora. Learn programming and other things from using our slides. For more visit : www.techora.net
This introductory slide program teaches you the foundational skills all programmers use, whether they program mobile apps, create web pages, or analyze data.
Computer programs are collections of instructions that tell a computer how to interact with the user, interact with the computer hardware and process data. The first programmable computers required the programmers to write explicit instructions to directly manipulate the hardware of the computer. This “machine language” was very tedious to write by hand since even simple tasks such as printing some output on the screen require 10 or 20 machine language commands. Machine language is often referred to as a “low level language” since the code directly manipulates the hardware of the computer.
By contrast, higher level languages such as “C”, C++, Pascal, Cobol, Fortran, ADA and Java are called “compiled languages”. In a compiled language, the programmer writes more general instructions and a compiler (a special piece of software) automatically translates these high level instructions into machine language. The machine language is then executed by the computer. A large portion of software in use today is programmed in this fashion.
Chapter 1
Introduction
Programming languages are notations for describing computations to people
and to machines. The world as we know it depends on programming languages,
because all the software running on all the computers was written in some
programming language. But, before a program can be run, it first must be
translated into a form in which it can be executed by a computer.
The software systems that do this translation are called compilers.
This book is about how to design and implement compilers. We shall discover that a few basic ideas can be used to construct translators for a wide
variety of languages and machines. Besides compilers, the principles and techniques for compiler design are applicable to so many other domains that they
are likely to be reused many times in the career of a computer scientist. The
study of compiler writing touches upon programming languages, machine architecture, language theory, algorithms, and software engineering.
In this preliminary chapter, we introduce the different forms of language
translators, give a high level overview of the structure of a typical compiler,
and discuss the trends in programming languages and machine architecture
that are shaping compilers. We include some observations on the relationship
between compiler design and computer-science theory and an outline of the
applications of compiler technology that go beyond compilation. We end with
a brief outline of key programming-language concepts that will be needed for
our study of compilers.
1.1 Language Processors
Simply stated, a compiler is a program that can read a program in one language - the source language - and translate it into an equivalent program in
another language - the target language; see Fig. 1.1. An important role of the
compiler is to report any errors in the source program that it detects during
the translation proc....
If the target program is an executable machine-language program, it can
then be called by the user to process inputs and produce outputs; see Fig. 1.2.
Target Program output tFigure 1.2: Running the target program
An interpreter is another common kind of language processor. Instead of
producing a target program as a translation, an interpreter appears to directly
execute the operations specified in the source program on inputs supplied by
the user, as shown in Fig. 1.3.
source program 1 Interpreter t- output input
Figure 1.3: An interpreter
The machine-language target program produced by a compiler is usually
much faster than an interpreter at mapping inputs to outputs . An interpreter,
however, can usually give better error diagnostics than a compiler, because it
executes the source program statement by statement.
Example 1.1 : Java language processors combine compilation and interpretation, as shown in Fig. 1.4. A Java source program may first be compiled into
an intermediate form called bytecodes. The bytecodes are tinto machine language
immediately be.
This Slide will clear all the Question Regarding compiler development and will also help to understand how a compiler works and how the phases are connected to each one
LANGUAGE PROCESSING SYSTEM
COMPILER DESIGN- ARCHITECTURE
INTERPRETER
ROLE OF COMPILER & INTERPRETER
COMPARISION OF INTERPRETER & COMPILER
PURE AND IMPUTER INTERPRETER
P-CODE COMPILERS
Introduction to Programming Concepts By Aamir Saleem AnsariTech
Get the free powerpoint slide of introduction to programming concepts from Techora. Learn programming and other things from using our slides. For more visit : www.techora.net
This introductory slide program teaches you the foundational skills all programmers use, whether they program mobile apps, create web pages, or analyze data.
Computer programs are collections of instructions that tell a computer how to interact with the user, interact with the computer hardware and process data. The first programmable computers required the programmers to write explicit instructions to directly manipulate the hardware of the computer. This “machine language” was very tedious to write by hand since even simple tasks such as printing some output on the screen require 10 or 20 machine language commands. Machine language is often referred to as a “low level language” since the code directly manipulates the hardware of the computer.
By contrast, higher level languages such as “C”, C++, Pascal, Cobol, Fortran, ADA and Java are called “compiled languages”. In a compiled language, the programmer writes more general instructions and a compiler (a special piece of software) automatically translates these high level instructions into machine language. The machine language is then executed by the computer. A large portion of software in use today is programmed in this fashion.
Chapter 1
Introduction
Programming languages are notations for describing computations to people
and to machines. The world as we know it depends on programming languages,
because all the software running on all the computers was written in some
programming language. But, before a program can be run, it first must be
translated into a form in which it can be executed by a computer.
The software systems that do this translation are called compilers.
This book is about how to design and implement compilers. We shall discover that a few basic ideas can be used to construct translators for a wide
variety of languages and machines. Besides compilers, the principles and techniques for compiler design are applicable to so many other domains that they
are likely to be reused many times in the career of a computer scientist. The
study of compiler writing touches upon programming languages, machine architecture, language theory, algorithms, and software engineering.
In this preliminary chapter, we introduce the different forms of language
translators, give a high level overview of the structure of a typical compiler,
and discuss the trends in programming languages and machine architecture
that are shaping compilers. We include some observations on the relationship
between compiler design and computer-science theory and an outline of the
applications of compiler technology that go beyond compilation. We end with
a brief outline of key programming-language concepts that will be needed for
our study of compilers.
1.1 Language Processors
Simply stated, a compiler is a program that can read a program in one language - the source language - and translate it into an equivalent program in
another language - the target language; see Fig. 1.1. An important role of the
compiler is to report any errors in the source program that it detects during
the translation proc....
If the target program is an executable machine-language program, it can
then be called by the user to process inputs and produce outputs; see Fig. 1.2.
Target Program output tFigure 1.2: Running the target program
An interpreter is another common kind of language processor. Instead of
producing a target program as a translation, an interpreter appears to directly
execute the operations specified in the source program on inputs supplied by
the user, as shown in Fig. 1.3.
source program 1 Interpreter t- output input
Figure 1.3: An interpreter
The machine-language target program produced by a compiler is usually
much faster than an interpreter at mapping inputs to outputs . An interpreter,
however, can usually give better error diagnostics than a compiler, because it
executes the source program statement by statement.
Example 1.1 : Java language processors combine compilation and interpretation, as shown in Fig. 1.4. A Java source program may first be compiled into
an intermediate form called bytecodes. The bytecodes are tinto machine language
immediately be.
Macroeconomics- Movie Location
This will be used as part of your Personal Professional Portfolio once graded.
Objective:
Prepare a presentation or a paper using research, basic comparative analysis, data organization and application of economic information. You will make an informed assessment of an economic climate outside of the United States to accomplish an entertainment industry objective.
Acetabularia Information For Class 9 .docxvaibhavrinwa19
Acetabularia acetabulum is a single-celled green alga that in its vegetative state is morphologically differentiated into a basal rhizoid and an axially elongated stalk, which bears whorls of branching hairs. The single diploid nucleus resides in the rhizoid.
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
In this webinar you will learn how your organization can access TechSoup's wide variety of product discount and donation programs. From hardware to software, we'll give you a tour of the tools available to help your nonprofit with productivity, collaboration, financial management, donor tracking, security, and more.
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
Synthetic fiber production is a fascinating and complex field that blends chemistry, engineering, and environmental science. By understanding these aspects, students can gain a comprehensive view of synthetic fiber production, its impact on society and the environment, and the potential for future innovations. Synthetic fibers play a crucial role in modern society, impacting various aspects of daily life, industry, and the environment. ynthetic fibers are integral to modern life, offering a range of benefits from cost-effectiveness and versatility to innovative applications and performance characteristics. While they pose environmental challenges, ongoing research and development aim to create more sustainable and eco-friendly alternatives. Understanding the importance of synthetic fibers helps in appreciating their role in the economy, industry, and daily life, while also emphasizing the need for sustainable practices and innovation.
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...Levi Shapiro
Letter from the Congress of the United States regarding Anti-Semitism sent June 3rd to MIT President Sally Kornbluth, MIT Corp Chair, Mark Gorenberg
Dear Dr. Kornbluth and Mr. Gorenberg,
The US House of Representatives is deeply concerned by ongoing and pervasive acts of antisemitic
harassment and intimidation at the Massachusetts Institute of Technology (MIT). Failing to act decisively to ensure a safe learning environment for all students would be a grave dereliction of your responsibilities as President of MIT and Chair of the MIT Corporation.
This Congress will not stand idly by and allow an environment hostile to Jewish students to persist. The House believes that your institution is in violation of Title VI of the Civil Rights Act, and the inability or
unwillingness to rectify this violation through action requires accountability.
Postsecondary education is a unique opportunity for students to learn and have their ideas and beliefs challenged. However, universities receiving hundreds of millions of federal funds annually have denied
students that opportunity and have been hijacked to become venues for the promotion of terrorism, antisemitic harassment and intimidation, unlawful encampments, and in some cases, assaults and riots.
The House of Representatives will not countenance the use of federal funds to indoctrinate students into hateful, antisemitic, anti-American supporters of terrorism. Investigations into campus antisemitism by the Committee on Education and the Workforce and the Committee on Ways and Means have been expanded into a Congress-wide probe across all relevant jurisdictions to address this national crisis. The undersigned Committees will conduct oversight into the use of federal funds at MIT and its learning environment under authorities granted to each Committee.
• The Committee on Education and the Workforce has been investigating your institution since December 7, 2023. The Committee has broad jurisdiction over postsecondary education, including its compliance with Title VI of the Civil Rights Act, campus safety concerns over disruptions to the learning environment, and the awarding of federal student aid under the Higher Education Act.
• The Committee on Oversight and Accountability is investigating the sources of funding and other support flowing to groups espousing pro-Hamas propaganda and engaged in antisemitic harassment and intimidation of students. The Committee on Oversight and Accountability is the principal oversight committee of the US House of Representatives and has broad authority to investigate “any matter” at “any time” under House Rule X.
• The Committee on Ways and Means has been investigating several universities since November 15, 2023, when the Committee held a hearing entitled From Ivory Towers to Dark Corners: Investigating the Nexus Between Antisemitism, Tax-Exempt Universities, and Terror Financing. The Committee followed the hearing with letters to those institutions on January 10, 202
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
A Strategic Approach: GenAI in EducationPeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
2. Why Study Compilers?
Reason #1: understand compilers and languages.
Understand the code structure and language semantics.
Understand relation between source code and generated machine code.
Allow to become a better programmer and increase programmer
productivity and portability
Reason #2: nice balance of theory and practice.
Theory:
Mathematical models: regular expressions, automata, grammars, graphs.
Algorithms that use these models.
Practice:
Apply theoretical notions to build a real compiler.
Reason #3: programming experience.
Creating a compiler entails writing a large computer program which
manipulates complex data structures and implement sophisticated algorithm
Increasing programming capability
3. Language Processors:
Computer programs are generally written in high-level
languages (like C++, Python, and Java).
A language processor, or language translator, is a computer
program that convert source code from one programming
language to another language or human readable language.
They also find errors during translation.
4. Language Processors:
Language Processors includes
– Compilers and translators,
– Interpreters,
– Pre-processors,
– Assemblers,
– Linkers,
– Loaders
5. Compilers
Compiler is a program which translates source program written
in one language to an equivalent program in other language (the
target language).
Usually the source language is a high level language like Java,
C, C++ etc. whereas the target language is machine code or
"code" that a computer's processor understands.
An important role of the compiler is to report any errors in the
source program that it detects during the translation process.
7. Compilers
If the target program is an executable machine-language program, it
can then be called by the user to process inputs and produce outputs;
Interpreters - translate programs written in high-level languages
into machine code that a computer understands.
.
8. Example 2.1:
Java language processors combine compilation and interpretation.
A Java source program may first be compiled into an intermediate form
called bytecodes.
The bytecodes are then interpreted by a virtual machine.
A benefit of this arrangement is that bytecodes compiled on one machine can
be interpreted on another machine, perhaps across a network.
In order to achieve faster processing of inputs to outputs, some Java
compilers, called just-in-time compilers, translate the bytecodes into machine
language immediately before they run the intermediate program to process the
input.
9. Example 2.1:
In order to achieve faster processing of inputs to outputs, some Java
compilers, called just-in-time compilers, translate the bytecodes into machine
language immediately before they run the intermediate program to process the
input.
10. Introduction to Compilers….
The machine-language target program produced by a
compiler is usually much faster than an interpreter at
mapping inputs to outputs .
An interpreter, however, can usually give better error
diagnostics than a compiler, because it executes the source
program statement by statement.
11. Introduction to Compilers ….
The source language is optimized for humans.
– It is more user-friendly, to some extent platform-
independent.
– They are easier to read, write, and maintain, and hence it is
easy to avoid errors.
A program written in any language must be translated into a
form that is understood by the computer.
– This form is typically known as Machine Language (ML)
or Machine Code, or Object Code.
Consists of streams of 0’s and 1’s
12. Introduction to Compilers ….
Some examples of compilers are:
– A Java compiler for the Apple Macintosh
– A COBOL compiler for the SUN
– A C++ compiler for the Apple Macintosh
If a portion of the input to a Java compiler looked like this:
– a = b + c ∗ d;
– the output corresponding to this input might look something like this:
13. Sample Problem 2.1.1
Show the output of a Java native code
compiler, in any typical assembly language, for
the following Java input string: while (x<a+b) x
= 2*x;
14. Introduction to Compilers ….
Figure 2.4: A Compiler and Interpreter produce very different output for the
same input.
15. Introduction to Compilers ….
The input to an interpreter is a program written in a high-level
language, but rather than generating a machine language
program, the interpreter actually carries out the computations
specified in the source program.
In other words, the output of a compiler is a program, whereas
the output of an interpreter is the source program’s output.
16. Sample Problem 2.1.2
Show the compiler output and the interpreter output for the
following Java source code:
for (i=1; i<=4; i++) System.out.println (i*3);
17. Compiler vs. Interpreter
Compiler Interpreter
A compiler is a program that converts the
entire source code of a programming
language into executable machine code.
An interpreter takes a source program
and runs it line by line, translating
each line as it comes to it.
The compiler takes a large amount of time
to analyze the entire source code but the
overall execution time of the program is
comparatively faster.
An interpreter takes less amount of
time to analyze the source code but
the overall execution time of the
program is slower.
The compiler generates the error message
only after scanning the whole program, so
debugging is comparatively hard as the
error can be present anywhere in the
program.
Its Debugging is easier as it continues
translating the program until the error
is met.
The compiler requires a lot of memory for
generating object codes.
It requires less memory than a
compiler because no object code is
generated.
Generates intermediate object code. No intermediate object code is
18. Big C notation for compilers
It is important to remember that a compiler is a program, and it
must be written in some language (machine, assembly, high-
level).
In describing this program, we are dealing with three
languages:
1) The source language, i.e. the input to the compiler,
2) The object language, i.e. the output of the compiler,
3) The language in which the compiler is written
19. Sample Problem 2.1.3
Using the big C notation, show each of the following
compilers:
1) An Ada compiler which runs on the PC and compiles to the
PC machine language.
2) An Ada compiler which compiles to the PC machine
language, but which is written in Ada.
3) An Ada compiler which compiles to the PC machine
language, but which runs on a Sun.
20. Error handling in Compilers
Other kinds of errors not
generally detected by the
compiler are called run-time
errors.
Compile time errors
Syntax errors are reported
by the compiler at compile
time.
21. Assemblers-
Assemblers- translate programs written in low-level or
assembly language into machine code.
Assembly language is called low-level language.
Because there is one to one correspondence between the assembly
language statements and machine language statements.
Symbolic form of the machine language, makes it easy to translate
Compiler generates assembly language as its target language and
assembler translate it into object code.
22. Assemblers-
Assembler is basically the 1st interface that is able to
communicate humans with the machine.
23. Linker
Linker - is responsible for taking object code
generated by the compiler and linking it with
libraries and other object code to create a final
executable program.
It resolves references to external symbols and
creates the complete executable.
Common examples include the GNU linker (ld)
and the Microsoft Visual C++ linker.
24. Loader
Loader - is responsible for loading an executable program
into memory for execution.
It prepares the memory space, reads the binary code, and
resolves any dynamic linking or loading of shared libraries.
This is often done by the operating system's loader
component.
25. A language-processing system
In addition to compiler, several other
programs may be required to create
an executable target program.
A source program may be divided
into modules stored in separate files.
The task of collecting the source
program is the responsibility of
another program called preprocessor.
The target program created by the
compiler may require further
processing before it can be run.
26. The Phases of a Compiler
The structure of a compiler includes;
Lexical analysis,
Syntax analysis,
Semantic Analysis,
Intermediate code generation,
Code Optimization,
Code generation,
Bookkeeping and
Error handling
29. 1. Lexical Analysis
The first phase of a compiler is lexical analysis, also known as
scanning.
The lexical phase reads the characters in the source program
and groups them into a stream of tokens in which each token
represents a logically cohesive sequence of characters, such
as, an identifier, keyword, punctuation character.
The character sequence forming a token is called the lexeme
for the token.
30. Lexical Analysis
A token is basically the arrangement of characters that defines
a unit of information in the source code.
NOTE: In computer science, a program that executes the
process of lexical analysis is called a scanner, tokenizer, or
lexer.
31. Lexical Analysis
Roles and Responsibilities of Lexical Analyzer
It is accountable for terminating the comments
and white spaces from the source program.
It helps in identifying the tokens.
Categorization of lexical units.
32. Lexical Analysis
A token, also known as a lexeme, a lexical item, or a lexical token, is a string
of input characters which is taken as a unit and passed on to the next phase of
compilation.
Examples
key words - while, void, if, for, ...
identifiers - declared by the programmer
operators - +, -, *, /, =, ==, ...
numeric constants - numbers such as 124, 12.35, 0.09E-23, etc.
33. Lexical Analysis
Examples
character constants - single characters or strings of characters enclosed in
quotes
special characters - characters used as delimiters such as . ( ) , ; :
comments - ignored by subsequent phases. These must be identified by the
scanner, but are not included in the output.
35. 2. Syntax Analysis
The second phase of a compiler is syntax analysis, also known
as parsing.
This phase takes the stream of tokens generated by the lexical
analysis phase and checks whether they conform to the
grammar of the programming language.
The output of this phase is usually an Abstract Syntax Tree
(AST).
36. Syntax Analysis
It accepts tokens as input and provides a
parse tree as output. It is also known as
parsing in a compiler.
37. The parser will check for proper syntax, issue appropriate error messages,
and determine the underlying structure of the source program.
The output of this phase may be a stream of atoms or a collection of syntax
trees.
An atom is an atomic operation, or one that is generally available with one
machine language instruction(s) on most target machines.
For example, MULT, ADD, and MOVE could represent atomic operations
for multiplication, addition, and moving data in memory.
38. Each atom consists of three or four parts:
an operation,
one or two operands, and
a result.
Example –
(ADD, A, B, C)
39. Sample Problem 2.2.5
Show the atoms corresponding to the following
Java statement:
a = b + c * d ;
Solution:
(MULT, c, d, temp1)
(ADD, b, temp1, temp2)
(MOVE, temp2, a)
40. Syntax Analysis
Roles and Responsibilities of Syntax Analyzer
Note syntax errors.
Helps in building a parse tree.
Acquire tokens from the lexical analyzer.
Scan the syntax errors, if any.
41. Semantic Analysis
This phase checks whether the code is
semantically correct, i.e., whether it conforms
to the language’s type system and other
semantic rules.
Roles and Responsibilities of Semantic
Analyzer:
Saving collected data to symbol tables or syntax
trees.
It notifies semantic errors.
Scanning for semantic errors.
42. Intermediate Code Generation
This phase generates an intermediate representation of the source code that
can be easily translated into machine code.
A middle-level language code generated by a compiler at the time of the
translation of a source program into the object code is known as intermediate
code or text.
Roles and Responsibilities:
Helps in maintaining the priority ordering of the source
language.
Translate the intermediate code into the machine code.
Having operands of instructions.
43. Optimization
This phase applies various optimization
techniques to the intermediate code to improve
the performance of the generated machine
code.
Roles and Responsibilities:
Remove the unused variables and unreachable code.
Enhance runtime and execution of the program.
Produce streamlined code from the intermediate expression.
44. Code Generation
The final phase of a compiler is code
generation.
This phase takes the optimized intermediate
code and generates the actual machine code
that can be executed by the target hardware.
Roles and Responsibilities:
Translate the intermediate code to target machine
code.
Select and allocate memory spots and registers.
45. Phases in Compiler
Generally, phases are divided into two parts:
Front End phases: These phases are source
language-dependent and target machine,
independents. These generally consist
of lexical analysis, semantic
analysis, syntactic analysis, symbol table
creation, and intermediate code generation.
The front-end part also includes the error
handling that goes along with each of the
phases.
Back End phases: The portions of
compilers that depend on the target machine
and do not depend on the source language.
In the back end, code generation and code
optimization phases, along with error
handling and symbol table operations.
46. Symbol Table
The symbol table is mainly known as the data structure of the compiler.
It helps in storing the identifiers with their name and types.
It stores:
Information about the identifier such as,
– its type, (by semantic and intermediate code)
– its scope, (by semantic and intermediate code)
– storage allocation, (by code generation)
– number of arguments and its type for procedure, the type returned.
It stores the literal constants and strings.
It helps in storing the function names.
It also prefers to store variable names and constants.
It stores labels in source languages.
47. Error Detecting and
Reporting
Each phase encounters errors.
Lexical phase determine the input that do not
form token.
Syntax phase determine the token that violates
the syntax rule.
Semantic phase detects the constructs that have
no meaning to operand.
48. Example These phases are illustrated by considering the
following statement: position := initial + rate *60
49. Compiler writing tools
The compiler writer can use some specialized
tools that help in implementing various phases of
a compiler.
These tools assist in the creation of an entire
compiler or its parts.
Some commonly used compiler construction tools
include:
Parser generators.
YACC,
Scanner generators.
LEX
Syntax-directed translation engines.