Lecture 3 Flashcards

(17 cards)

1
Q

Layered View of Computer

A

Bare Machine.

Macro Instruction Interpreter.

Operating System.

Compiler level, such as C++, FORTRAN, Operating System Command Interpreter (CMD).

Then Virtual Compiler.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Computer & Languages

Primitive Operations.

A

The processor circuits provide a realisation of a set of primitive operations, or machine instructions for arithmetic and logic
operations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Computer & Languages

Macroinstructions

A

Some of machine instructions are called macroinstructions, because they are put together with a set of instructions of even lower level called microinstructions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Computer & Languages

Set of instructions

A

Machine Language of a computer is its set of instructions. In the absence of any other supporting software, its own machine language is the only language a computer can understand.

A computer could be designed and built with particular high-level languages as its machine languages, but it would be very complex, expensive, difficult or impossible to use other high-level languages.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Computer and Languages Continued

A

On top of the machine language, is the Operating System.

Large Collection of programs that supplies higher-primitive than those of the machine language, e.g primitives for device and file system management, I/O operations, text/program editor and etc.

Rested on the operating system are various language
implementations.
* A particular language implementation and the operating system form
a virtual computer of that language, e.g., the operating system and C compiler provide a virtual C computer.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Language Implementation Methods

Compilation

A

Programs are translated into machine language, includes Just-In-Time systems.

Use: large scientific or commercial applications.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Language Implementation Methods

Pure Interpretation

A

Programs are interpreted by another program known as an interpreter.

Use: Small programs or when efficiency is not a big issue, web programs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Language Implementation Methods

Hybrid Implementation Systems

A

A compromise between compilers and pure interpreters.

Use: Small and Medium systems when efficiency is not the first priority.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Compilation

A

Translates high-level program (source language) into machine code (machine language).

Slow translation, fast execution.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Compilation process

A

Lexical Analysis:
Converts characters in the source program into lexical units.

Syntax Analysis:
Transforms lexical units into parse trees which represent the syntactic structure of program.

Semantics Analysis:
Generate intermediate code.

Code Generation:
Machine code is generated.

Work is done by a compiler.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Compiler

A

Computer Program that translates a program in a source language into a equivalent program in a target language.

Compiler can give error messages.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Compiler Source Language

A

Source language is a high-level language. The target language is a low level language.

  • A machine or assembly language.
  • A language executable by a virtual machine.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Structure of a Compiler

A
  • Source Program -

Lexical Analyser
Semantic Analyser
Code optimiser
Code generations
(all have a symbol table)

  • Target Programs -
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Structure of a compiler details

A

The source program is read by the first phase. (Lexical Analyser)

The target program is output by the final phase (code gen.)

Phases interact with a data structure called a symbol table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Lexical Analysis

A

Reads the source program text ( one character at a time ) and returns sequence of tokens to send to next phase.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Lexical Analysis Tokens

A

Tokens are symbolic names for lexical elements of the source language, in a Pascal compiler.

  • IF might be the token for the Paschal keyword if.
  • IDENT stands for any identifier (e,g. foo, n12)

Each token is associated with a pattern
- IF is an associated with the pattern “i followed by f”
-IDENT is associated with the pattern “ a sequence of letters, digits and ‘_’ that begin with a letter.”