Lecture Note 6 Flashcards

1
Q

What is specification of programming

A

a programming language specification (or standard or definition) is a documentation artifact that defines a programming language so that users and implementors (language translators) can agree on what programs in that language mean.

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

What are the main translator for programming language translations

A

The assembler
The compiler
The interpereter

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

Describe syntactic analysis

A

The syntactic analyser(parser) costruct a derivation tree for the list

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

Describe semantic analysis

A

The derivation tree is subjected to checks of the language’s various context-based constraints.

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

Descirbe Code optimization

A

Optimizes the code obtained from the preceding phases

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

Describe code generation

A

Generates the final object code

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

What is an interpreter

A

An Interpreter is also a program that translates high-level source code into executable code.

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

What are the two parts of language specification

A

The syntax of a programming language is the part of the language definition that says what programs look like; their form and structure.

The semantics of a programming language is the part of the language definition that says what programs do; their behavior and meaning.

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

The syntax of a programming language is usually described using a combination of two components??

A

i. A regular expression describing its lexemes,

ii. A context-free grammar which describes how lexemes may be combined to form a syntactically correct program.

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

What are forms of programming language specification

A

i. Formal Language Specification

ii) ii. A description of the behavior of a compiler (sometimes called “translator”) for the language (e.g., the C++ language and FORTRAN).

iii)A model implementation, sometimes written in the language being specified

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

What is programming language translation

A

Programming language translation is the conversion of statements written in one language to statements in another language e.g converting assembly language to machine code.

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

What is a compiler

A

A compiler translates a program written in one high level language, the source code into another language which is the object code.

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

What is an assembler

A

The assembler translates mnemonic operation codes into machine code, and symbolic addresses into machine addresses

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

What is documentation

A

Documentation is any communicable material that is used to describe, explain or instruct regarding some attributes of an object or system such as its parts, assembly, installation, maintenance and use.

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

Compilers are organized into three stages:

A

A front end
An optimizers
A back end

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

Object codes to source codes is done in two parts??

A

Analysis and synthesis

10
Q

Types of assembler

A

Load and Go Assembler: Load-and-go assembler generates their object code in memory for immediate execution

One-Pass Assemblers : One-Pass Assemblers generate their object code in memory for immediate execution just like loadand-go assemblers.

Two Pass Assemblers: Two pass assembler translate instructions by converting labels to addresses, generating values defined by BYTE and WORD, processing the directives not done in pass one and then writing the object code to output device

10
Q

Mention the three types of translator

A

assemblers, interpreters and Compilers

11
Q

What are ways in which programming semantics can be described

A

Natural language: Description by human natural language

Formal semantics: Description by mathematics

Reference implementation: Description by computer program

Test suites: Descriptoin by examples of programs and their expected behaviours

12
Q

Mention the two parts involved in interpretion and describe them

A

a parser and an evaluator

.The parser breaks the program into language components to form a parse tree.

The evaluator then uses the parse tree to execute the program.

12
Q

What is the job of each stages

A

The front end is responsible for understanding the program.

The optimizer improves the intermediate representation to increase the speed or reduce the size of the executable which is ultimately produced by the compiler.

The back end converts the optimized intermediate representation into the output language of the compiler.

12
Q

Phases of compilation

A

Lexical analysis:
Syntactic analysis
Semantic analysis
Code optimization
Code generation

12
Q

Describe lexical analysis

A

The aim of lexical analysis is to read the symbols (characters) forming the program sequentially from the input and to group these symbols into meaningful logical units, which we call tokens.

13
Q

Mention advantages of an interpreter

A
  1. Good at locating errors in programs
  2. Debugging is easier since the interpreter stops when it encounters an error.
  3. If an error is deducted there is no need to retranslate the whole program
14
Q

Mention disadvantages of an interpreter

A

Disadvantages of an Interpreter
1. Rather slow
2. No object code is produced, so a translation has to be done every time the program is running.
3. For the program to run, the Interpreter must be present