Unit 5 CD
Unit 5 CD
What it is: The place where the function should go back to once it
finishes running.
Why it's important: Ensures the program continues from the right
spot after the function is done.
What it is: The inputs or arguments you give to the function when
you call it.
Why it's important: Helps the function return control back to the
function that called it.
Why it's important: Lets the function access variables that are in its
surrounding functions (for languages that allow nested functions).
What it is: The saved state of the computer’s registers before the
function call.
7. Temporaries:
Why it's important: Holds values that are needed briefly, for
example, parts of complex calculations.
The instruction within block are executed sequentially without any jump or
branches except at the end
Process: Instructions from intermediate code which are leaders are determined.
The following are the rules used for finding a leader:
Flow Graphs
Flow Graph (Control Flow Graph): A flow graph is a directed graph that
represents the control flow of a program.
Components:
Types of Errors
1. Lexical Errors:
2. Syntax Errors:
Errors that occur during parsing, when the source code violates the
grammar rules of the programming language.
3. Semantic Errors:
Errors that occur during semantic analysis, where the syntax is correct
but the code has logical inconsistencies or type mismatches.
4. Runtime Errors:
5. Logical Errors:
Description: Errors that result in incorrect output, where the logic of
the code does not produce the intended result.
1. Panic Mode:
2. Phrase-Level Recovery:
3. Error Productions:
4. Global Correction:
Description: The compiler considers the entire program to find the
minimal set of changes that correct the errors.
Type: The data type of the identifier (e.g., integer, float, custom type).
2. Implementation:
1. Lexical Analysis:
The symbol table is populated with tokens representing identifiers,
along with their basic attributes.
2. Syntax Analysis:
The parser checks the symbol table to ensure identifiers are declared
before use and adheres to scope rules.
3. Semantic Analysis:
4. Code Generation:
5. Optimization: