Compiler Presentation Flashcards

1
Q

The four parts of how a compiler works:

A

Lexer, Parser, Code generator, Optimization

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

Lexer

A

First part of compiler
Reads the entire source code
One character at a time

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

Parser

A

Second part of compiler
Converts each token from the Lexer into a “node” on a syntax tree

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

Code generator

A

Third part of compiler
translates nodes into machine language

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

Code optimizer

A

Fourth part of compiler
Inspects code produced by the code generator
looks for redundancies

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

Interpreter vs Compiler

A

Interpreter translates each statement line by line, compiler translates the entire thing, then runs

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

DOS command to see how many files are in a particular directory

A

> dir

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

Interpreter vs Compiler

A

Interpreter translates code line by line

Compiler translates the source code into an executable file, that the computer then runs without an interpreter

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

A software interpreter is a computer program that performs instructions that are written in a _____________ (_______ ____) or _________ (_____ _____) language

A

programming (batch file) or scripting (Linux shell) language

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

The area of memory that the interpreter creates when you run a file is called

A

The offset

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

Interpreters read each line of the file, comparing the _____ ____ in the line to a list of commands

A

first word

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

Unlike other interpreters, _____ can handle a ________ as the first word in a line

A

BASIC, variable

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

in a BASIC program, the interpreter will generate an error if the first word is not a _______ or a _________

A

command or a variable

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

in a batch file, the interpreter will look for ____, ____ or ____ if the first word of a line is not found

A

.com, .bat, or .exe

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

Commands or variables that are valid are turned into ______

A

tokens

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

Tokens are an abbreviation for

A

the instructions that get passed on to the CPU to execute

17
Q

If the commands/variables are not valid, or they perform a forbidden action, the interpreter will generate

A

a syntax error

18
Q

These commands CAN interrupt the interpreters usual processing pattern

A

GOTO and IF

19
Q

Compiler’s Lexical analysis

A

Reads individual characters and tries to assemble them into computer commands or punctuation characters that it can understand

20
Q

When the scanner comes across an interpretable word or punctuation mark

A

it generates a token

21
Q

When the scanner finds a string of numeric characters it

A

converts the string into an int, then converts the int into a token

22
Q

In the parser, each node on the syntax tree __________ a __________ _________ that generates data or an instruction

A

represents a program operation

23
Q

In the parser, each node

A

passes instructions to the node above it

24
Q

When the parser is finished, the entire program will have been converted into a

A

tree

25
Q

The top most node in the parser is called the _______, and the nodes that pass results to it are _______ _, _______ _

A

Program, routine 1, routine 2