0% found this document useful (0 votes)
18 views3 pages

Introduction To Compiling

A compiler is a program that translates a high-level language program into a low-level language program so that it can run on a computer. The compilation process has two main parts - analysis of the source program and synthesis of the source program. Analysis involves lexical, syntax and semantic analysis to understand the structure and meaning of the program. Synthesis optimizes the code and generates target code by translating instructions into machine code.

Uploaded by

Vikas Manchal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views3 pages

Introduction To Compiling

A compiler is a program that translates a high-level language program into a low-level language program so that it can run on a computer. The compilation process has two main parts - analysis of the source program and synthesis of the source program. Analysis involves lexical, syntax and semantic analysis to understand the structure and meaning of the program. Synthesis optimizes the code and generates target code by translating instructions into machine code.

Uploaded by

Vikas Manchal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Introduction to Compiling

Definition: A compiler is a program that translates a high-


level language program into a functionally equivalent low
level language program. Basically, it is a translator whose
source language (the language to be translated) is a high-
level language, and the target language (the language into
which the source language is to be translated) is a low-level
language. In other words, a compiler is used to implement a
high-level language on a computer.

analysis of the source program


two parts of compilation:
1. Analysis of source program
2. Synthesis of source program

Source Analysis Synthesis Target



program phase phase program

1. Lexical Analysis: It determines the lexical constituents in


the source string by reading the stream of characters
from left to right and grouping them into tokens. A
token is a sequence of characters having a collective
meaning.
2. Syntax Analysis: It determines the structure of the source
string by grouping them into nested collections with
collective meaning.

3. Semantic Analysis: It determines the meaning of source


string and ensures that components of a program fit together
meaningfully.

The synthesis step consists of two phases.

1. Code Optimization: It tries to improve the intermediate


code to achieve a faster running machine code.

2. Code Generation: It generates the target code. Memory


allocations are done for each of the variables used by the
program. Intermediate instructions are then translated into a
sequence of machine instructions.

the phases of a compiler


the grouping of phases, Compiler Construction tools, A
simple one-pass compiler.

You might also like