Professional Documents
Culture Documents
9691-CIE-Answers (3.2) - Purposes of Translators
9691-CIE-Answers (3.2) - Purposes of Translators
Section 3.2
May/June 2003
1. (a) The sequence will have to be interpreted 2000 times/this will include all
stages, such as checking
Compiled version needs no further translation (2)
(b) Removes spaces/white space/tabs
Removes comments
Checked validity of reserved words
Tokenises reserved words
Tokenises operators
Checks validity of symbols/variable names
Creates the symbol table
(1 each, max 4) (4)
Oct/NOV 2003
3. (a) - Whole program not written
- so may not compile
- Testing needs to be done
- diagnostics will be more complete
- individual segments can be run
- allowing errors to be isolated
- running will be necessary after very minor changes
- continual compilation of whole code is wasteful/time consuming
(1 per -, max 5) (5)
(b) - Check on grammar of statements
- Error diagnostics are issued
- Jump destinations checked for existence
- Control constructs checked
- Check that variables have been declared
- Check for existence of library modules
(1 per -, max 3) (3)
http://sites.google.com/site/computing9691/
Page 1 of 11
Reinforcement: 05-10 Years' relevant CIE answers.
Section 3.2
May/June 2004
4. (Tokens) are analysed to check for grammatical correctness (form valid
sentences)
(Code)/reserved word checked against rules
Invalid number of brackets found
Determine priorities of arithmetic operators in an expression
Produce intermediate code
Diagnostic error messages are reported
Label checks
Flow of control checks
Declaration checks (1 per point, max 5) (5)
Oct/NOV 2004
4. Program is in modular form in machine code
The individual modules must be loaded by the loader into the computer’s memory
Loader decides where modules are to be placed
Memory addresses adjusted by loader
Use of loader to load library routines
Linker links the modules correctly
Calculates addresses of the separate modules
Allows library routines to be linked to several programs
(1 per point, max 6) (6)
May/June 2005
6. (a) -Interpreter translates line of code and then runs it
-Compiler translates entire program before run.
-Compiler creates an object code
-Interpreter retains source code.
-Compiler must be present for translation
-Interpreter must be present for run
(1 per -, max 2, must include one for each of interpreter and compiler) (2)
(b) -Creates a stream of tokens…
-each group of characters is replaced by a token
-Symbol table created…
-accessed by hashing algorithm
-which initially stores just the variable names
-Redundant characters removed…
-white spaces/tabs/comments…
-(Some) error diagnostics created…
-e.g. illegal variable names.
(1 per -, max 5) (5)
(c) -Address of variables calculated
-and stored in symbol table
-Intermediate code produced…
-which can then be turned into executable code/machine code
-Code optimized…
-which involves using rules to make code as small/efficient as possible.
(1 per -, max 2 pairs, max 4) (4)
http://sites.google.com/site/computing9691/
Page 2 of 11
Reinforcement: 05-10 Years' relevant CIE answers.
Section 3.2
Oct/NOV 2005
5. (c) -Programs may be in modular form
(i) -Calculates the address of the individual module
-Ensures jump instruction from module to module properly addressed
(ii) -Decides whereabouts to place program/modules in memory
-Adjusts memory addresses according to where placed
-Copies program from store to memory
(1 per -, max 4) [4]
May/June 2006
1. (a) - the computer only understands binary
- HLL is written in language close to human language
- translator needed to turn one into the other
(1 per -, max 2) [2]
(b) - interpreter translates one line of code and runs it
- before translating the next line
- original code is always present
- compiler translates entire code
- before allowing it to be run
- creates object code
(1 per -, max 4) [4]
(c) (i) - translator program maintains a dictionary of reserved words
- if the reserved word used is not in this dictionary then an error has been made
- message may be given which suggests one close to spelling provided
(ii) - variable names must follow the rules of the language
- translator tries the rules against the names used and reports any errors
- contents of variables must be of a specific type
- error created by the attempted use of anything else.
(1 per -, max 4) [4]
Oct/NOV 2006
4. (a) -the production of a machine code program/intermediate code which…
-will produce the results intended by the source code
-optimisation reduces the size of the object code by…
-removing any duplicate or redundant instructions…
-which improves speed of execution
(1 per -, max 3) (3)
(b) (i) -linkers join together (compiled) modules of code
-to produce an executable file
-needs to match up address references between modules
(ii) -takes a set of code from storage and copies it into memory
-needs to resolve problems with addresses
-mention of linking loader (1 per -, max 2 per section, max 4) (4)
http://sites.google.com/site/computing9691/
Page 3 of 11
Reinforcement: 05-10 Years' relevant CIE answers.
Section 3.2
May/June 2007
6. (c) - Interpreter translates one command at a time and runs it before the next is
translated.
- Used during writing because it aids debugging
- (Compiler translates whole program) into object code (before running)
- Runs faster once it has been called/may be held as a library routine.
(1 per -, max 4) [4]
(d) - Decides where to place programs and procedures
- Loads program and procedures into memory
- Adjusts memory addresses to match locations used
(1 per -, max 2) [2]
Oct/NOV 2007
7. – Characters in the variable name are tokenised
– Variable name is added to symbol table…
– during lexical analysis
– Data type added…
– scope is added/block(s) in which variable is valid
– during syntax analysis
– Variable names which do not match the rules are reported in error diagnostics
– Statements containing variables are checked for syntax
– Position in table is hashed from the name
– Variable declarations are checked/also variable use
– Address of variable calculated…
– added to symbol table…
– during code generation
(1 per –, max 6) [6]
May/June 2008
9. (a) -Reserved word is isolated...
-if not in list of reserved words (then error)
-(If reserved word identified then syntax table) checked for expected form of
statement...
-matched to statement provided and error issued if different
-Variable names checked against rules for variable names
-Check for variable declarations
(1 per -, max 4) [4]
(b) -All errors due to incorrect use of language have been corrected
-When variables are first met in code generation, an address is assigned to them
-Intermediate code is produced
-Machine code/executable code produced (from intermediate code)
-Optimisation of code carried out
(1 per -, max 4) [4]
http://sites.google.com/site/computing9691/
Page 4 of 11
Reinforcement: 05-10 Years' relevant CIE answers.
Section 3.2
Oct/NOV 2008
2. (a) (i) – Code written in a high level language
(ii) – Code in machine code/result of source code being
(compiled)/executable code/binary [2]
(b) – Compiler produces object code/object code must exist before
code is run/error diagnostics reported for entire source code
– Interpreter does not produce object code of program/only
produces m.c. of each statement/error diagnostics reported as
error is met [2]
(c) (i) – Makes the run of the program more efficient (faster)/runs
without the presence of the compiler/because no further
translation needs to be done
– Makes the software more secure/cannot be altered because source
code not present
(ii) – When writing a program/gives better diagnostics/will run
despite not being complete (Up to 2 per –, max 1 – per dotty,
max4) [4]
May/June 2009
2. (d) (i) -Used to combine already compiled procedures
-with compiled program…
-to create an executable file.
-Deals with external references.
(ii) -Copies object code into…
-(primary) memory ready for execution.
-Deals with addressing anomalies,
-particularly relocatable addressing
(1 per -, max 2 per dotty, max 4) [4]
http://sites.google.com/site/computing9691/
Page 5 of 11
Reinforcement: 05-10 Years' relevant CIE answers.
Section 3.2
http://sites.google.com/site/computing9691/
Page 9 of 11
Reinforcement: 05-10 Years' relevant CIE answers.
Section 3.2
-machine code and assembly language are both low level languages (machine
specific) (1 per -, max 2) [2]
(b) -Labels added to a symbol table
-Labels are later looked up to determine the actual address / Assembler must
allocate addresses to labels
-Mnemonic looked up in opcode table to find operation code
-Macro instructions used to stand for groups of instructions
(1 per -, max 2) [2]
11 (a) -Interpreter translates one instruction, runs it before going on to the next //
Compiler translates all the instructions before run.
-Compiler creates object code/executable file // Interpreter does not
-Interpreter makes for easier debugging
-Compiled programs will execute faster // interpreted code will execute slower
-Interpreter must be present to run the program // compiler not needed at runtime
-Interpreter will translate code in loops more than once // Compiler only once
-once compiled no further translation needed // every program execution requires
interpreter
(1 per -, max 3) [3]
http://sites.google.com/site/computing9691/
Page 10 of 11
Reinforcement: 05-10 Years' relevant CIE answers.
Section 3.2
http://sites.google.com/site/computing9691/
Page 11 of 11