Welcome To Our
Presentation
1. Sazzad Hossain Hasnat
2. Atik Hasan
3. Md. Ahad Kabir
4. Md. Imran Hossain
5.Md. Mohitul Islam
Group Members:
Sazzad Hossain Hasnat
What is a Compiler?
• A compiler is a computer program that transforms source code
written in a programming language into another computer
language.
Block Diagram Of Compiler
What is a Interpreter
• An interpreter is a computer program that directly executes
instructions written in a programming or scripting language,
without previously compiling them into a machine language
program.
Block Diagram Of Interpreter
Md.Mohitul Islam
Difference Between Compiler and Interpreter
• Input
• Intermediate Code
• Conditional Statement
• Memory Requirement
• Time Complexity
• Example
Md. Imran Hossain
Structure of a Compiler
• Lexical Analyzer
• Syntax Analyzer
• Semantic Analyzer
• Intermediate Code Generator
• Code Optimizer
• Code Generator
Atik Hasan
The Role of the Lexical Analyzer
• Scan a source program and break it up into small, meaningful units, called tokens
• Transform into meaningful units: identifiers, constants, operators, and punctuation
• Removal of comments
• Case conversion
• Removal of white spaces
• Communication with symbol table
What is Tokens, Lexemes, Patterns
• Token : A certain classification of entities of a program
• Example of tokens : Identifiers, Operators, Number, Symbols
• Lexeme : A specific instance of a token. It is used to differentiate tokens
• Patterns : Rule describing how tokens are specified in a program. It is needed
because a language can create infinite loops.
Type of Errors
• Lexical : Name of some identifier typed incorrectly
• Syntactical : Missing semicolon or unbalanced parenthesis
• Semantical : Incompatible value assignment
• Logical : Infinite loops, code not reachable
Md. Ahad Kabir
Errors Recovery Strategies
• There are four types of error recovery strategies
• 1. Panic Mode
• 2. Statement Mode
• 3. Error Productions
• 4. Global Correction
Errors Recovery Strategies
Panic Mode:
When a parser encounters an error anywhere in the statement, it ignores the
rest of the statement by not processing input from erroneous input to
delimiter, such as semi-colon. This is the easiest way of error-recovery
Statement Mode:
When a parser encounters an error, it tries to take corrective measures so that
the rest of inputs of statement allow the parser to parse ahead. For example,
inserting a missing semicolon, replacing comma with a semicolon etc.
Errors Recovery Strategies
Error productions:
Some common errors are known to the compiler designers that may occur in the code.
In addition, the designers can create augmented grammar to be used, as productions
that generate erroneous constructs when these errors are encountered
Global correction:
The parser considers the program in hand as a whole and tries to figure out what the
program is intended to do and tries to find out a closest match for it, which is error-
free.
Thank You

Compiler vs interpreter

  • 1.
  • 2.
    1. Sazzad HossainHasnat 2. Atik Hasan 3. Md. Ahad Kabir 4. Md. Imran Hossain 5.Md. Mohitul Islam Group Members:
  • 3.
  • 4.
    What is aCompiler? • A compiler is a computer program that transforms source code written in a programming language into another computer language. Block Diagram Of Compiler
  • 5.
    What is aInterpreter • An interpreter is a computer program that directly executes instructions written in a programming or scripting language, without previously compiling them into a machine language program. Block Diagram Of Interpreter
  • 6.
  • 7.
    Difference Between Compilerand Interpreter • Input • Intermediate Code • Conditional Statement • Memory Requirement • Time Complexity • Example
  • 8.
  • 9.
    Structure of aCompiler • Lexical Analyzer • Syntax Analyzer • Semantic Analyzer • Intermediate Code Generator • Code Optimizer • Code Generator
  • 10.
  • 11.
    The Role ofthe Lexical Analyzer • Scan a source program and break it up into small, meaningful units, called tokens • Transform into meaningful units: identifiers, constants, operators, and punctuation • Removal of comments • Case conversion • Removal of white spaces • Communication with symbol table
  • 12.
    What is Tokens,Lexemes, Patterns • Token : A certain classification of entities of a program • Example of tokens : Identifiers, Operators, Number, Symbols • Lexeme : A specific instance of a token. It is used to differentiate tokens • Patterns : Rule describing how tokens are specified in a program. It is needed because a language can create infinite loops.
  • 13.
    Type of Errors •Lexical : Name of some identifier typed incorrectly • Syntactical : Missing semicolon or unbalanced parenthesis • Semantical : Incompatible value assignment • Logical : Infinite loops, code not reachable
  • 14.
  • 15.
    Errors Recovery Strategies •There are four types of error recovery strategies • 1. Panic Mode • 2. Statement Mode • 3. Error Productions • 4. Global Correction
  • 16.
    Errors Recovery Strategies PanicMode: When a parser encounters an error anywhere in the statement, it ignores the rest of the statement by not processing input from erroneous input to delimiter, such as semi-colon. This is the easiest way of error-recovery Statement Mode: When a parser encounters an error, it tries to take corrective measures so that the rest of inputs of statement allow the parser to parse ahead. For example, inserting a missing semicolon, replacing comma with a semicolon etc.
  • 17.
    Errors Recovery Strategies Errorproductions: Some common errors are known to the compiler designers that may occur in the code. In addition, the designers can create augmented grammar to be used, as productions that generate erroneous constructs when these errors are encountered Global correction: The parser considers the program in hand as a whole and tries to figure out what the program is intended to do and tries to find out a closest match for it, which is error- free.
  • 18.