Chapter 1 - Introduction
Chapter 1 - Introduction
Chapter 1 - Introduction
Instructor: Mohammed O.
Email: momoumer90@gmail.com
Samara University
Preliminaries Required
oBasic knowledge of programming languages.
oBasic knowledge of FSA and CFG.
Chapter One: Introduction
This Chapter Covers:
Phases of a Compiler
Compiler Construction Tool
Introduction
Programming languages are notations for describing
computations (study) to people and to machines.
Before a program can be run, it first must be translated
into a form that can be executed by a computer.
Top-Down Parsing:
Construction of the parse tree starts at the root, and
proceeds towards the leaves.
Efficient top-down parsers can be easily constructed by
hand.
Recursive Predictive Parsing, Non-Recursive Predictive
Parsing (LL Parsing).
Parsing Techniques (Cont.)
Bottom-Up Parsing:
Construction of the parse tree starts at the leaves, and
proceeds towards the root.
Normally efficient bottom-up parsers are created with the
help of some software tools.
Bottom-up parsing is also known as shift-reduce parsing.
LR Parsing – much general form of shift-reduce parsing,
LR, SLR, LALR
Semantic Analyzer
A semantic analyzer checks the source program for
semantic errors and collects the type information for the
code generation.
Type-checking is an important part of semantic analyzer.
Ex:
MULT id2,id3,temp1
ADD temp1,#1,id1
Code Generator
The main purpose of code generator is to write a code that
the machine can understand (Produces the target
language).
The target program is normally is a relocatable object file
containing the machine codes.
Ex:
MOVE id2,R1
MULTid3,R1
ADD #1,R1
MOVE R1,id1
Symbol Table
This portion of the compiler keeps track of the names used
by the programme and records essential information about
each, such as its type (integer, real, etc.).