LATEST UPDATE (ALREADY GRADED A+)
Global Transformation
Applied over large segments like loops or functions, requires more analysis.
Compile Time Evaluation (constant folding)
3 + 8 turns into 11
Dead code elimination
comments and other things that aren't used go away
Elimination of common sub-expressions
if something is used a lot, then make a variable that is equal to that math, and use that instead of the big
one.
Frequency reduction
move something out of a loop, that is invarient
Strength Reduction
a * 4 becomes a + a + a + a or a << 2
Lazy Swapper
Pager - tell me when you need it and I'll give it to you
Lexical Analysis
Identify the lexical units in a source statement
Classify units into different lexical Classes (constants, reserved words) and enter them into different
tables.
build tokens for each lexical unit
ignore comments in the source program
detect tokens which are not a part of the language
Token
a symbol representing something
Regular expressions
(0|1) 11 (0|1)
Syntax analyzer (parser)
, groups sequences of tokens into phrases
obtains tokens from the lexical analyzer
checks whether the expression is systactically correct
report syntax errors
determine the statement class (if, else)
group tokens into statements
parse trees
breaks statements into trees where the phrase is represented.
recursive descent parser
built from CFG
Profiler instrumentation
modifies binary, inserting probes at function entry/exit to collect performance data ever step while
program running
Profiler sampling
takes statistical samples of application performance
Semantic Analizer
determines if the symbol table and the parse tree has a well-defined meaning
mainly concerned with TYPE CHECKING and TYPE COERCION based on TYPE RULES
Symbol Table
built and maintained by the semantic analyzer
maps each identifyer to information known (type, internal structure, scope)
semantic analyzer uses this to enforce a large variety of rules
provides quick and uniform access to identifier attributes throughout compilation
type coercion
changing the data type of an object with similar content (changing "5" to int 5 or doub 5)
type Checking
semantic error where the type is wrong
Lexemes
Sequence of characters that match a pattern
Syntax errors
errors in the program text
lexical error