• 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. Marked by a teacher

    Business & IT Department BTEC. Organisational System Security - Describe the various types of ...

    3 star(s)

    This method results in the 'man in the middle' acquiring sensitive information such as credit card details from either party. This could result in the 'middle man' leaking sensitive customer information such as customer addresses and more importantly; bank details.

  2. Peer reviewed

    information systems assignment 2

    4 star(s)

    Those include technical measures (such as firewalls) and organisational measures (such as staff training). Also subjects are allowed/have the right to make changes to wrong information The data protection act has an effect on everything and every company, the Rufus supermarket is also affected by this act.

  1. Input and Output Devices

    - People with a range of disabilities can use it for voice recognition and many appliances that can be used by voice control. Dis- it can become distorted when background noise is present. - Sound sampling often produces very large data files.

  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. 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

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

    How should the backhaul program be implemented? Frito-Lay should not approve the backhaul program for the following reasons: a. It would be a distraction from their core-competency, which is maintaining their service-to-sales structure. b. They have six core products that account for 80% of their sales. Each core product has a short shelf life (25 to 30 days)

  1. Future needs of Computer

    Defense software is embedded in almost every weapon. Software is used for controlling the flight and targeting in ballistic missiles. Software is used to control access to atomic bombs. Instead of a book now it is easier to learn from an E-learning software. You can give online exams and get instant results.

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

    For example, a constant that is held in memory and is used lots of time in lots of calculations. Fetching data from IAS takes time. Fetching the same data time after time is a waste of time. Processing can be speeded up by storing constantly needed data in some very fast-access memory.

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