Language Translators: Full Compilers, Linkers, Interpreters, and Hybrid Implementations Flashcards

1
Q

List the 4 fundamental phases of a typical compiler

A
  1. lexical analyzer
  2. syntatic analyzer
  3. semantic analyzer & intermediate code generator
  4. final code generator
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

T/F: C++ and Ada are not fully compiled languages.

A

False, they are fully compiled

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

What does the Lexical Analyzer do?

A
  • Breaks the character stream into “words” called lexemes
  • categorizes lexemes by token type
  • detects lexical errors
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

list some typical tokens

A
  1. Identifiers
  2. reserved words
  3. numeric literals
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are tokens equivalent to?

A

English parts of speech like verbs or nouns.

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

What are lexical errors?

A

Sequences of characters that doesn’t represent valid tokens

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

give an example of a lexical error

A

A question mark outside of a comment, character, or string literal is usually an error

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

What does the syntactic analyzer do? (3)

A
  • verifies syntax
  • detects errors
  • generates the parse tree
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

T/F: Most compilation errors are syntax errors

A

True

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

What is a typical example of a syntax error in most languages?

A

a missing semi-colon “;”

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

What is a parse tree used for? what is this approach generally referred to as?

A

Intermediate code generation

syntax-directed translation.

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

What does the Semantic Analyzer do?

A

Detects static semantic errors

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

What are the most common semantic errors?

A

Mismatching types, like a non-boolean expression in an if statement.

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

What does the intermediate code generator do?

A

Generates intermediate code.

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

What is intermediate code?

A

a machine-independent low-level language that has no nested expressions or statements

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

What phase is included in production compilers in regards to the semantic analyzer and intermediate code generator?

A

Optimizer

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

T/F: The first 3 phases comprise the first pass of a compiler.

A

True

18
Q

What does the final code generator do?

A

generates machine-dependent object code or machine code

19
Q

T/F: The final code generator is often a 3rd pass over the complete program in its initially translated form.

A

False; 2nd

20
Q

The final code generator phase of the compiler typically involves ____ ____.

A

register allocation.

21
Q

What is the only phase of the compiler process that involves no error detection?

A

Final code generator

22
Q

T/F: Programs written in fully compiled languages must be linked before they can be run

A

True

23
Q

What don’t programmers often realize about linkers in IDEs

A

The linker automatically runs on a “build” command

24
Q

What does the linker do?

A

links together object files for programs made of multiple source files.

25
Q

What kind of programs do linkers usually apply to?

A

large programs

26
Q

What do linkers also link?

A

object libraries that come with the compiler

27
Q

What do object libraries contain?

A

I/O code, common math functions, and so on.

28
Q

When does a linker error occur?

A

When one source file refers to the name of another that cannot be found

29
Q

How do programs made from fully interpreted languages work in a nutshell?

A

They are translated and then executed by the interpreter

30
Q

T/F: interpreted languages always produce an executable file.

A

False; never produce.

31
Q

What runs slower, fully interpreted programs, or fully compiled programs? why?

A

fully interpreted programs

they need to be translated on every execution.

32
Q

What kind of errors do interpreted languages present? why?

A

run-time errors

there is no compilation time.

33
Q

What characterizes a hybrid implementation?

A

involving a compiler and interpreter

34
Q

The compiler in a hybrid implementation consists of the first ____ phases, which constitute the ____ of a traditional compiler.

A

three
first pass

35
Q

T/F: A hybrid implementation is completely machine-dependent.

A

False; independent

36
Q

in a hybrid implementation when does the interpreter part happen?

A

the second pass

37
Q

Initial implementations of ____ used this approach—the output of the compiler being referred to as ____.

A

Java
bytecode

38
Q

____ compilers are an alternative to the interpreter

A

Just-in-time

39
Q

Later ____ implementations replaced the interpreter with a just-in-time compiler

A

Java

40
Q

What makes just-in-time compilers different from interpreters?

A

They do extra compilation making the code execute faster