Podcast
Questions and Answers
What is the output of a compiler?
What is the output of a compiler?
What is the role of the scanner in a compiler?
What is the role of the scanner in a compiler?
What is the brain of the compiler?
What is the brain of the compiler?
What is the main difference between a compiler and an interpreter?
What is the main difference between a compiler and an interpreter?
Signup and view all the answers
Which of the following is an example of an interpreted language?
Which of the following is an example of an interpreted language?
Signup and view all the answers
What is the role of the parser in a compiler?
What is the role of the parser in a compiler?
Signup and view all the answers
What is the equivalent of the code generator in an interpreter?
What is the equivalent of the code generator in an interpreter?
Signup and view all the answers
What is the purpose of the code generator in a compiler?
What is the purpose of the code generator in a compiler?
Signup and view all the answers
Study Notes
Compilation and Interpretation of Programs
- A compiler translates a high-level language program into an intermediate form called object code, which can be directly executed by the machine.
- An interpreter does not produce object code, but translates the source program line by line into machine language.
Examples of Compiled and Interpreted Languages
- Examples of compiled languages include: C, C++, C#, Ada, ALGOL, Java, COBOL, Visual Basic, Lisp, FORTRAN, Pascal
- Examples of interpreted languages include: QBASIC, JavaScript, PHP, ASP, APL
How a Compiler Works
- The parser is the brain of the compiler, knowing the syntax and grammatical rules of the source language.
- The parser uses a scanner to read in source program statements and break them into a sequence of tokens (words, numbers, identifiers, operators, etc.).
- The parser calls the code generator to produce object code, which performs the operation specified by the instruction.
- The process continues until the entire program has been read in and translated.
How an Interpreter Works
- An interpreter also has a parser that controls it, with a scanner that does the same job as the compiler's scanner.
- Instead of a code generator, an interpreter has an executor that directly executes the translated code.
- The interpreter translates the source program line by line into machine language, without producing object code.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Description
Learn about the difference between compilation and interpretation in programming languages, including examples of compiled languages such as C, C++, and Java.