operating systems and language translators cis 2380 term 2 – language translators lee mccluskey...

16
OPERATING SYSTEMS AND LANGUAGE TRANSLATORS CIS 2380 TERM 2 – LANGUAGE TRANSLATORS Lee McCluskey – [email protected] 23/08/22 1

Upload: charlotte-morton

Post on 29-Dec-2015

230 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: OPERATING SYSTEMS AND LANGUAGE TRANSLATORS CIS 2380 TERM 2 – LANGUAGE TRANSLATORS Lee McCluskey – lee@hud.ac.uklee@hud.ac.uk 23/09/20151

OPERATING SYSTEMS AND LANGUAGE TRANSLATORS

CIS 2380

TERM 2 – LANGUAGE TRANSLATORS

Lee McCluskey – [email protected]

19/04/23 1

Page 2: OPERATING SYSTEMS AND LANGUAGE TRANSLATORS CIS 2380 TERM 2 – LANGUAGE TRANSLATORS Lee McCluskey – lee@hud.ac.uklee@hud.ac.uk 23/09/20151

TERM 2 resources…

http//scom.hud.ac.uk/scomtlm/cis2380/

There will be a link from Unilearn.

19/04/23 2

Page 3: OPERATING SYSTEMS AND LANGUAGE TRANSLATORS CIS 2380 TERM 2 – LANGUAGE TRANSLATORS Lee McCluskey – lee@hud.ac.uklee@hud.ac.uk 23/09/20151

TERM 2 format …

1 Lecture + 1 Tutorial or Practical

A mix of practical + theory.

19/04/23 3

Page 4: OPERATING SYSTEMS AND LANGUAGE TRANSLATORS CIS 2380 TERM 2 – LANGUAGE TRANSLATORS Lee McCluskey – lee@hud.ac.uklee@hud.ac.uk 23/09/20151

Assessment

One exam covering all term 2 material, 50% of module. You will be given 4 questions of which you have to choose 3 question to do in 2 hours.

The exam is “closed book” – you must remember stuff !

19/04/23 4

Page 5: OPERATING SYSTEMS AND LANGUAGE TRANSLATORS CIS 2380 TERM 2 – LANGUAGE TRANSLATORS Lee McCluskey – lee@hud.ac.uklee@hud.ac.uk 23/09/20151

Language Translators Computer Systems are full of FORMAL

LANGUAGES – HTML, XML, Java, Pascal, BNF, Z, VDM, Python, Lingo, C++ …

There are languages for programming, for data, for database manipulation, for mark-up, for specification ..

Sentences (programs) of LANGUAGES have to be compiled/interpreted/translated/executed/analysed

by programs

19/04/23 5

Page 6: OPERATING SYSTEMS AND LANGUAGE TRANSLATORS CIS 2380 TERM 2 – LANGUAGE TRANSLATORS Lee McCluskey – lee@hud.ac.uklee@hud.ac.uk 23/09/20151

Compilers Are the most commonly known language

translator A COMPILER translates a program P written in

a ‘HIGH LEVEL’ language into a program Q written in a ‘LOW LEVEL’ language eg Java -> Byte code

Question: what is the relationship between programs P and Q ??????????

19/04/23 6

Page 7: OPERATING SYSTEMS AND LANGUAGE TRANSLATORS CIS 2380 TERM 2 – LANGUAGE TRANSLATORS Lee McCluskey – lee@hud.ac.uklee@hud.ac.uk 23/09/20151

Interpreters Are commonly known language translators

What is the difference between Interpreters and Compilers?

19/04/23 7

Page 8: OPERATING SYSTEMS AND LANGUAGE TRANSLATORS CIS 2380 TERM 2 – LANGUAGE TRANSLATORS Lee McCluskey – lee@hud.ac.uklee@hud.ac.uk 23/09/20151

Interpreters Are commonly known language translators

What is the difference between Interpreters and Compilers?

ANSWER: Interpreters analyse a program written in a ‘HIGH LEVEL’ language AND execute it. Eg languages such as Prolog, Scheme, Haskell, Basic have interpreters Compilers analyse then translate,

Interpreters analyse then execute.

Interpreted code execution is invariably slower than compiled code execution..

19/04/23 8

Page 9: OPERATING SYSTEMS AND LANGUAGE TRANSLATORS CIS 2380 TERM 2 – LANGUAGE TRANSLATORS Lee McCluskey – lee@hud.ac.uklee@hud.ac.uk 23/09/20151

Some Jargon Syntax – the ‘marks’ or ‘symbols’ used in a

language Syntax Specification – the set of symbols used

in a language and the legal order that they may occur

GRAMMARS are often used to precisely specify syntax of languages

19/04/23 9

Page 10: OPERATING SYSTEMS AND LANGUAGE TRANSLATORS CIS 2380 TERM 2 – LANGUAGE TRANSLATORS Lee McCluskey – lee@hud.ac.uklee@hud.ac.uk 23/09/20151

Some JargonLexical Analysis – analysing the characters that

make up program/sentence syntax to work out the components of the program/sentence

Eg I f ( x x x x == 2 3 4 5 ) y y y = 4 2 ETC

Are a sequence of characters. After lexical analysis this might translate to:

Keyword(if) openbracket identifier(xxxx) operator(==) integer(2345) closedbracket Identifier(yyy) operator(=) integer(42) ….

19/04/23 10

Page 11: OPERATING SYSTEMS AND LANGUAGE TRANSLATORS CIS 2380 TERM 2 – LANGUAGE TRANSLATORS Lee McCluskey – lee@hud.ac.uklee@hud.ac.uk 23/09/20151

Some JargonParsing – analysing the components of the

program/sentence to work out its syntactic structure

IF-construct

Keyword(if) openbracket identifier(xxxx) operator(==) integer(2345)

Boolean Expression

Statement

19/04/23 11

Page 12: OPERATING SYSTEMS AND LANGUAGE TRANSLATORS CIS 2380 TERM 2 – LANGUAGE TRANSLATORS Lee McCluskey – lee@hud.ac.uklee@hud.ac.uk 23/09/20151

TERM 2 contents …

Theory of Languages revision, Grammars and Properties of Grammars

Lexical Analysis, Scanning Parsing Automated Parser Generation Symbol Tables Other topics related to Compilers

CODEANALYSIS

19/04/23 12

Page 13: OPERATING SYSTEMS AND LANGUAGE TRANSLATORS CIS 2380 TERM 2 – LANGUAGE TRANSLATORS Lee McCluskey – lee@hud.ac.uklee@hud.ac.uk 23/09/20151

Related Subjects

Software Design: Compilers/interpreters can be very complex programs – they require good software development skills

Theory of computing: A great deal of the theory of automata, and grammars, is used to inform the practical pursuit of building language translators

Syntax and Semantics of Programs: You have to know how a language is structured, and what a language ‘means’ before you can write a translator

19/04/23 13

Page 14: OPERATING SYSTEMS AND LANGUAGE TRANSLATORS CIS 2380 TERM 2 – LANGUAGE TRANSLATORS Lee McCluskey – lee@hud.ac.uklee@hud.ac.uk 23/09/20151

Resources for TERM 2

Main Book: Andrew Appel – Modern Compiler Implementation in Java. There are many copies in the library. We will cover the first 100 or so pages.

Other Books: There are many books on Compilers – all are worth looking at for background.

Website: This forms the module hand book, as it has most of the teaching resources, the lecture plan, and the coursework There are links to other resources from the website – an

online book, and some other lecture notes Lecture Slides, most tutorial/practical sheets and most

answers to questions are all on the website. SOME OF THE LATER SLIDES / TUTORIALS WILL CHANGE.

19/04/23 14

Page 15: OPERATING SYSTEMS AND LANGUAGE TRANSLATORS CIS 2380 TERM 2 – LANGUAGE TRANSLATORS Lee McCluskey – lee@hud.ac.uklee@hud.ac.uk 23/09/20151

Resources for TERM 2

The MAIN practical tool for this term is

JavaCupThis is a PARSER-GENERATOR – we will use it to generate parsers automatically

from syntax specifications

19/04/23 15

Page 16: OPERATING SYSTEMS AND LANGUAGE TRANSLATORS CIS 2380 TERM 2 – LANGUAGE TRANSLATORS Lee McCluskey – lee@hud.ac.uklee@hud.ac.uk 23/09/20151

Tutorial this week…

Find the websitehttp//scom.hud.ac.uk/scomtlm/cas380/

Work through the exercises in Week 1. These are REVISION. If you are happy with a question move on to the next.

Some of the answers appear on the website.

19/04/23 16