Programming Language Translators

Cards (31)

  • What do computers execute?
    Machine code
  • Why is machine code difficult for humans?
    It is hard to read, write, and debug
  • What might a machine code instruction look like?
    01000101
  • How do assembly code instructions compare to machine code?
    They are easier for humans to work with
  • What type of language is assembly code?
    Low level language
  • What does an assembler do?
    Translates assembly code into machine code
  • Why is object code hardware specific?
    Each processor has its own instruction set
  • What does a compiler do?
    Translates high-level language into machine code
  • What is the resulting machine code from a compiler called?
    Object code
  • How is object code produced?
    It is hardware specific
  • What does an interpreter do?
    Translates high-level language into machine code
  • How does an interpreter execute code?
    Line by line
  • What are the differences between a compiler and an interpreter?
    • Compiler:
    • Runs programs multiple times without recompilation
    • Faster execution
    • Executable code does not need interpreter
    • Compiled code is hard to read

    • Interpreter:
    • Source code runs on any machine with interpreter
    • Small errors don't require recompilation
  • What is bytecode in programming?
    Intermediate step between source and machine code
  • How is Java related to bytecode?
    Java is compiled into bytecode
  • What interprets bytecode?
    Bytecode interpreter
  • What are the stages of compilation?
    1. Lexical analysis
    2. Symbol table
    3. Syntax analysis
    4. Semantic analysis
    5. Code generation
  • What happens during lexical analysis?
    Unnecessary spaces and comments are removed
  • What are tokens in lexical analysis?
    Represent functions in the program
  • What might tokens look like for the code "age = 17; print(age);"?
    <identifier> <operator> <number> <keyword> <open_bracket> <identifier> <close_bracket>
  • What does the symbol table do?
    Keeps track of memory addresses for identifiers
  • What occurs during syntax analysis?
    Tokens are checked against language rules
  • What happens if a phrase is not valid in syntax analysis?
    An error will be recorded
  • What is a syntax diagram?
    Visual representation of syntax rules
  • What does semantic analysis check for?
    Valid syntax that is not a valid program
  • What occurs during code generation?
    Machine code is generated from the program
  • What is code optimization?
    Improving code efficiency and removing redundancies
  • What are libraries in programming?
    • Sets of pre-written functions
    • Examples: random number generation, math operations
    • Programmers can write their own libraries
    • Library functions can be called in programs
  • What does a linker do?
    Links memory addresses for library functions
  • What is the role of a loader?
    Copies program into main memory to run
  • Why does the loader relocate memory addresses?
    Some memory may already be in use