11 - Semantic Analysis Flashcards

(34 cards)

1
Q

refers to structure; like grammar in English

A

syntax

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

refers to meaning; what the words actually do

A

semantics

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

why does semantics matter?

A

to know what certain combinations of words mean

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

common misunderstandings in semantics (3)

A
  1. words can be ambiguous
  2. programmers might misunderstand
  3. implementors may make it behave differently
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

refers to the actual code written

A

source program

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

breaks the source program into tokens (identifiers, keywords, operators)

A

lexical analyzer

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

another term for tokens

A

lexical units

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

checks grammar of tokens

A

syntax analyzer

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

the syntax analyzer produces __ representing valid statements

A

parse trees

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

stores information about variables, functions, and identifiers

A

symbol table

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

used across multiple phases of compilation

A

symbol table

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

why use a symbol table?

A

it helps the compiler remember what each symbol is

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

refers to when the compiler fills in the gaps of information that are not explicitly written by programmers

A

default conventions

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

checks for errors

A

semantic analyzer

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

shortcuts or templates; pieces of code that get substituted before compilation

A

macros

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

can package a function or a formula so the programmer doesn’t rewrite it every time and everywhere

17
Q

improves programs

18
Q

the compiler tries to make the code better and faster before generating the final output

19
Q

what can be optimized? (6)

A
  1. removing redundant work
  2. common subexpression elimination
  3. dead code elimination
  4. copy propagation
  5. loop optimizations
  6. optimizing use of registers
20
Q

compiler finds repeated expressions in a program and computes them only once

A

removing redundant work

21
Q

save time by avoiding redundant calculations

A

common subexpression elimination

22
Q

if the code never executes, compiler removes it

A

dead code elimination

23
Q

eliminate unnecessary assignments and make code simpler and more efficient

A

copy propagation

24
Q

take calculations out of loops if they don’t change

A

loop optimizations

25
deciding which registers to use and minimizes the use of registers
optimizing use of registers
26
true or false: some compilers have no significant optimization
true, compilers that have no significant optimization are used in educational settings
27
translates optimized code into machine language instructions
code generator
28
true or false: once the code is optimized, it is immediately ran by the CPU
false, it is first turned into assembly or machine code before becoming the actual set of instructions that the CPU can run
29
combining all pieces of code together into one executable
linking
30
putting the executable into memory so the CPU can run it
loading
31
if a compiler is written in its own language, how do you compile the first compiler?
bootstrapping
32
popular in the 1960s, when computers were slow and errors took a long time to find
diagnostic compilers
33
a special compiler designed to help students and programmers learn by giving better feedback
diagnostic compilers
34
combines your code with libraries and put it into memory
linking and loading