4. 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
5. 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
11. 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
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
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
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.
17. 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.