Program Construction Flashcards
Does Assembly code work on all computers
No
Are compilers one-to-many or one-to-one
one-to-many
What do compilers do
they take all high level code and covert it into a single executable file
What are the benefits to compilers
They can be run faster than assemblers or interpreters after being compiled.
They allow the source code to be hidden
Are assemblers one-to-many or one-to-one
one-to-one
What do assemblers do
They convert low level assembly language directly into machine code
Are interpreters one-to-many or one-to-one
one-to-many
What do interpreters do
They convert one line of high level code at a time and turn it into machine code which is then run
Why compile over interpret
Doesn’t risk someone stealing your source code
Takes a long time to compile something, however it will run faster afterwards
Name the three stages to the compilation process
Lexical analysis
Syntax analysis
Semantic analysis
What happens during the Lexical analysis stage of compilation
White spaces and comments are removed, each part is allocated a token, categorizing the code
What happens during the syntax analysis stage
Tasks are identified to see if they match up with the syntax of the programming language, backus-naur form plays a roll in this stage
What happens during the semantic analysis stage
compiler checks the meaning of the program, completes checks such as scope resolution, checks the variables have been used, checks for infinite loops.
What three kinds of errors that can occur during compilation and interpretation
Errors that prevent the program from running at all
Errors that occur as the program is actually running
Execution errors