• Join over 1.2 million students every month
  • Accelerate your learning by 29%
  • Unlimited access from just £6.99 per month

Compilers and Interpreters

Extracts from this document...

Introduction

Compilers and Interpreters There are two types of translator for converting a high-level language such as Pascal into machine code; compilers and interpreters. These relieve programmers of the tedium and complexity of low-level programming and hence make programming considerably easier and less error prone. Compiler This type of translator takes the whole source code and compiles it into object code. The object code (sometimes called machine code) can then be run. Pascal is an example of a programming language that uses compilation. Interpreter This type of translator takes the source code and translates the first line of the program, and then executes it. It then does the second line, and the third line, until it gets to the end of the code. BASIC, LISP, Prolog and APL are examples of programming languages that uses interpretation. Compilers plus Interpreters. Some programs written in languages such as JAVA are both compiled and interpreted! A program is firstly compiled into an 'intermediate code'. It is then distributed to users who use a wide range of computers such as Mac or PCs. These computers then run their own 'interpreter' to convert the compiled code into a code they can use. Languages such as JAVA are said to be platform-independent, because any program written in that language can run on any machine. These types of languages are ideal for use on the Internet, where you don't know anything about the machine that will be running your code. Compilation and interpretation compared * Compilation is much faster than interpretation. Once the compilation process has been completed, the object code will run much faster than the same interpreted code. ...read more.

Middle

The lexical analyser only adds the "Item Name" and "Run Time Value". The most common way of organising the symbol table is to use a hash table. The identifier is hashed to a memory location. Semantic Analysis It is concerned with the meaning or interpretation of words in the context in which they are used. For example A:= B may be a correct PASCAL statement, but it is not possible to assign B to A if A is an integer variable and B is a character variable. Semantic analysis checks that the statements have some correct meaning. Examples: (a) Are the parameters and arguments types of a subprogram compatible? (b) Do the number of parameters and arguments match? (c) In an assignment statement, are the types of the LHS and RHS compatible? In natual language (for example English) a sentence may also be syntactically correct but sematically meaningless. For example 'The man eats an apple' has meaning and obeys the rules of the language whereas 'The apple eats the man' obeys the rules of the language(the syntax) but not the semantics. Syntactic correctness does not imply semantic correctness. Code Generation Source code is first passed through a lexical analysis program and then a syntax analysis program. It is then given to the code generation program to actually produce the object code. A high level language is first LEXICALLY analysed. Then its SYNTAX is analysed. During syntax analysis, the SEMANTICS of the code is checked to see if it makes sense. If any errors are found in these stages the REPORT GENERATOR program springs into action and displays helpful (or not so helpful) ...read more.

Conclusion

A library is a file that contains a collection of object files. The linkage editor will manage these files and link them to other programs as necessary. In order to link object files, the files have to be copied into memory. It is also necessary to copy an executable file into memory before it can be executed. When program code is copied into memory, it is said that the code is loaded into memory. The program that performs this task is called a loader. The loader is usually an integral part of the linkage editor. Loader A program is loaded into memory from a library by a program known as a loader. There are two types of loaders: (a) Absolute loader It loads the program into a single fixed area of memory. All address references in the program are fixed at translation time (when the program is assembled or compiled) and it will only work properly when loaded into one specific position in main memory. (b) Relocating loader It can load the program anywhere in main memory because the program has been translated in such a way that all addresses are relative to the start of the program. The start address of the program can be held in a special register called the base register. There are two basic forms in which a relocatable object program can be prepared. For the first form, static relocation, once the object program has been loaded into main memory relocatability is lost and the process cannot be moved again. For the second form, dynamic relocation, relocatability is retained and a process may be moved to a different memory during its execution (essential in a multi-programming set-up where programs are constantly being swapped in and out of memory). ...read more.

The above preview is unformatted text

This student written piece of work is one of many that can be found in our AS and A Level Computer Science section.

Found what you're looking for?

  • Start learning 29% faster today
  • 150,000+ documents available
  • Just £6.99 a month

Here's what a teacher thought of this essay

5 star(s)

*****
A great piece of work! With questions and answers too!

Marked by teacher Ivor Borkin 22/04/2012

Not the one? Search for your essay title...
  • Join over 1.2 million students every month
  • Accelerate your learning by 29%
  • Unlimited access from just £6.99 per month

See related essaysSee related essays

Related AS and A Level Computer Science essays

  1. Peer reviewed

    information systems assignment 2

    4 star(s)

    The Rufus supermarket will be effected by this due to all of the employees and customers they have. All the customers will have their personal details stored within the company because they work there. The information the supermarket will hold will be very personal and confidential.

  2. Future needs of Computer

    You can give online exams and get instant results. You can check your examination results online. Shops and supermarkets use software, which calculate the bills. Taxes can be calculated and paid online. Accounting is done using computers. One can predict future trends of business using artificial intelligence software. Software is used in major stock markets.

  1. Control Unit, Memory Unit, and Arithmetic Logic Unit. The CPU or Central Processing ...

    RAM is volatile. That means that when the power is turned off, its contents is lost. Motherboards have a small amount of battery-backed RAM which keeps the details of the BIOS password, date and time when the power is switched off. Secondary Storage Media Primary memory is memory within the processor.

  2. Activity Based Costing system

    As that can gives more financial information about the products costs, therefore, it can help managers to control the products costs which concentrates on each cost driver consumed and overhead costs which highlights the cost per unit of each cost driver, that makes all costs to be more distinct, as

  1. Evaluate the design and operation of Frito-Lay's logistic network.

    take over operational capabilities that may not be the customers' core competency. Using Frito-Lay as a transport service can also reduce the customer's logistical expenses and investments in developing its own delivery service. 3. Should senior management at Frito-Lay approve the backhaul proposal? How should the backhaul program be implemented?

  2. Computer systems assignment 1

    Motherboard allows them to communicate via BUSes which. They are little cables or printed Circuits which computer components share In order to exchange communication. There are various amounts of data that can be carried by a bus at once. They usually range from 16 to 64 bits and this is called a width of the bus.

  1. Explain why the Bloody Code was developed and ended!

    Another reason I think the Bloody Code was developed is because landowners had emerged from the 1600's more successful, they based their power on the amount of property they owned, the landowners also felt that one of the laws main priorities was to protect their property.

  2. Describe the application and limits of procedural, object oriented and event driven programming paradigms

    This will also result in hiring new employees to be much more expensive as it will take weeks before the programmer will fully understand innards of the program and how it works. Also as everything in procedural programing is connected to each other making modification are difficult to make without

  • Over 160,000 pieces
    of student written work
  • Annotated by
    experienced teachers
  • Ideas and feedback to
    improve your own work