GoConqr hat ein neues Design! Sag uns, wie es dir gefällt.

Karteikarten

Programming language translators

James Norman OCR A level Computer Science A level Englisch 26 Karten

Karten in diesem Stapel (26)

  1. 1The function of a programming language translatorConverts source code to object code, while detecting errors in the source code
  2. 2Source codeCode written in a high-level language
    Acts as a halfway house between natural language and machine code
  3. 3Object codeA program converted to machine code, but without any library code
  4. 4Types of translator1. Compiler
    2. Interpreter
    3. Assembler
    4. Bytecode/intermediary code
  5. 5CompilerTranslates an entire high-level program into object code
  6. 6Advantages of a compilerOutput code is fully built with no dependencies (following linking with libraries)
    The program can run without the compiler present
    It's difficult to reverse-engineer the code, making it more secure
  7. 7Disadvantages of a compilerThe entire program must be compiled in order to run
    A separate program must be compiled for each platform
  8. 8InterpreterTranslates source code to machine code line-by-line at runtime
  9. 9Advantages of an interpreterPortable - the same code can be run on multiple platforms
    Faster to test as code is translated at runtime
  10. 10Disadvantages of an interpreterPrograms often run slower as statements have to be retranslated each time they are encountered
    Less secure as source code may be provided rather than object code
    The interpreter must be present for the code to run
  11. 11AssemblerTranslates assembly language into machine code
    Often simpler than other translators as assembly language is mnemonic - each line corresponds to an instruction
  12. 12Bytecode/intermediary codeSome languages use hybrids of compilation and interpretation
    This can be done using an intermediary code such as bytecode
    Programs are compiled into bytecode, then run from an interpreter
  13. 13Advantages of bytecodePlatform independence - bytecode can be run on any machine
    Secure layer - the interpreter can act as a guard against any malicious programs
    Difficult to reverse-engineer bytecode as it is closer to machine code than natural language
  14. 14Disadvantages of bytecodeRequires the interpreter to be present on the computer
  15. 15Stages of compilation1. Lexical analysis
    2. Syntax analysis
    3. Code generation
    4. Optimisation
  16. 16Lexical analysis1. Comments and whitespace are removed from the program
    2. High-level code is converted into a series of tokens using reserved words that can be picked out by the computer
    3. A symbol table is created and used to keep track of variables and subroutines
  17. 17Symbol tableContains an entry for every keyword and identifier in the program
    Commonly implemented as a hash table to improve access speed
    Typically shows
    1. The identifier or keyword
    2. The kind of item represented (variable, array, etc.)
    3. The type of item represented - referring to data types
    4. The run-time address of the item or its value if constant
    5. A pointer to accessing information
  18. 18Syntax analysisParses through tokens and performs the following:
    1. Checks the code for syntax errors
    2. Compiles a list of errors for the user where the code does not follow the language rules
    3. Creates an abstract syntax tree
    4. Carries out semantic analysis
  19. 19Semantic analysisCompiler checks for logic errors e.g.
    1. Type mismatch
    2. Undeclared variables
    3. Multiple declarations of the same variable in the same scope
    4. Accessing the array with an out-of-bounds integer literal
  20. 20Code generationObject code is generated from the abstract syntax tree
  21. 21Code optimisationAttempts are made to reduce the execution time of object code
    May involve:
    1. Removing redundant instructions
    2. Replacing groups of instructions with more efficient ones that perform the same function
  22. 22LinkersObject code only consists of the code the developer has written - any libraries or separately compiled subroutines used are not included
    It is the job of the linker to collect these other subroutines and link them up with the object code
  23. 23LoadersNot all libraries are pre-compiled - some are only linked to the program at runtime
    It is the job of the loader to find these libraries when the program requires them
  24. 24Use of librariesLibraries are ready-compiled objects or subroutines that can be loaded and run when required
    Most compiled languages (and some interpreted languages) have their own libraries of pre-written functions which can be imported and used in a program
  25. 25Advantages of librariesOften well-tested and have few errors
    They save the programmer time as they do not have to write code already written to perform common tasks
    Can be used many times, reducing the risk of error
  26. 26Disadvantages of librariesThere may be a lack of documentation

Informationen

Beschreibung
A level OCR A level Computer Science (Topic 2 - Systems Software) Karteikarten am Programming language translators, erstellt von James Norman am 26/01/2020.
Erstellt von
James Norman
Aufrufe
0
Bewertung

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck