SlideShare a Scribd company logo
Language Translators
Language translators convert programming source code into language that the computer
processor understands. Programming source code has various structures and commands, but
computer processors only understand machine language. Different types of translations must
occur to turn programming source code into machine language, which is made up of bits of
binary data. The three major types of language translators are compilers, assemblers, and
interpreters.

   1. Compilers
Most 3GL and higher-level programming languages use a compiler for language translation. A
compiler is a special program that takes written source code and turns it into machine language.
When a compiler executes, it analyzes all of the language statements in the source code and
builds the machine language object code. After a program is compiled, it is then a form that the
processor can execute one instruction at a time.

In some operating systems, an additional step called linking is required after compilation.
Linking resolves the relative location of instructions and data when more than one object module
needs to be run at the same time and both modules cross-reference each otherüs instruction
sequences or data.

Most high-level programming languages come with a compiler. However, object code is unique
for each type of computer. Many different compilers exist for each language in order to translate
for each type of computer. In addition, the compiler industry is quite competitive, so there are
actually many compilers for each language on each type of computer. Although they require an
extra step before execution, compiled programs often run faster than programs executed using an
interpreter.

A compiler is a computer program (or set of programs) that transforms source code written in a
computer language (the source language) into another computer language (the target language,
often having a binary form known as object code). The most common reason for wanting to
transform source code is to create an executable program.

The name "compiler" is primarily used for programs that translate source code from a high-level
programming language to a lower level language (e.g., assembly language or machine code). A
program that translates from a low level language to a higher level one is a decompiler. A
program that translates between high-level languages is usually called a language translator,
source to source translator, or language converter. A language rewriter is usually a program
that translates the form of expressions without a change of language.

A compiler is likely to perform many or all of the following operations: lexical analysis,
preprocessing, parsing, semantic analysis, code generation, and code optimization.
a) NATIVE AND CROSS COMPILERS

A native or hosted compiler is one whose output is intended to directly run on the same type of
computer and operating system that the compiler itself runs on. The output of a cross compiler is
designed to run on a different platform. Cross compilers are often used when developing
software for embedded systems that are not intended to support a software development
environment.

The output of a compiler that produces code for a virtual machine (VM) may or may not be
executed on the same platform as the compiler that produced it. For this reason such compilers
are not usually classified as native or cross compilers.

   b) ONE PASS AND MULTI PASS COMPILERS

Classifying compilers by number of passes has its background in the hardware resource
limitations of computers. Compiling involves performing lots of work and early computers did
not have enough memory to contain one program that did all of this work. So compilers were
split up into smaller programs which each made a pass over the source (or some representation of
it) performing some of the required analysis and translations.

The ability to compile in a single pass is often seen as a benefit because it simplifies the job of
writing a compiler and one pass compilers generally compile faster than multi-pass compilers.
Many languages were designed so that they could be compiled in a single pass (e.g., Pascal).

The front end analyzes the source code to build an internal representation of the program, called
the intermediate representation or IR. It also manages the symbol table, a data structure mapping
each symbol in the source code to associated information such as location, type and scope. This
is done over several phases, which includes some of the following:

   1. Line reconstruction. Languages which strop their keywords or allow arbitrary spaces
      within identifiers require a phase before parsing, which converts the input character
      sequence to a canonical form ready for the parser. The top-down, recursive-descent,
      table-driven parsers used in the 1960s typically read the source one character at a time
      and did not require a separate tokenizing phase. Atlas Autocode, and Imp (and some
      implementations of Algol and Coral66) are examples of stropped languages whose
      compilers would have a Line Reconstruction phase.
   2. Lexical analysis breaks the source code text into small pieces called tokens. Each token
      is a single atomic unit of the language, for instance a keyword, identifier or symbol name.
      The token syntax is typically a regular language, so a finite state automaton constructed
      from a regular expression can be used to recognize it. This phase is also called lexing or
      scanning, and the software doing lexical analysis is called a lexical analyzer or scanner.
   3. Preprocessing. Some languages, e.g., C, require a preprocessing phase which supports
      macro substitution and conditional compilation. Typically the preprocessing phase occurs
      before syntactic or semantic analysis; e.g. in the case of C, the preprocessor manipulates
      lexical tokens rather than syntactic forms. However, some languages such as Scheme
      support macro substitutions based on syntactic forms.
4. Syntax analysis involves parsing the token sequence to identify the syntactic structure of
      the program. This phase typically builds a parse tree, which replaces the linear sequence
      of tokens with a tree structure built according to the rules of a formal grammar which
      define the language's syntax. The parse tree is often analyzed, augmented, and
      transformed by later phases in the compiler.
   5. Semantic analysis is the phase in which the compiler adds semantic information to the
      parse tree and builds the symbol table. This phase performs semantic checks such as type
      checking (checking for type errors), or object binding (associating variable and function
      references with their definitions), or definite assignment (requiring all local variables to
      be initialized before use), rejecting incorrect programs or issuing warnings. Semantic
      analysis usually requires a complete parse tree, meaning that this phase logically follows
      the parsing phase, and logically precedes the code generation phase, though it is often
      possible to fold multiple phases into one pass over the code in a compiler
      implementation.



   2. Assembler
An assembler translates assembly language into machine language. Assembly language is one
step removed from machine language. It uses computer-specific commands and structure similar
to machine language, but assembly language uses names instead of numbers.

An assembler is similar to a compiler, but it is specific to translating programs written in
assembly language into machine language. To do this, the assembler takes basic computer
instructions from assembly language and converts them into a pattern of bits for the computer
processor to use to perform its operations.

Typically a modern assembler creates object code by translating assembly instruction
mnemonics into opcodes, and by resolving symbolic names for memory locations and other
entities.[1] The use of symbolic references is a key feature of assemblers, saving tedious
calculations and manual address updates after program modifications. Most assemblers also
include macro facilities for performing textual substitution—e.g., to generate common short
sequences of instructions to run inline, instead of in a subroutine.

Assemblers are generally simpler to write than compilers for high-level languages, and have
been available since the 1950s. Modern assemblers, especially for RISC based architectures,
such as MIPS, Sun SPARC, and HP PA-RISC, as well as x86(-64), optimize instruction
scheduling to exploit the CPU pipeline efficiently.

There are two types of assemblers based on how many passes through the source are needed to
produce the executable program. One-pass assemblers go through the source code once and
assumes that all symbols will be defined before any instruction that references them. Two-pass
assemblers (and multi-pass assemblers) create a table with all unresolved symbols in the first
pass, then use the 2nd pass to resolve these addresses. The advantage in one-pass assemblers is
speed - which is not as important as it once was with advances in computer speed and
capabilities. The advantage of the two-pass assembler is that symbols can be defined anywhere
in the program source. As a result, the program can be defined in a more logical and meaningful
way. This makes two-pass assembler programs easier to read and maintain.

More sophisticated high-level assemblers provide language abstractions such as:

      Advanced control structures
      High-level procedure/function declarations and invocations
      High-level abstract data types, including structures/records, unions, classes, and sets
      Sophisticated macro processing
      Object-Oriented features such as encapsulation, polymorphism, inheritance, interfaces

   3. Interpreters
Many high-level programming languages have the option of using an interpreter instead of a
compiler. Some of these languages exclusively use an interpreter. An interpreter behaves very
differently from compilers and assemblers. It converts programs into machine-executable form
each time they are executed. It analyzes and executes each line of source code, in order, without
looking at the entire program. Instead of requiring a step before program execution, an
interpreter processes the program as it is being executed.

In computer science, an interpreter is a computer program which reads source code written in a
high-level programming language, transforms the code to machine code, and executes the
machine code. Using an interpreter, a single source file can produce equal results even in vastly
different systems (e.g. a PC and a PlayStation3). Using a compiler, a single source file can
produce equal results only if it is compiled to distinct, system-specific executables.

Interpreting code is slower than running the compiled code because the interpreter must analyze
each statement in the program each time it is executed and then perform the desired action,
whereas the compiled code just performs the action within a fixed context determined by the
compilation. This run-time analysis is known as "interpretive overhead". Access to variables is
also slower in an interpreter because the mapping of identifiers to storage locations must be done
repeatedly at run-time rather than at compile time. There are various compromises between the
development speed when using an interpreter and the execution speed when using a compiler.
Some systems (e.g., some LISPs) allow interpreted and compiled code to call each other and to
share variables. This means that once a routine has been tested and debugged under the
interpreter it can be compiled and thus benefit from faster execution while other routines are
being developed. Many interpreters do not execute the source code as it stands but convert it into
some more compact internal form. For example, some BASIC interpreters replace keywords with
single byte tokens which can be used to find the instruction in a jump table. An interpreter might
well use the same lexical analyzer and parser as the compiler and then interpret the resulting
abstract syntax tree.
A compiler takes a text file written in a programming language, and converts it into binary code
that a processor can understand: it makes an ".exe" file. You compile only once, then always run
the "exe" file. Borland Turbo C is a compiler: you write in C in a text file, then you compile to
get and exe file.
An interpreter does the same, BUT in real time: each time you run the code, it is "compiled", line
by line: Basic is an interpreter.
An assembler is similar, in the way that, instead of taking a plain text file, ie in C, it takes a code
written in Assembler Mnemonics, and convert it into binaries.
All "executable" files are in binaries (just 1's and 0's) - maybe viewed in hex (0x12de...)
In a nutshell: A compiler takes your source programming code and converts it into an executable
form that the computer can understand. This is a very broad explanation though, because some
compilers only go so far as to convert it into a binary file that must then be "linked" with several
other libraries of code before it can actually execute. Other compilers can compile straight to
executable code. Still other compilers convert it to a sort of tokenized code that still needs to be
semi-interpreted by a virtual machine, such as Java.
An interpreter does not compile code. Instead, it typically reads a source code file statement by
statement and then executes it. Most early forms of BASIC were interpeted languages.
An assembler is similar to a compiler, except that it takes source code written in "Assembly
Language", which is just shorthand for the actual machine/processor specific instructions, values,
and memory locations, and it converts those instructions to the equivalent machine language.
Very fast and small executable code but very tedious to write.
Incidentally, many compilers, especially older C compilers, for example, actually convert the C
source code to assembly language and then pass it through an assembler. The benefit is that
someone adept at assembly can tweak the compiler-generatd assembler code for speed or size.

More Related Content

What's hot

Relational operators
Relational operatorsRelational operators
Programming languages
Programming languagesProgramming languages
Programming languages
Asmasum
 
Graphical Programming
Graphical ProgrammingGraphical Programming
Graphical Programming
Gaditek
 
Compilers
CompilersCompilers
Compilers
Bense Tony
 
Lexical Analysis
Lexical AnalysisLexical Analysis
Lexical Analysis
Munni28
 
Project report
Project reportProject report
Project report
meenalpandey
 
Basic programming concepts
Basic programming conceptsBasic programming concepts
Basic programming concepts
salmankhan570
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python Programming
Kamal Acharya
 
Computer Language Translator
Computer Language TranslatorComputer Language Translator
Computer Language Translator
Ranjeet Kumar
 
Introduction to Computer Programming
Introduction to Computer ProgrammingIntroduction to Computer Programming
Compiler vs interpreter
Compiler vs interpreterCompiler vs interpreter
Compiler vs interpreter
Paras Patel
 
C++ io manipulation
C++ io manipulationC++ io manipulation
C++ io manipulation
Pedro Hugo Valencia Morales
 
What is Compiler?
What is Compiler?What is Compiler?
What is Compiler?
Huawei Technologies
 
What is keyword in c programming
What is keyword in c programmingWhat is keyword in c programming
What is keyword in c programming
Rumman Ansari
 
Structure of the compiler
Structure of the compilerStructure of the compiler
Structure of the compiler
Sudhaa Ravi
 
Tokens in C++
Tokens in C++Tokens in C++
Tokens in C++
Mahender Boda
 
Presentation on generation of languages
Presentation on generation of languagesPresentation on generation of languages
Presentation on generation of languages
Richa Pant
 
Type conversion
Type  conversionType  conversion
Type conversion
PreethaPreetha5
 
Lect 1. introduction to programming languages
Lect 1. introduction to programming languagesLect 1. introduction to programming languages
Lect 1. introduction to programming languages
Varun Garg
 
History of C Programming Language
History of C Programming LanguageHistory of C Programming Language
History of C Programming Language
Niloy Biswas
 

What's hot (20)

Relational operators
Relational operatorsRelational operators
Relational operators
 
Programming languages
Programming languagesProgramming languages
Programming languages
 
Graphical Programming
Graphical ProgrammingGraphical Programming
Graphical Programming
 
Compilers
CompilersCompilers
Compilers
 
Lexical Analysis
Lexical AnalysisLexical Analysis
Lexical Analysis
 
Project report
Project reportProject report
Project report
 
Basic programming concepts
Basic programming conceptsBasic programming concepts
Basic programming concepts
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python Programming
 
Computer Language Translator
Computer Language TranslatorComputer Language Translator
Computer Language Translator
 
Introduction to Computer Programming
Introduction to Computer ProgrammingIntroduction to Computer Programming
Introduction to Computer Programming
 
Compiler vs interpreter
Compiler vs interpreterCompiler vs interpreter
Compiler vs interpreter
 
C++ io manipulation
C++ io manipulationC++ io manipulation
C++ io manipulation
 
What is Compiler?
What is Compiler?What is Compiler?
What is Compiler?
 
What is keyword in c programming
What is keyword in c programmingWhat is keyword in c programming
What is keyword in c programming
 
Structure of the compiler
Structure of the compilerStructure of the compiler
Structure of the compiler
 
Tokens in C++
Tokens in C++Tokens in C++
Tokens in C++
 
Presentation on generation of languages
Presentation on generation of languagesPresentation on generation of languages
Presentation on generation of languages
 
Type conversion
Type  conversionType  conversion
Type conversion
 
Lect 1. introduction to programming languages
Lect 1. introduction to programming languagesLect 1. introduction to programming languages
Lect 1. introduction to programming languages
 
History of C Programming Language
History of C Programming LanguageHistory of C Programming Language
History of C Programming Language
 

Viewers also liked

Type Chart Boltdepot
Type Chart BoltdepotType Chart Boltdepot
Type Chart Boltdepot
Evan Fan
 
9 Two5 Motoring Alternative Fuels Conversion Management White Paper
9 Two5 Motoring Alternative Fuels Conversion Management White Paper9 Two5 Motoring Alternative Fuels Conversion Management White Paper
9 Two5 Motoring Alternative Fuels Conversion Management White Paper
universalffg
 
Bill Gates
Bill GatesBill Gates
Bill Gates
iiit bangalore
 
Tata Bbye
Tata   BbyeTata   Bbye
Tata Bbye
SPARDHAguptA
 
Winter
Winter Winter
Winter
guest4830750
 
Inspire For Dummies
Inspire For DummiesInspire For Dummies
Inspire For Dummies
liberTIC
 
20 bí quyết bán hàng
20 bí quyết bán hàng20 bí quyết bán hàng
20 bí quyết bán hàng
guest3c41775
 
How Much Does Faith Matter
How Much Does Faith MatterHow Much Does Faith Matter
How Much Does Faith Matter
Heather Nichols
 
Marketing trong hoạt động xuất khẩu
Marketing trong hoạt động xuất khẩuMarketing trong hoạt động xuất khẩu
Marketing trong hoạt động xuất khẩu
guest3c41775
 
Financial Solutions in a Troubling Economy
Financial Solutions in a Troubling EconomyFinancial Solutions in a Troubling Economy
Financial Solutions in a Troubling Economy
Stuart Little
 
Certificates of conformity
Certificates of conformityCertificates of conformity
Certificates of conformity
Jana Perackova
 
How Encryption For Strong Security Works
How Encryption For Strong Security WorksHow Encryption For Strong Security Works
How Encryption For Strong Security Works
guestf50fcba
 
Social Sharing for Pharma
Social Sharing for Pharma Social Sharing for Pharma
Social Sharing for Pharma
Wendy Blackburn
 
Phim Tat Trong Excel
Phim Tat Trong ExcelPhim Tat Trong Excel
Phim Tat Trong Excel
guest3c41775
 
Interactive Cloth Simulation
Interactive Cloth SimulationInteractive Cloth Simulation
Interactive Cloth Simulation
guestcdaa770
 
11. Sespsis Targoviste
11. Sespsis Targoviste11. Sespsis Targoviste
11. Sespsis Targoviste
guest785b8e
 
Yeni TTK ve Kurumsallaşma
Yeni TTK ve KurumsallaşmaYeni TTK ve Kurumsallaşma
Yeni TTK ve Kurumsallaşma
Hydron Consulting Grup
 
דוח תובנות עולם הלמידה 2014
דוח תובנות עולם הלמידה 2014דוח תובנות עולם הלמידה 2014
דוח תובנות עולם הלמידה 2014Kineo Israel
 
Germ Warfare Presentation Y Gamble 052709
Germ Warfare Presentation Y Gamble 052709Germ Warfare Presentation Y Gamble 052709
Germ Warfare Presentation Y Gamble 052709
universalffg
 

Viewers also liked (20)

Type Chart Boltdepot
Type Chart BoltdepotType Chart Boltdepot
Type Chart Boltdepot
 
9 Two5 Motoring Alternative Fuels Conversion Management White Paper
9 Two5 Motoring Alternative Fuels Conversion Management White Paper9 Two5 Motoring Alternative Fuels Conversion Management White Paper
9 Two5 Motoring Alternative Fuels Conversion Management White Paper
 
Bill Gates
Bill GatesBill Gates
Bill Gates
 
Tata Bbye
Tata   BbyeTata   Bbye
Tata Bbye
 
Winter
Winter Winter
Winter
 
Inspire For Dummies
Inspire For DummiesInspire For Dummies
Inspire For Dummies
 
20 bí quyết bán hàng
20 bí quyết bán hàng20 bí quyết bán hàng
20 bí quyết bán hàng
 
How Much Does Faith Matter
How Much Does Faith MatterHow Much Does Faith Matter
How Much Does Faith Matter
 
Marketing trong hoạt động xuất khẩu
Marketing trong hoạt động xuất khẩuMarketing trong hoạt động xuất khẩu
Marketing trong hoạt động xuất khẩu
 
Financial Solutions in a Troubling Economy
Financial Solutions in a Troubling EconomyFinancial Solutions in a Troubling Economy
Financial Solutions in a Troubling Economy
 
Certificates of conformity
Certificates of conformityCertificates of conformity
Certificates of conformity
 
Nieuwjaar 2012
Nieuwjaar 2012Nieuwjaar 2012
Nieuwjaar 2012
 
How Encryption For Strong Security Works
How Encryption For Strong Security WorksHow Encryption For Strong Security Works
How Encryption For Strong Security Works
 
Social Sharing for Pharma
Social Sharing for Pharma Social Sharing for Pharma
Social Sharing for Pharma
 
Phim Tat Trong Excel
Phim Tat Trong ExcelPhim Tat Trong Excel
Phim Tat Trong Excel
 
Interactive Cloth Simulation
Interactive Cloth SimulationInteractive Cloth Simulation
Interactive Cloth Simulation
 
11. Sespsis Targoviste
11. Sespsis Targoviste11. Sespsis Targoviste
11. Sespsis Targoviste
 
Yeni TTK ve Kurumsallaşma
Yeni TTK ve KurumsallaşmaYeni TTK ve Kurumsallaşma
Yeni TTK ve Kurumsallaşma
 
דוח תובנות עולם הלמידה 2014
דוח תובנות עולם הלמידה 2014דוח תובנות עולם הלמידה 2014
דוח תובנות עולם הלמידה 2014
 
Germ Warfare Presentation Y Gamble 052709
Germ Warfare Presentation Y Gamble 052709Germ Warfare Presentation Y Gamble 052709
Germ Warfare Presentation Y Gamble 052709
 

Similar to Language translators

2 Programming Language.pdf
2 Programming Language.pdf2 Programming Language.pdf
2 Programming Language.pdf
KINGZzofYouTube
 
Compiler_Lecture1.pdf
Compiler_Lecture1.pdfCompiler_Lecture1.pdf
Compiler_Lecture1.pdf
AkarTaher
 
Compiler Construction introduction
Compiler Construction introductionCompiler Construction introduction
Compiler Construction introduction
Rana Ehtisham Ul Haq
 
Phases of Compiler
Phases of CompilerPhases of Compiler
Phases of Compiler
A. S. M. Shafi
 
Compiler Design Material
Compiler Design MaterialCompiler Design Material
Compiler Design Material
Dr. C.V. Suresh Babu
 
Chapter 2 Program language translation.pptx
Chapter 2 Program language translation.pptxChapter 2 Program language translation.pptx
Chapter 2 Program language translation.pptx
dawod yimer
 
3.2
3.23.2
Introduction to compiler development
Introduction to compiler developmentIntroduction to compiler development
Introduction to compiler development
DeepOad
 
Chapter1pdf__2021_11_23_10_53_20.pdf
Chapter1pdf__2021_11_23_10_53_20.pdfChapter1pdf__2021_11_23_10_53_20.pdf
Chapter1pdf__2021_11_23_10_53_20.pdf
DrIsikoIsaac
 
La 5 Pl Translator
La 5   Pl TranslatorLa 5   Pl Translator
La 5 Pl Translator
Cma Mohd
 
SSD Mod 2 -18CS61_Notes.pdf
SSD Mod 2 -18CS61_Notes.pdfSSD Mod 2 -18CS61_Notes.pdf
SSD Mod 2 -18CS61_Notes.pdf
JacobDragonette
 
Insight into progam execution ppt
Insight into progam execution pptInsight into progam execution ppt
Insight into progam execution ppt
Keerty Smile
 
1 Describe different types of Assemblers.Assembly language.docx
 1 Describe different types of Assemblers.Assembly language.docx 1 Describe different types of Assemblers.Assembly language.docx
1 Describe different types of Assemblers.Assembly language.docx
aryan532920
 
Cd unit i
Cd unit iCd unit i
Cd unit i
Abhimanyu Mishra
 
Lecture 1 introduction to language processors
Lecture 1  introduction to language processorsLecture 1  introduction to language processors
Lecture 1 introduction to language processors
Rebaz Najeeb
 
Chapter#01 cc
Chapter#01 ccChapter#01 cc
Chapter#01 cc
abdulbaki3
 
First session quiz
First session quizFirst session quiz
First session quiz
Keroles karam khalil
 
First session quiz
First session quizFirst session quiz
First session quiz
Keroles karam khalil
 
Ch 1.pptx
Ch 1.pptxCh 1.pptx
Ch 1.pptx
woldu2
 
design intoduction of_COMPILER_DESIGN.pdf
design intoduction of_COMPILER_DESIGN.pdfdesign intoduction of_COMPILER_DESIGN.pdf
design intoduction of_COMPILER_DESIGN.pdf
advRajatSharma
 

Similar to Language translators (20)

2 Programming Language.pdf
2 Programming Language.pdf2 Programming Language.pdf
2 Programming Language.pdf
 
Compiler_Lecture1.pdf
Compiler_Lecture1.pdfCompiler_Lecture1.pdf
Compiler_Lecture1.pdf
 
Compiler Construction introduction
Compiler Construction introductionCompiler Construction introduction
Compiler Construction introduction
 
Phases of Compiler
Phases of CompilerPhases of Compiler
Phases of Compiler
 
Compiler Design Material
Compiler Design MaterialCompiler Design Material
Compiler Design Material
 
Chapter 2 Program language translation.pptx
Chapter 2 Program language translation.pptxChapter 2 Program language translation.pptx
Chapter 2 Program language translation.pptx
 
3.2
3.23.2
3.2
 
Introduction to compiler development
Introduction to compiler developmentIntroduction to compiler development
Introduction to compiler development
 
Chapter1pdf__2021_11_23_10_53_20.pdf
Chapter1pdf__2021_11_23_10_53_20.pdfChapter1pdf__2021_11_23_10_53_20.pdf
Chapter1pdf__2021_11_23_10_53_20.pdf
 
La 5 Pl Translator
La 5   Pl TranslatorLa 5   Pl Translator
La 5 Pl Translator
 
SSD Mod 2 -18CS61_Notes.pdf
SSD Mod 2 -18CS61_Notes.pdfSSD Mod 2 -18CS61_Notes.pdf
SSD Mod 2 -18CS61_Notes.pdf
 
Insight into progam execution ppt
Insight into progam execution pptInsight into progam execution ppt
Insight into progam execution ppt
 
1 Describe different types of Assemblers.Assembly language.docx
 1 Describe different types of Assemblers.Assembly language.docx 1 Describe different types of Assemblers.Assembly language.docx
1 Describe different types of Assemblers.Assembly language.docx
 
Cd unit i
Cd unit iCd unit i
Cd unit i
 
Lecture 1 introduction to language processors
Lecture 1  introduction to language processorsLecture 1  introduction to language processors
Lecture 1 introduction to language processors
 
Chapter#01 cc
Chapter#01 ccChapter#01 cc
Chapter#01 cc
 
First session quiz
First session quizFirst session quiz
First session quiz
 
First session quiz
First session quizFirst session quiz
First session quiz
 
Ch 1.pptx
Ch 1.pptxCh 1.pptx
Ch 1.pptx
 
design intoduction of_COMPILER_DESIGN.pdf
design intoduction of_COMPILER_DESIGN.pdfdesign intoduction of_COMPILER_DESIGN.pdf
design intoduction of_COMPILER_DESIGN.pdf
 

More from Aditya Sharat

Neural networks
Neural networksNeural networks
Neural networks
Aditya Sharat
 
Google apps cloud computing
Google apps cloud computingGoogle apps cloud computing
Google apps cloud computing
Aditya Sharat
 
Deloitte's Cloud Perspectives
Deloitte's Cloud PerspectivesDeloitte's Cloud Perspectives
Deloitte's Cloud Perspectives
Aditya Sharat
 
Virtual Reality
Virtual RealityVirtual Reality
Virtual Reality
Aditya Sharat
 
Number system
Number systemNumber system
Number system
Aditya Sharat
 
Introduction to IT
Introduction to ITIntroduction to IT
Introduction to IT
Aditya Sharat
 
Humanware
HumanwareHumanware
Humanware
Aditya Sharat
 
Generation of computers
Generation of computersGeneration of computers
Generation of computers
Aditya Sharat
 
Flow charts
Flow chartsFlow charts
Flow charts
Aditya Sharat
 
Electronic computer classification
Electronic computer classificationElectronic computer classification
Electronic computer classification
Aditya Sharat
 
MCS
MCSMCS
Unix shell program training
Unix shell program trainingUnix shell program training
Unix shell program training
Aditya Sharat
 
Railway Management system
Railway Management systemRailway Management system
Railway Management system
Aditya Sharat
 
Mobile communication
Mobile communicationMobile communication
Mobile communication
Aditya Sharat
 
Conducting polymers
Conducting polymersConducting polymers
Conducting polymers
Aditya Sharat
 
IS95 CDMA Technology
IS95 CDMA TechnologyIS95 CDMA Technology
IS95 CDMA Technology
Aditya Sharat
 

More from Aditya Sharat (16)

Neural networks
Neural networksNeural networks
Neural networks
 
Google apps cloud computing
Google apps cloud computingGoogle apps cloud computing
Google apps cloud computing
 
Deloitte's Cloud Perspectives
Deloitte's Cloud PerspectivesDeloitte's Cloud Perspectives
Deloitte's Cloud Perspectives
 
Virtual Reality
Virtual RealityVirtual Reality
Virtual Reality
 
Number system
Number systemNumber system
Number system
 
Introduction to IT
Introduction to ITIntroduction to IT
Introduction to IT
 
Humanware
HumanwareHumanware
Humanware
 
Generation of computers
Generation of computersGeneration of computers
Generation of computers
 
Flow charts
Flow chartsFlow charts
Flow charts
 
Electronic computer classification
Electronic computer classificationElectronic computer classification
Electronic computer classification
 
MCS
MCSMCS
MCS
 
Unix shell program training
Unix shell program trainingUnix shell program training
Unix shell program training
 
Railway Management system
Railway Management systemRailway Management system
Railway Management system
 
Mobile communication
Mobile communicationMobile communication
Mobile communication
 
Conducting polymers
Conducting polymersConducting polymers
Conducting polymers
 
IS95 CDMA Technology
IS95 CDMA TechnologyIS95 CDMA Technology
IS95 CDMA Technology
 

Recently uploaded

GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
ThomasParaiso2
 
Data structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdfData structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdf
TIPNGVN2
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 

Recently uploaded (20)

GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
 
Data structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdfData structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdf
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 

Language translators

  • 1. Language Translators Language translators convert programming source code into language that the computer processor understands. Programming source code has various structures and commands, but computer processors only understand machine language. Different types of translations must occur to turn programming source code into machine language, which is made up of bits of binary data. The three major types of language translators are compilers, assemblers, and interpreters. 1. Compilers Most 3GL and higher-level programming languages use a compiler for language translation. A compiler is a special program that takes written source code and turns it into machine language. When a compiler executes, it analyzes all of the language statements in the source code and builds the machine language object code. After a program is compiled, it is then a form that the processor can execute one instruction at a time. In some operating systems, an additional step called linking is required after compilation. Linking resolves the relative location of instructions and data when more than one object module needs to be run at the same time and both modules cross-reference each otherüs instruction sequences or data. Most high-level programming languages come with a compiler. However, object code is unique for each type of computer. Many different compilers exist for each language in order to translate for each type of computer. In addition, the compiler industry is quite competitive, so there are actually many compilers for each language on each type of computer. Although they require an extra step before execution, compiled programs often run faster than programs executed using an interpreter. A compiler is a computer program (or set of programs) that transforms source code written in a computer language (the source language) into another computer language (the target language, often having a binary form known as object code). The most common reason for wanting to transform source code is to create an executable program. The name "compiler" is primarily used for programs that translate source code from a high-level programming language to a lower level language (e.g., assembly language or machine code). A program that translates from a low level language to a higher level one is a decompiler. A program that translates between high-level languages is usually called a language translator, source to source translator, or language converter. A language rewriter is usually a program that translates the form of expressions without a change of language. A compiler is likely to perform many or all of the following operations: lexical analysis, preprocessing, parsing, semantic analysis, code generation, and code optimization.
  • 2. a) NATIVE AND CROSS COMPILERS A native or hosted compiler is one whose output is intended to directly run on the same type of computer and operating system that the compiler itself runs on. The output of a cross compiler is designed to run on a different platform. Cross compilers are often used when developing software for embedded systems that are not intended to support a software development environment. The output of a compiler that produces code for a virtual machine (VM) may or may not be executed on the same platform as the compiler that produced it. For this reason such compilers are not usually classified as native or cross compilers. b) ONE PASS AND MULTI PASS COMPILERS Classifying compilers by number of passes has its background in the hardware resource limitations of computers. Compiling involves performing lots of work and early computers did not have enough memory to contain one program that did all of this work. So compilers were split up into smaller programs which each made a pass over the source (or some representation of it) performing some of the required analysis and translations. The ability to compile in a single pass is often seen as a benefit because it simplifies the job of writing a compiler and one pass compilers generally compile faster than multi-pass compilers. Many languages were designed so that they could be compiled in a single pass (e.g., Pascal). The front end analyzes the source code to build an internal representation of the program, called the intermediate representation or IR. It also manages the symbol table, a data structure mapping each symbol in the source code to associated information such as location, type and scope. This is done over several phases, which includes some of the following: 1. Line reconstruction. Languages which strop their keywords or allow arbitrary spaces within identifiers require a phase before parsing, which converts the input character sequence to a canonical form ready for the parser. The top-down, recursive-descent, table-driven parsers used in the 1960s typically read the source one character at a time and did not require a separate tokenizing phase. Atlas Autocode, and Imp (and some implementations of Algol and Coral66) are examples of stropped languages whose compilers would have a Line Reconstruction phase. 2. Lexical analysis breaks the source code text into small pieces called tokens. Each token is a single atomic unit of the language, for instance a keyword, identifier or symbol name. The token syntax is typically a regular language, so a finite state automaton constructed from a regular expression can be used to recognize it. This phase is also called lexing or scanning, and the software doing lexical analysis is called a lexical analyzer or scanner. 3. Preprocessing. Some languages, e.g., C, require a preprocessing phase which supports macro substitution and conditional compilation. Typically the preprocessing phase occurs before syntactic or semantic analysis; e.g. in the case of C, the preprocessor manipulates lexical tokens rather than syntactic forms. However, some languages such as Scheme support macro substitutions based on syntactic forms.
  • 3. 4. Syntax analysis involves parsing the token sequence to identify the syntactic structure of the program. This phase typically builds a parse tree, which replaces the linear sequence of tokens with a tree structure built according to the rules of a formal grammar which define the language's syntax. The parse tree is often analyzed, augmented, and transformed by later phases in the compiler. 5. Semantic analysis is the phase in which the compiler adds semantic information to the parse tree and builds the symbol table. This phase performs semantic checks such as type checking (checking for type errors), or object binding (associating variable and function references with their definitions), or definite assignment (requiring all local variables to be initialized before use), rejecting incorrect programs or issuing warnings. Semantic analysis usually requires a complete parse tree, meaning that this phase logically follows the parsing phase, and logically precedes the code generation phase, though it is often possible to fold multiple phases into one pass over the code in a compiler implementation. 2. Assembler An assembler translates assembly language into machine language. Assembly language is one step removed from machine language. It uses computer-specific commands and structure similar to machine language, but assembly language uses names instead of numbers. An assembler is similar to a compiler, but it is specific to translating programs written in assembly language into machine language. To do this, the assembler takes basic computer instructions from assembly language and converts them into a pattern of bits for the computer processor to use to perform its operations. Typically a modern assembler creates object code by translating assembly instruction mnemonics into opcodes, and by resolving symbolic names for memory locations and other entities.[1] The use of symbolic references is a key feature of assemblers, saving tedious calculations and manual address updates after program modifications. Most assemblers also include macro facilities for performing textual substitution—e.g., to generate common short sequences of instructions to run inline, instead of in a subroutine. Assemblers are generally simpler to write than compilers for high-level languages, and have been available since the 1950s. Modern assemblers, especially for RISC based architectures, such as MIPS, Sun SPARC, and HP PA-RISC, as well as x86(-64), optimize instruction scheduling to exploit the CPU pipeline efficiently. There are two types of assemblers based on how many passes through the source are needed to produce the executable program. One-pass assemblers go through the source code once and assumes that all symbols will be defined before any instruction that references them. Two-pass assemblers (and multi-pass assemblers) create a table with all unresolved symbols in the first pass, then use the 2nd pass to resolve these addresses. The advantage in one-pass assemblers is speed - which is not as important as it once was with advances in computer speed and
  • 4. capabilities. The advantage of the two-pass assembler is that symbols can be defined anywhere in the program source. As a result, the program can be defined in a more logical and meaningful way. This makes two-pass assembler programs easier to read and maintain. More sophisticated high-level assemblers provide language abstractions such as:  Advanced control structures  High-level procedure/function declarations and invocations  High-level abstract data types, including structures/records, unions, classes, and sets  Sophisticated macro processing  Object-Oriented features such as encapsulation, polymorphism, inheritance, interfaces 3. Interpreters Many high-level programming languages have the option of using an interpreter instead of a compiler. Some of these languages exclusively use an interpreter. An interpreter behaves very differently from compilers and assemblers. It converts programs into machine-executable form each time they are executed. It analyzes and executes each line of source code, in order, without looking at the entire program. Instead of requiring a step before program execution, an interpreter processes the program as it is being executed. In computer science, an interpreter is a computer program which reads source code written in a high-level programming language, transforms the code to machine code, and executes the machine code. Using an interpreter, a single source file can produce equal results even in vastly different systems (e.g. a PC and a PlayStation3). Using a compiler, a single source file can produce equal results only if it is compiled to distinct, system-specific executables. Interpreting code is slower than running the compiled code because the interpreter must analyze each statement in the program each time it is executed and then perform the desired action, whereas the compiled code just performs the action within a fixed context determined by the compilation. This run-time analysis is known as "interpretive overhead". Access to variables is also slower in an interpreter because the mapping of identifiers to storage locations must be done repeatedly at run-time rather than at compile time. There are various compromises between the development speed when using an interpreter and the execution speed when using a compiler. Some systems (e.g., some LISPs) allow interpreted and compiled code to call each other and to share variables. This means that once a routine has been tested and debugged under the interpreter it can be compiled and thus benefit from faster execution while other routines are being developed. Many interpreters do not execute the source code as it stands but convert it into some more compact internal form. For example, some BASIC interpreters replace keywords with single byte tokens which can be used to find the instruction in a jump table. An interpreter might well use the same lexical analyzer and parser as the compiler and then interpret the resulting abstract syntax tree.
  • 5. A compiler takes a text file written in a programming language, and converts it into binary code that a processor can understand: it makes an ".exe" file. You compile only once, then always run the "exe" file. Borland Turbo C is a compiler: you write in C in a text file, then you compile to get and exe file. An interpreter does the same, BUT in real time: each time you run the code, it is "compiled", line by line: Basic is an interpreter. An assembler is similar, in the way that, instead of taking a plain text file, ie in C, it takes a code written in Assembler Mnemonics, and convert it into binaries. All "executable" files are in binaries (just 1's and 0's) - maybe viewed in hex (0x12de...) In a nutshell: A compiler takes your source programming code and converts it into an executable form that the computer can understand. This is a very broad explanation though, because some compilers only go so far as to convert it into a binary file that must then be "linked" with several other libraries of code before it can actually execute. Other compilers can compile straight to executable code. Still other compilers convert it to a sort of tokenized code that still needs to be semi-interpreted by a virtual machine, such as Java. An interpreter does not compile code. Instead, it typically reads a source code file statement by statement and then executes it. Most early forms of BASIC were interpeted languages. An assembler is similar to a compiler, except that it takes source code written in "Assembly Language", which is just shorthand for the actual machine/processor specific instructions, values, and memory locations, and it converts those instructions to the equivalent machine language. Very fast and small executable code but very tedious to write. Incidentally, many compilers, especially older C compilers, for example, actually convert the C source code to assembly language and then pass it through an assembler. The benefit is that someone adept at assembly can tweak the compiler-generatd assembler code for speed or size.