Presentation is loading. Please wait.

Presentation is loading. Please wait.

ICS312 Introduction to Compilers Set 23. What is a Compiler? A compiler is software (a program) that translates a high-level programming language to machine.

Similar presentations


Presentation on theme: "ICS312 Introduction to Compilers Set 23. What is a Compiler? A compiler is software (a program) that translates a high-level programming language to machine."— Presentation transcript:

1 ICS312 Introduction to Compilers Set 23

2 What is a Compiler? A compiler is software (a program) that translates a high-level programming language to machine language A simple representation would be: Source Code -> Compiler -> Machine Language (Object file) A compiler has to perform several steps to produce an object file in machine code form.

3 Analysis of the source code Lexical Analysis using a program called a SCANNER Syntax Analysis using a program called a PARSER Semantic Analysis using CODE GENERATION routines

4 Lexical Analysis Scan the input source code to identify tokens of the programming language. Tokens are basic units (keywords, identifier names, etc.) from which the source code is constructed The program to do this is called a SCANNER

5 Syntax Analysis Group the tokens identified by the scanner into meaningfull phrases that will be used by the compiler to generate the output code. This process is called parsing and is performed by a parser.

6 Synthesis of the target program This can include: Generate an intermediate representation of the source program Code Optimization Code Generation

7 Generate an intermediate representation This is performed by some compilers, but not necessarily all. For instance, compilers for Java on diff. computers compilers for diff. (.net) languages on the same computer, e.g. C#.net, Basic.net

8 Code Optimization Improve the intermediate code to produce a faster running machine code in the final translation. Not all compilers include the code optimization step.

9 Linking the programs produced by the compiler Whether or not an intermediate language is used, the final output of the compiler is usually a representation of the machine language in a relocatable form, called an object module. A linker program links the object modules, created by a compiler, and any additional library object modules, to create the executable program.


Download ppt "ICS312 Introduction to Compilers Set 23. What is a Compiler? A compiler is software (a program) that translates a high-level programming language to machine."

Similar presentations


Ads by Google