Code Translation Flashcards

1
Q

What is code translation?

A

In simple terms, it is the process of translating source code to object code.

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

Special Programs for Translation

A

Four examples of programs used for translation include:
- Compiler
- Interpreter
- Assembler
- Linker

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

Platform Independent

A

This means source code is portable, and writes the code as one simple text file. Then uses a compiler that targets a specific platform (source code and byte code).

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

Platform Dependent

A

Compiler outputs assembly code or object code that will only run on the platform for which it was compiled (compile a game in c++, and run it on PC, Xbox etc). Examples include assembly code and machine code, or object code.

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

Compiler v Interpreter

A

Compiler translates the whole code (returns a file of errors) and adds it to an executable, whilst interpreter runs line-by-line.
With compilers, translations and executions phases are separate, while for interpreters, they are interlaced.

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

Compiler Advantages

A

Compilation process is faster than interpreter.
Compiled code runs much faster.
Checks for syntax AND semantic errors, but interpreters can only check for syntax errors.

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

Interpreter Advantages

A

Syntax errors are easily identifiable.
Useful for rapid prototyping.
Debugging tools are easier to use.

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

Java’s Exception with Compiler and Interpreter

A

Java uses best of both worlds, compiling the java with the java development kit (javac in terminal), and then running it with the interpreter, the java virtual machine (java in terminal).

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

Interpreter Creation

A

At the origin of every interpreter there will be a compiler. Essentially, a compiled language will be needed to write the code for the interpreter.

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

Single Pass Compiler

A

Moves through source code line-by-line and generates object code along the way.

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

Multi-pass Compiler

A

Reads the entire source file into an internal data structure, and analyses and augments the data structure in multiple stages.

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

Linking

A

There can be many source files, which compiled turns into object files, so it is the linker’s job to put all these together into one final executable program image.

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

Static Linking

A

Static linking copies all the libraries used in our code into the final executable file.

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

Dynamic Linking

A

Dynamic linking is the process of loading the external shared libraries into the program and then binds those shared libraries dynamically to the program.

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

Lexical Component

A

List of all keywords allowed in language (import, public, else, while, for).

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

Syntactical Component

A

Defines form and structure of legal expressions in the language (instead of saying private x double in Java, we would say private double x).

17
Q

Semantic Component

A

Adds meaning to an expression made from keywords (actions from an if-else statement etc).

18
Q

Grammar

A

Set of formal syntax rules.

19
Q

Tokens

A

Grouped characters from the translator.

20
Q

Expressions

A

One or more tokens.

21
Q

Non-terminal Expressions

A

Defined by other rules.

22
Q

Terminal Expressions

A

Defined in their final form with simple characters.

23
Q

Extended Backus-Naur Form

A

Rules that are defined as productions of non-terminal and terminal expressions.

24
Q

EBNF Matching

A

Allow the compiler to match the source code against the EBNF grammar of the language.

25
Q

EBNF Rules

A

-> defines a rule
“|” OR

<name> Non-terminal Symbol
symbol Terminal Symbol
[tokens] Optional Tokens
{tokens} Tokens repeated 0 or more times
* Tokens repeated zero or more times
\+ Tokens repeated one or more times
</name>