Programming Language Translators Flashcards
What is assembly code?
Low-level language, with each instruction in assembly code almost always neigh equivalent to one machine code instruction
Before assembly code program can be executed, what must it be translated into?
Equivalent machine code, or an intermediate form called bytecode, this is done by a program called an assembler
What is a complier?
A program that translate a high-level language into machine code
How does a complier work?
The source code, is input as data to the complier who scans it through several time, each time performing different checks and building up tables of information needed to produce the final object code, the object code can then be saved and run whenever needed without the presence of the complier
What is an interpreter?
A different type of programming language translator
How does a interpreter work?
Once the programmer has written and saved a program, and runs it, the interceptor looks at each line of the program, analyses it and, if no syntax error translates it into machine code and runs it
What is bytecode?
An intermediate representation which combines compiling and interpreting when interpreting each line of code
What is some advantages
You can achieve platform independence, which masks inherent difference between different computer architectures and operating systems
Kt acts as an extra security layer between your computer and the program, as you can download an untruest program and you then execute the Java bytecode interpreter rather than the program itself, which guards against malicious programs
What is the 4 advantages a complier has over an interpreter?
The object code can be saved on disk and run whenever required without the need to recompile, however if an error is discovered the whole program had to be recompiled
The Object code executed faster than in interpreted code
The object code produced by a complier can be distributed or executed without having to have the complier present
The object code is more secure, as t cannot be read without a great deal of ‘reverse engineering’
What is the 2 advantages an interpreter has over a compiler?
Platform independence
It is useful for program development as there is no need for lengthy recompilation each time an error is discovered
What are the disadvantages of an interpreter?
The program may run slower, because each statement has to be translated to machine code each time it is encountered
What are the 3 stages of complication?
Lexical analysis, syntax analysis and code generation and optimisation
What are the functions lexical analysis performs>
Superfluous spaces are removed
All comments are removed
Some simple error-checking is performed like illegal identifier or an attempt to assign an illegal value to a constant that might cause overflow or underflow
A,, keywords, constants and identifiers used in the source code are replaced by ‘tokens’ (unique symbols)
What does a symbol table contain?
An entry for every keyword and identifier in the program
What is the most common way of organising the symbol table?
A hash table, where the keywords or identifier is ‘hashed’ to produce an array subscript