Compiler Presentation Flashcards
The four parts of how a compiler works:
Lexer, Parser, Code generator, Optimization
Lexer
First part of compiler
Reads the entire source code
One character at a time
Parser
Second part of compiler
Converts each token from the Lexer into a “node” on a syntax tree
Code generator
Third part of compiler
translates nodes into machine language
Code optimizer
Fourth part of compiler
Inspects code produced by the code generator
looks for redundancies
Interpreter vs Compiler
Interpreter translates each statement line by line, compiler translates the entire thing, then runs
DOS command to see how many files are in a particular directory
> dir
Interpreter vs Compiler
Interpreter translates code line by line
Compiler translates the source code into an executable file, that the computer then runs without an interpreter
A software interpreter is a computer program that performs instructions that are written in a _____________ (_______ ____) or _________ (_____ _____) language
programming (batch file) or scripting (Linux shell) language
The area of memory that the interpreter creates when you run a file is called
The offset
Interpreters read each line of the file, comparing the _____ ____ in the line to a list of commands
first word
Unlike other interpreters, _____ can handle a ________ as the first word in a line
BASIC, variable
in a BASIC program, the interpreter will generate an error if the first word is not a _______ or a _________
command or a variable
in a batch file, the interpreter will look for ____, ____ or ____ if the first word of a line is not found
.com, .bat, or .exe
Commands or variables that are valid are turned into ______
tokens