Stages of compilation

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Describe the contents of the symbol table and how it is used in lexical analysis

- In the lexical analysis stage, identifiers are replaced by a pointer to an address in the symbol table. - The symbol table will typically contain the following entries: 1). The identifier or keyword 2). The kind of item (variable, array, procedure, keyword, etc.) 3). The type of item (integer, real, char, etc.) 4). The run-time address of the item or its value if it's a constant. 5). A pointer to accessing information (array- bounds of the array, procedure- info about each of the parameters). A hash table is used to organise the symbol table so that entries can be found as quickly as possible to minimise compile time.

Describe what happens at the syntax analysis stage

- Parsing- The task of systematically applying a set of rules to each statement to determine if it is valid. - Stacks will be used to check, for example, that brackets are correctly paired. - The priorities of arithmetic operators determined. - Expressions converted into a form which machine code can more easily be generated. Semantics are also checked. This is the meaning of the language.

Describe what happens at the code generation and optimisation stage

- The machine code is generated - Code optimisation techniques attempt to reduce execution time. For example by spotting redundant instructions and producing object code which achieves the same net effect but not by the same means.

Describe what happens at the lexical analysis stage

- unnecessary spaces removed - comments removed - simple error checking is performed (illegal identifiers, assigning illegal values). - All keywords, constants and identifiers used in the source code are replaced by tokens (unique symbols)

Give 2 disadvantages of code optimisation

1). Increases compile time 2). May sometimes produce unexpected results

Give the stages of compilation

1). Lexical analysis 2). Syntax analysis & semantic analysis 3). Code generation and optimisation

Give 3 advantages of using libraries

1). Provide solutions to common problems in everyday programming 2). Tested and error-free 3). Save the programmer time in re-inventing the wheel to write code themselves to perform common tasks.

Explain what the loader does

A relocating loader can load the object code anywhere in memory.

Explain what a linker does

Any separates compiled subroutines must be linked into the object code. It is the job of the linker to put the appropriate machine addresses in all the external call and return instructions, so that the modules are all linked together correctly.


Ensembles d'études connexes

Jewish, Early Christian, and Byzantine Art

View Set

WEEK No. (9)- Ninth Lecture-2023- Selected Texts from Social Theories

View Set

Chapter 4 (Life Provisions) - Life Insurance Policies - Provisions, Options and Riders

View Set

Cell Biology: Discuss the importance of membrane proteins, including examples of notable membrane proteins, how proteins affect membrane characteristics, and how these proteins are involved in cellular protection and signaling

View Set

Physics Chp. 10 Projectile and Satellite Motion

View Set

Section 7 - Data Strucutres, Algorithms & Data Stru

View Set

Chapter 7 course point Nursing Fundamentals

View Set