質問                    | 
                
                    答え                    | 
            
        
        | 
     学び始める
 | 
 | 
      [1] Translate high-level program (source language) into machine code (machine language) [3] Slow translation, fast execution [2] Use: Large commercial applications.   
 | 
 | 
 | 
      Describe Pure Interpretation    学び始める
 | 
 | 
      [1] Programs are interpreted by another program known as an interpreter. [2] Use: Small programs or when efficiency is not an issue.   
 | 
 | 
 | 
      Describe Hybrid Implementation Systems    学び始める
 | 
 | 
      [1] A compromise between compilers and pure interpreters. [2] Use: Small and medium systems when efficiency is not the first priority.   
 | 
 | 
 | 
      what are the phases of Compilation?    学び始める
 | 
 | 
      [1] lexical analysis [2] syntax analysis [3] Semantics analysis [4] code generation   
 | 
 | 
 | 
| 
     学び始める
 | 
 | 
      converts characters in the source program into lexical units   
 | 
 | 
 | 
| 
     学び始める
 | 
 | 
      transforms lexical units into parse trees which represent the syntactic structure of program   
 | 
 | 
 | 
      what is Semantics analysis    学び始める
 | 
 | 
      generate intermediate code   
 | 
 | 
 | 
| 
     学び始める
 | 
 | 
      machine code is generated   
 | 
 | 
 | 
| 
     学び始める
 | 
 | 
      A compiler is a program that translates a program in a source language into an equivalent program in a target language.   
 | 
 | 
 | 
      What is the structure of a compiler?    学び始める
 | 
 | 
      (Source program->[Lexical analyser]->[Synax analyser]->[Semantic analyser]->[Code optomiser]->[Code generator]->Target program) everything in [] is also conected to a symbol table   
 | 
 | 
 | 
      what does the lexical Analysis entail?    学び始める
 | 
 | 
      [1] The lexical analyser (or scanner): reads the source program’s text (one character at a time); and returns a sequence of tokens to send to the next phase. [2] Tokens are symbolic names for the lexical elements of the source language   
 | 
 | 
 | 
      What is the Symbols Table    学び始める
 | 
 | 
      The symbol table is a data structure containing all the identifiers (together with their attributes) of a source program.   
 | 
 | 
 | 
      What are typical Attributes of variables?    学び始める
 | 
 | 
    
 | 
 | 
 | 
      What are typical attributes for methods procedures or functions    学び始める
 | 
 | 
      number of arguments and their types and passing mechanisms; the return type (if any).   
 | 
 | 
 | 
      What is Syntax Analisis (parsing)    学び始める
 | 
 | 
      [1] analyses the syntactic structure of the source program for valid syntax[2] input to a parser is the sequence of output tokens from the lexical analyser [3] It attempts to apply the rules that define the syntax of the language on the sequence of tokens   
 | 
 | 
 | 
      what is Semantic Analysis    学び始める
 | 
 | 
      determines if the source program (based on the AST and symbol table) is semantically valid.   
 | 
 | 
 | 
      What does AST stand for? and what is it?    学び始める
 | 
 | 
      Abstract syntax trees are data structures widely used in compilers to represent the structure of program code   
 | 
 | 
 | 
| 
     学び始める
 | 
 | 
      [1] The three analysis phases of a compiler must be able to deal with errors in the source program. [2] On detecting an error a compiler should ideally: report the error in a helpful way, and continue processing to look for further errors.   
 | 
 | 
 | 
      What is Code Optimisation    学び始める
 | 
 | 
      [1] Attempts to improve the time and space requirements of a program, i.e., makes a smaller or faster or both. [2] Example optimisations include: -constant folding (e.g., replacing 3+7 with 10); -eliminating unreachable code   
 | 
 | 
 | 
| 
     学び始める
 | 
 | 
      [1] The final task of the compiler is to generate code for a specific machine. In this phase we need to consider such [2] The output from this phase is usually programs in machine language or assembly language or code for a virtual machine.   
 | 
 | 
 | 
      What things may be considered during code generation    学び始める
 | 
 | 
      [1] Instruction selection: The machine language instr' to use [2] Instr' scheduling: The order to put those instr'[3] Register allocation: The allocation of variables to processor registers[4] Debug data generation if required so the code can be debugged   
 | 
 | 
 | 
      What is Pure Interpretation    学び始める
 | 
 | 
      An interpreter parse the source code and execute it directly, e.g., early versions of the Lisp and BASIC.   
 | 
 | 
 | 
      describe some dissadvantages of pure implimentation compared with compilation.    学び始める
 | 
 | 
      [1] Slower execution than compiled programs [2] Often requires more space   
 | 
 | 
 | 
      Why is pure interpritation slower than compilation?    学び始める
 | 
 | 
      [1] decoding high-level language statement is slower than decoding machine language instructions [2] Regardless how many times a statement is executed, it must be decoded every time.   
 | 
 | 
 | 
      Why does pure interpritation need more space than compilation?    学び始める
 | 
 | 
      the source code and the symbol table must be present during interpretation   
 | 
 | 
 | 
      give examples of Pure interpritation languages    学び始める
 | 
 | 
      Now rare for traditional high-level languages but has significant comeback with some Web scripting languages (e.g., JavaScript, PHP)   
 | 
 | 
 | 
      What is Hybrid Implementation Systems    学び始める
 | 
 | 
      A compromise between compilers and pure interpreters (not as fast as compiled languages, but faster than interpreted languages)   
 | 
 | 
 | 
      Describe the process used byHybrid Implementation Systems    学び始める
 | 
 | 
      A high-level language program is translated/compiled to an intermediate code that will be interpreted during execution.   
 | 
 | 
 | 
      with Hybrid Implementation Systems is the intermediate code ever translated further?    学び始める
 | 
 | 
      no never, Instead, a virtual machine is supplied that takes the intermediate language as its machine language, and interpret the intermediate code (much faster than it would be able to interpret a high-level language)   
 | 
 | 
 | 
      Give examples of some Hybrid Implementation Systems languages    学び始める
 | 
 | 
      E.g., Perl, Python, and MATLAB, JDK1.0   
 | 
 | 
 | 
      describe Just-in-Time Implementation Systems    学び始める
 | 
 | 
      [1] compile programs to an intermediate language[2] intermediate language is loaded into memory [3] segments/subprograms are translated into machine code just before its execution (or when they are called)[4] The machine code is kept for subsequent calls   
 | 
 | 
 |