COMPILER CONSTRUCTION AND PROJECT
DEVELOPMENT.
What is Compiler Construction course?
Course Description: The course is intended to teach the students the basic
techniques that underlie the practice of Compiler Construction. The
course will introduce the theory and tools that can be employed in order to
perform syntax-directed translation of a high-level programming language into
an executable code.
In computing, a compiler is a computer program that transforms source
code written in a programming language or computer language, into
another computer language. The most common reason for transforming
source code is to create an executable program.
What you'll learn
Compiler construction and compiler design complete course in a very
easy and simple approach
Different Phases of Compiler Construction:
1. Lexical Analysis (scanner) Phase
2. Syntax Analysis (parser) Phase
3. Semantics Analysis (mapper) Phase
4. Code Optimization Phase
5. Code Generation Phase
6. Compiler Projects
7. Compiler Quizzes
Requirements
If you have zero knowledge of compiler, I claim, you will learn this course
without any problem
No programming experience needed, I will teach you everything you need to
know
You have need a little knowledge about computer related terms like input,
output, cpu, computer language etc.
This compiler construction course will teach you the lessons that have taken
years to learn
A Mac or PC computer or any Smart phone.
Description
Welcome to the course of Compiler Construction from scratch!!!!
BRIEF HISTORY OF COMPILER
The first compiler was developed between 1954 and 1957 The FORTRAN
language and its compiler by a team at IBM led by John Backus, The structure
of natural language was studied at about the same time by Noam Chomsky.
The related theories and algorithms in the 1960s and 1970s The classification
of language: Chomsky hierarchy the parsing problem was pursued:
Context-free language, parsing algorithms the symbolic methods for expressing
the structure of the words of a programming language:
Finite automata, Regular expressions Methods have been developed for
generating efficient object code:
Optimization techniques or code, improvement techniques
Programs were developed to automate the complier development for
parsing
Parser generators, such as Yacc by Steve Johnson in 1975 for the Unix
system
Scanner generators, such as Lex by Mike Lesk for Unix system about
same time
PROGRAMS RELATED TO COMPILER.
1. Interpreters: Execute the source program immediately rather than generating
object code
• Examples: BASIC, LISP, used often in educational or development
situations
• Speed of execution is slower than compiled code by a factor of 10 or more
• Share many of their operations with compilers
2. Assemblers:
• A translator for the assembly language of a particular computer
• Assembly language is a symbolic form of one machine language
• A compiler may generate assembly language as its target language and
an assembler finished the translation into object code.
3. Linkers:
• Collect separate object files into a directly executable file
• Connect an object program to the code for standard library functions
and to resource supplied by OS
Becoming one of the principle activities of a compiler, depends on OS and
processor.
4. Loaders:
• Resolve all re-locatable address relative to a given base
• Make executable code more flexible
• Often as part of the operating environment, rarely as an actual separate
program
5. Preprocessors:
• Delete comments, include other files, and perform macro substitutions
• Required by a language (as in C) or can be later add-ons that provide
additional facilities
6. Editors:
• Compiler have been bundled together with editor and other programs
into an interactive development environment (IDE)
• Oriented toward the format or structure of the programming language,
called structure- based
• May include some operations of a compiler, informing some errors
7. Debuggers:
• Used to determine execution error in a compiled program
• Keep tracks of most or all of the source code information
• Halt execution at pre-specified locations called breakpoints
• Must be supplied with appropriate symbolic information by the compiler
8. Profiles:
• Collect statistics on the behavior of an object program during
execution
– Called Times for each procedures
– Percentage of execution time
• Used to improve the execution speed of the program.
9. Project Managers:
• Coordinate the files being worked on by different people, maintain
coherent version of a program
• Language-independent or bundled together with a compiler
• Two popular project manager programs on Unix system
– Sccs (Source code control system)
– Rcs (revision control system)
Mastering the concepts of Compiler Construction is very important to get
started with Computer Science because Compiler is a program which
translate higher level language code like ( int a = 10 +10) to assembly
language code or direct to machine code. Compiler do this job of converting
higher level language code to assembly code in many phases. There are many
books and online courses available in market on compiler construction and
design, but as my personnel experience as a student of computer science,
many of them are too lengthy or short, many of these books are covering only
Theoretical Aspect of the course, and many of them only full with lots of
headache code. Therefore, I often felt difficulties in choosing the right book or
online course for learning the compiler construction course. Therefore, I
decided to prepare an online video course for the students of computer science
to cover the concept of compiler construction and compiler design in a very
easy and descriptive way. I prepare this course only for those students who fell
always difficulties in learning this subject and for those who wish to learn
compiler design for the first time.
OBJECTIVES
Be able to build a compiler for a (simplified) (programming) language
Know how to use compiler construction tools, such as generators of
scanners and parsers
Be familiar with assembly code and virtual machines, such as the
JVM, and bytecode
Be able to define LL(1), LR(1), and LALR(1) grammars
Be familiar with compiler analysis and optimization techniques
COMPILERS AND INTERPRETERS.
• “Compilation”
– Translation of a program written in a source language into a
semantically equivalent program written in a target language
Oversimplified view:
The picture below shows the compilations process.
Compilers and Interpreters.
“Interpretation” Performing the operations implied by the source program
Oversimplified view:
The Analysis-Synthesis Model of Compilation.
• There are two parts to compilation:
– Analysis determines the operations implied by the source program
which are recorded in a tree structure
– Synthesis takes the tree structure and translates the operations
therein into the target program
Types of Compiler
Cross Compilers. They produce an executable machine code for a platform
but, this platform is not the one on which the compiler is running.
Bootstrap Compilers. These compilers are written in a programming language
that they have to compile.
PREPROCESSORS, COMPILERS, ASSEMBLERS, AND LINKERS
In this course, every concept of Compiler Construction and Compiler
Design is taught in an easy way. you will be able to go through all phase of
Compiler design in an easy and understandable way. You will learn all the
phases of compiler:
1. Lexical analysis phase.
2. Syntax analysis phase.
3. Semantic analysis phase.
4. Source Code optimizer.
5. Code generation phase.
6. Target Code Optimizer.
COMPILER-CONSTRUCTION TOOLS.
Software development tools are available to implement one or more compiler
phases
Scanner generators
Parser generators
Syntax-directed translation engines
Automatic code generators
Data-flow engines
THE TRANSLATION PROCESS.
Major Data Structure in a
Compiler
NEXT LECTURE