Language Processing System
Figure 1: A language-processing system
Preprocessor
A preprocessor produce input to compilers. They may perform the following functions.
1. Macro processing: A preprocessor may allow a user to define macros that are short hands for longer
constructs.
2. File inclusion: A preprocessor may include header files into the program text.
3. Rational preprocessor: these preprocessors augment older languages with more modern flow-of control
and data structuring facilities.
4. Language Extensions: These preprocessor attempts to add capabilities to the language by certain
amounts to build-in macro
Compiler
Compiler is a translator program that translates a program written in (HLL) the source program and translate
it into an equivalent program in (MLL) the target program. As an important part of a compiler is error showing
to the programmer.
Fig 2: Structure of a Compiler
Executing a program written in HLL programming language is of two parts. The source program must first
be compiled translated into an object program. Then the results object program is loaded into a memory
executed.
Fig 3: Execution process of source program in Compiler
Assembler
An assembler translates assembly language programs into machine code. The output of an assembler is
called an object file, which contains a combination of machine instructions as well as the data required to
place these instructions in memory.
Interpreter
An interpreter, like a compiler, translates high-level language into low-level machine language. The
difference lies in the way they read the source code or input. A compiler reads the whole source code at
once, creates tokens, checks semantics, generates intermediate code, executes the whole program and
may involve many passes. In contrast, an interpreter reads a statement from the input converts it to an
intermediate code, executes it, then takes the next statement in sequence. If an error occurs, an interpreter
stops execution and reports it; whereas a compiler reads the whole program even if it encounters several
errors.
Fig 4: Execution in Interpreter
Languages such as BASIC, SNOBOL, LISP can be translated using interpreters. JAVA also uses
interpreter. The process of interpretation can be carried out in following phases.
1. Lexical analysis
2. Synatx analysis
3. Semantic analysis
4. Direct Execution
Linker
Linker is a computer program that links and merges various object files together in order to make an
executable file. Loader is a part of operating system and is responsible for loading executable files into
memory and execute them. It calculates the size of a program (instructions and data) and creates memory
space for it. It initializes various registers to initiate execution.
What is a compiler?
In order to reduce the complexity of designing and building computers, nearly all of these are made to
execute relatively simple commands (but do so very quickly). A program for a computer must be built by
combining these very simple commands into a program in what is called machine language. Since this is a
tedious and error prone process most programming is, instead, done using a high-level programming
language. This language can be very different from the machine language that the computer can execute,
so some means of bridging the gap is required. This is where the compiler comes in.
A compiler translates (or compiles) a program written in a high-level programming language that is suitable
for human programmers into the low-level machine language that is required by computers. During this
process, the compiler will also attempt to spot and report obvious programmer mistakes.
Impact of using a high-level language for programming
Using a high-level language for programming has a large impact on how fast programs can be developed.
The main reasons for this are:
 Compared to machine language, the notation used by programming languages is closer to the way
humans think about problems.
 The compiler can spot some obvious programming mistakes.
 Programs written in a high-level language tend to be shorter than equivalent programs written in
machine language.
Another advantage of using a high-level level language is that the same program can be compiled to many
different machine languages and, hence, be brought to run on many different machines.

Introduction to compiler

  • 1.
    Language Processing System Figure1: A language-processing system Preprocessor A preprocessor produce input to compilers. They may perform the following functions. 1. Macro processing: A preprocessor may allow a user to define macros that are short hands for longer constructs. 2. File inclusion: A preprocessor may include header files into the program text. 3. Rational preprocessor: these preprocessors augment older languages with more modern flow-of control and data structuring facilities. 4. Language Extensions: These preprocessor attempts to add capabilities to the language by certain amounts to build-in macro
  • 2.
    Compiler Compiler is atranslator program that translates a program written in (HLL) the source program and translate it into an equivalent program in (MLL) the target program. As an important part of a compiler is error showing to the programmer. Fig 2: Structure of a Compiler Executing a program written in HLL programming language is of two parts. The source program must first be compiled translated into an object program. Then the results object program is loaded into a memory executed. Fig 3: Execution process of source program in Compiler Assembler An assembler translates assembly language programs into machine code. The output of an assembler is called an object file, which contains a combination of machine instructions as well as the data required to place these instructions in memory. Interpreter An interpreter, like a compiler, translates high-level language into low-level machine language. The difference lies in the way they read the source code or input. A compiler reads the whole source code at once, creates tokens, checks semantics, generates intermediate code, executes the whole program and may involve many passes. In contrast, an interpreter reads a statement from the input converts it to an intermediate code, executes it, then takes the next statement in sequence. If an error occurs, an interpreter stops execution and reports it; whereas a compiler reads the whole program even if it encounters several errors. Fig 4: Execution in Interpreter Languages such as BASIC, SNOBOL, LISP can be translated using interpreters. JAVA also uses interpreter. The process of interpretation can be carried out in following phases. 1. Lexical analysis
  • 3.
    2. Synatx analysis 3.Semantic analysis 4. Direct Execution Linker Linker is a computer program that links and merges various object files together in order to make an executable file. Loader is a part of operating system and is responsible for loading executable files into memory and execute them. It calculates the size of a program (instructions and data) and creates memory space for it. It initializes various registers to initiate execution. What is a compiler? In order to reduce the complexity of designing and building computers, nearly all of these are made to execute relatively simple commands (but do so very quickly). A program for a computer must be built by combining these very simple commands into a program in what is called machine language. Since this is a tedious and error prone process most programming is, instead, done using a high-level programming language. This language can be very different from the machine language that the computer can execute, so some means of bridging the gap is required. This is where the compiler comes in. A compiler translates (or compiles) a program written in a high-level programming language that is suitable for human programmers into the low-level machine language that is required by computers. During this process, the compiler will also attempt to spot and report obvious programmer mistakes. Impact of using a high-level language for programming Using a high-level language for programming has a large impact on how fast programs can be developed. The main reasons for this are:  Compared to machine language, the notation used by programming languages is closer to the way humans think about problems.  The compiler can spot some obvious programming mistakes.  Programs written in a high-level language tend to be shorter than equivalent programs written in machine language. Another advantage of using a high-level level language is that the same program can be compiled to many different machine languages and, hence, be brought to run on many different machines.