What am I?. Translators Translators – Module Knowledge Areas Types of translators and their use Lexical analysis Syntax analysis Code generation and.

Slides:



Advertisements
Similar presentations
GCSE Computing Lesson 5.
Advertisements

compilers and interpreters
Dr. Ken Hoganson, © August 2014 Programming in R COURSE NOTES 2 Hoganson Language Translation.
The Functions and Purposes of Translators Code Generation (Intermediate Code, Optimisation, Final Code), Linkers & Loaders.
Creating a Program In today’s lesson we will look at: what programming is different types of programs how we create a program installing an IDE to get.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design First Edition by Tony Gaddis.
Program Flow Charting How to tackle the beginning stage a program design.
Program Flow Charting How to tackle the beginning stage a program design.
Chapter 16 Programming and Languages: Telling the Computer What to Do.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 1, Lab.
Compilers and Interpreters. Translation to machine language Every high level language needs to be translated to machine code There are different ways.
PRE-PROGRAMMING PHASE
Programming. Software is made by programmers Computers need all kinds of software, from operating systems to applications People learn how to tell the.
Compiled by Benjamin Muganzi 3.2 Functions and Purposes of Translators Computing 9691 Paper 3 1.
Activity 1 - WBs 5 mins Go online and spend a moment trying to find out the difference between: HIGH LEVEL programming languages and LOW LEVEL programming.
Programming In C++ Spring Semester 2013 Programming In C++, Lecture 1.
CHAPTER 4: INTRODUCTION TO COMPUTER ORGANIZATION AND PROGRAMMING DESIGN Lec. Ghader Kurdi.
P51UST: Unix and Software Tools Unix and Software Tools (P51UST) Compilers, Interpreters and Debuggers Ruibin Bai (Room AB326) Division of Computer Science.
Basics Programming Concepts. Basics A computer program is a set of instructions to tell a computer what to do Machine language = circuit level language.
สาขาวิชาเทคโนโลยี สารสนเทศ คณะเทคโนโลยีสารสนเทศ และการสื่อสาร.
High level & Low level language High level programming languages are more structured, are closer to spoken language and are more intuitive than low level.
An intro to programming. The purpose of writing a program is to solve a problem or take advantage of an opportunity Consists of multiple steps:  Understanding.
Higher Grade Computing Studies 2. Languages and Environments Higher Computing Software Development S. McCrossan 1 Classification of Languages 1. Procedural.
Parser-Driven Games Tool programming © Allan C. Milne Abertay University v
Introduction to C++ Programming Language
3/5/2009Computer software1 Introduction Computer System Hardware Software HW Kernel/OS API Application Programs SW.
What on Earth? LEXEMETOKENPATTERN print p,r,i,n,t (leftpar( 4number4 *arith* 5number5 )rightpar) userAnswerID Letter followed by letters and digits “Game.
I Power Higher Computing Software Development Development Languages and Environments.
What Do I Represent?. Translators – Module Knowledge Areas Revisiting object code When we disassemble code we can view the opcodes used This is just a.
Chapter 1 Introduction. Chapter 1 -- Introduction2  Def: Compiler --  a program that translates a program written in a language like Pascal, C, PL/I,
A compiler is a computer program that translate written code (source code) into another computer language Associated with high level languages A well.
 Programming - the process of creating computer programs.
What am I? while b != 0 if a > b a := a − b else b := b − a return a AST == Abstract Syntax Tree.
 Computer Languages Computer Languages  Machine Language Machine Language  Assembly Language Assembly Language  High Level Language High Level Language.
By: Cheryl Mok & Sarah Tan. Java is partially interpreted. 1. Programmer writes a program in textual form 2. Runs the compiler, which converts the textual.
The single most important skill for a computer programmer is problem solving Problem solving means the ability to formulate problems, think creatively.
The Functions and Purposes of Translators Translators, Interpreters and Compilers - High Level Languages.
Programming Objectives What is a programming language? Difference between source code and machine code What is python? – Where to get it from – How to.
ICS312 Introduction to Compilers Set 23. What is a Compiler? A compiler is software (a program) that translates a high-level programming language to machine.
Compilers and Interpreters
OCR A Level F453: The function and purpose of translators Translators a. describe the need for, and use of, translators to convert source code.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
Objective of the course Understanding the fundamentals of the compilation technique Assist you in writing you own compiler (or any part of compiler)
History of C and basics of Programming
Topic 2: Hardware and Software
Why don’t programmers have to program in machine code?
Component 1.6.
Introduction to programming
Programming Language Hierarchy, Phases of a Java Program
CSCI-235 Micro-Computer Applications
Lecture 1: Introduction to JAVA
A451 Theory – 7 Programming 7A, B - Algorithms.
Teaching Computing to GCSE
TRANSLATORS AND IDEs Key Revision Points.
Teaching Computing to GCSE
Translators & Facilities of Languages
Language is a medium of communication.
Assembler, Compiler, Interpreter
High Level Programming Languages
CMP 131 Introduction to Computer Programming
Programming.
Assembler, Compiler, Interpreter
ICT Programming Lesson 1:
Tonga Institute of Higher Education IT 141: Information Systems
An Introduction to Programming with C++ Fifth Edition
Tonga Institute of Higher Education IT 141: Information Systems
Chapter 1 Introduction.
Programming language translators
Presentation transcript:

What am I?

Translators

Translators – Module Knowledge Areas Types of translators and their use Lexical analysis Syntax analysis Code generation and optimisation Library routines

Translators – Module Learning Objectives describe the need for, and use of, translators to convert source code to object code understand the relationship between assembly language and machine code describe the use of an assembler in producing machine code describe the difference between interpretation and compilation describe the purpose of intermediate code in a virtual machine describe what happens during lexical analysis describe what happens during syntax analysis, explaining how errors are handled explain the code generation phase and understand the need for optimisation describe the use of library routines

Translators Describe the need for, and use of, translators to convert source code to object code What is source code? Source code is the program instructions you as a programmer create eg print(“The Game of Jones”) is the source code for a Python program As this is written in a high level language it is meaningless to a computer – it must be translated into object code So, what is object code?

Translators – Example Try this: import dis def objectMe() num1 = 8 num2 = 9 print(num1 * num2) Run it and at the chevron input dis.dis(objectMe)

Translators – Object Code Output Notice the use of mnemonics to call modules eg LOAD_CONST The numbers just before the mnemonics refer to byte offset

Translators – Process Congratulations, you have created object code The process was: Create source code – the Python script Run – compiles the code (we used the dis module to disassemble the bytecode) The bytecode/object code (compiled code) is executed by the Python virtual machine Bytecode is converted to machine code Simple View Actual View

Translators – Why? TASK – WHY OBJECT CODE? Why do we need object code? Using your disassembled code, what is being shown? What is the relationship between source code, object code and a virtual machine? Complete in “Why object code?” in Moodle

Translators – Debugging Try this: import dis a = 4 b = b + 4 After the chevron input: dis.distb() What has happended?

Translators – Debugging What is the red text telling you? How can we use the object code view to assist with debugging?

Translators – Module Learning Objectives So, why translators? We have already seen that Python source code is assembled into byte code / object code The object code separates the source code into a series of instructions. Object code is also referred to as intermediate code. Intermediate because it sits between High Level source code and machine code. The assembler translates the object code into machine code Object code instructions are readable by the virtual machine The virtual machine is independent of hardware (eg 32/64 bit machines, Windows/IOS, RISC/CISC) The translation into object code is an opportunity for the syntax to be verified. Python has an IDE that will flag syntax errors. This is an example of translator diagnostics (the problem is diagnosed) Once object code is compiled and deemed free of syntax errors it is then translated into machine code by the assembler

Translators – What is a Translator? Explain what a translator is with reference to the source code and object code stage Why is not a good idea to compile source code straight into machine code? What problems might be encountered?