Вы находитесь на странице: 1из 15

A PROJECT PRESENTATION ON

BY

WHAT IS A

COMPILER?

A Compiler is a SYSTEM Software to convert Higher level code to Machine level code without changing the purpose of the HLL code.

NEED OF A

COMPILER

A Compiler allows a Programmer to write a program in HLL irrespective of the underlying Hardware configuration.

OBJECTIVE OF THE

PROJECT

A Compiler allows a Programmer to write a program in HLL irrespective of the underlying Hardware configuration.

Lexical Analysis or Linear Analysis or Scanning, in which the stream of characters making up the source program is read from left-to-right and grouped in to tokens, sequence of characters having a collective meaning. The blanks separating the characters of the tokens and the comments statements appearing within the program would be eliminated during lexical analysis.

Syntax Analysis or Hierarchical Analysis, in which characters or tokens are grouped hierarchically into nested collections with collective meaning. Hierarchical analysis also termed as Parsing, involves grouping the tokens of the source program into grammatical phrases that are used by the compiler to synthesize output. Usually, the grammatical phrases of the source program are represented by a Parse tree.

Semantic Analysis, in which certain checks are performed to ensure that the components of a program fit together meaningfully. The semantic analysis phase checks the source program for semantic errors and gathers type information for the subsequent codegeneration phase. It uses hierarchical structure determined by the syntax-analysis phase to identify the operators and operands of expressions and statements.

After the syntax and semantic analysis, some compilers generate as explicit intermediate representation of the source program. We can think of this intermediate representation as a program for an abstract machine. This intermediate representation should have two important properties: it should be easy to produce and easy to translate into the target program.

The code optimization phase attempts to improve intermediate code, so that fasterrunning machine code will result. There is a great variation in the amount of code optimization different compilers perform. In those that do the most, called optimizing compilers, a significant amount of the time of the compiler is spent on this phase. However, there are simple optimizations that significantly improve the running time of the target program without slowing down compilation too much.

The final phase of the compiler is the generation of target code, consisting normally relocatable machine code or assembly code. Memory locations are selected for each of the variables used by the program. Then, intermediate instructions are each translated into a sequence of machine instructions that perform the same task. A crucial aspect is the assignment of variables to registers.

A symbol table is a data structure containing a record for each identifier, with fields for the attributes of the identifier. The data structure allows us to find the record for each identifier quickly and to store or retrieve data from that record quickly. The attributes may provide information about the storage allocated for an identifier (if applicable), its type, its scope and in the case of procedure names, such things as the number and types of arguments, the method of passing each argument and the type of return value if the functions returns any value.

Each phase can encounter errors. However, after detecting an error, a phase must somehow deal with that error, so that compilation can proceed, allowing further errors in the source program to be detected. A compiler that stops when it finds error is not as helpful as it could be. The syntax and semantic analysis phases usually handle a large fraction of the errors detectable by the compiler. The lexical phase can detect errors where the characters remaining in the input do not form any token of the language. Errors where the token stream violates the structure rules (syntax) of the language are determined by the syntax analysis phase. During semantic analysis the compiler tries to detect constructs then have the right syntactic structure but no meaning to the operation involved.

The compiler designed by us has the following limitations Floating point, arrays, structures, pointers, enumerators and function definition are not supported. The auto, constant, volatile and register keywords are ignored. Strong type checking is not supported.

Вам также может понравиться