GoConqr has a new look! Let us know what you think.

Slides

6 stages of high level code completion

Ethan Long English 8 slides

Slides in this set (8)

  1. Stages of complation for high level code

    • First off there are 6 stages to Compilation
    • 1. Lexical Analysis
    • 2. Symbol Table Construction
    • 3. Syntax Analysis
    • 4. Semantic Analysis
    • 5. Code Generation
    • 6. Optimisation
  2. 1. Lexical Analysis

    • �Comments and unneeded spaces are removed.
    • �Keywords, constants and identifiers are replaced by ‘tokens’.
    • �Examples of keywords that would be replaced:
    • �if
    • �while
    • �for
  3. Symbol Table Construction

    • �A symbol table is created to hold variable addresses, labels and subroutines.
    • Examples
  4. Syntax Analysis

    • Tokens are checked to see of they match the rules (or syntax) for the language used.
    • Examples:
    • �does every open bracket have a close bracket?
    • �Does an if command end with a colon?
    • �If syntax errors are found, error messages are produced.
  5. Semantic Analysis

    • Variables are checked to see if they are properly declared and used.
    • Variables are checked to ensure they are of the correct data type.
    • Operators are checked to ensure they are legal.
    • Examples:
    • �5/3 can not be stored as an integer
    • �"cabbage"+3 can not be evaluated
  6. Syntax Error

    • If any of these steps detects a problem, a syntax error is produced.
    • A syntax error is an error that prevents the code compiling – it is caused by something in the code that is not valid for that programming language
    • Examples:
    • �Missing semicolon
    • �Mismatched brackets or quotes
    • �An invalid operator (=> instead of >=)
    • �Comma used instead of dot
    • Task: During which stage of compilation would each of the above syntax errors be identified
  7. Code Generation

    • �Provided there have been no syntax errors produced, the machine code is now generated
    • �Complex algorithms are used to create machine code instructions that perform the same task as the high level code.
  8. Optimisation

    • �The generated code is scanned for repetitions or known inefficiencies that can be replaced with loops or more efficient code
    • �This step is a big factor in the quality and expense of a compiler. A good compiler will produce better, more efficient machine code than a poor one.

Information

Description
these are the 6 high level code stages for completion
Created by
Ethan Long
Views
3
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?