1. Home
  2. Explore
  3. Computer Science
  4. Compiler Construction Introduction

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Compiler Construction Introduction

  • 58Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Compiler Foundations
A compiler translates source code into
code.

58 questions

  1. 1
    A compiler translates source code into
    _____
    code.
    Hint

    Think of the low-level code produced from a high-level program.

    Answer

    machine object

  2. 2
    Source code is generally written in a
    _____
    -level language that is intended to be readable by humans.
    Hint

    Contrast this with the low-level language understood directly by the computer.

    Answer

    high

  3. 3
    Machine code is considered
    _____
    -level code because it is directly understood by the computer.
    Hint

    It is closer to the machine than human-oriented programming languages.

    Answer

    low

  4. 4
    One benefit of high-level languages is that they maximize programmer
    _____
    by hiding many machine-level details.
    Hint

    Think about how much work programmers can accomplish without managing hardware details.

    Answer

    productivity

  5. 5
    A compiler allows programmers to focus on the problem they are solving rather than on
    _____
    -level details.
    Hint

    These details include registers, memory addresses, and machine instructions.

    Answer

    machine

  6. 6
    The statement z=x+yz = x + yz=x+y is an example of an
    _____
    statement because the value of an expression is placed into a variable.
    Hint

    It gives the result of a computation to a named variable.

    Answer

    assignment

  7. 7
    To implement z=x+yz = x + yz=x+y on a typical machine, the compiler first loads xxx from memory into a
    _____
    .
    Hint

    This is a fast storage location used by the processor during computation.

    Answer

    register

  8. 8
    After loading xxx into one register and yyy into another, the machine performs an
    _____
    operation on the two registers.
    Hint

    The operation corresponds to the plus sign in x+yx + yx+y.

    Answer

    add

  9. 9
    After computing the sum in a register, the result must be stored back into the memory variable
    _____
    .
    Hint

    This is the destination variable in the original assignment.

    Answer

    z

  10. 10
    In actual assembly, a source-level variable name is replaced by a memory
    _____
    rather than being used as a symbolic variable name.
    Hint

    The machine needs a location identifying where the variable is stored.

    Answer

    address

  11. 11
    For a local variable stored on the stack, its location is represented by an
    _____
    relative to the activation record pointer.
    Hint

    This specifies the variable's position relative to the start of the function's activation record.

    Answer

    offset

  12. 12
    The activation record pointer points to the activation record of the function currently being
    _____
    .
    Hint

    It refers to the function whose code the compiler is processing.

    Answer

    compiled

  13. 13
    A program consisting of multiple source files generally produces one
    _____
    file for each source file.
    Hint

    These files contain translated code but are not necessarily executable by themselves.

    Answer

    object

  14. 14
    The
    _____
    combines object files into an executable program.
    Hint

    It performs the stage after compilation that joins separately translated pieces.

    Answer

    linker

  15. 15
    In addition to combining object files, the linker connects a program with required
    _____
    functions.
    Hint

    These are prewritten functions supplied by libraries such as the C library.

    Answer

    library

  16. 16
    A major responsibility of linking is resolving internal and
    _____
    references.
    Hint

    These references point outside the current source or object file.

    Answer

    external

  17. 17
    A compiler may apply code
    _____
    to make generated code more efficient.
    Hint

    These are transformations intended to improve code quality and performance.

    Answer

    optimizations

  18. 18
    Compiler optimization does not necessarily produce
    _____
    code every time.
    Hint

    The lecture distinguishes code that is good from code that is mathematically best.

    Answer

    optimal

  19. 19
    The main focus of an introductory compiler course is basic translation from a high-level language to
    _____
    code.
    Hint

    Optimization is covered, but it is not the central emphasis.

    Answer

    machine

  20. 20
    A compiler typically uses
    _____
    representations between the high-level source program and assembly code.
    Hint

    These representations occupy a stage between the input language and the target language.

    Answer

    intermediate

  21. 21
    An abstract syntax tree is a
    _____
    representation of a program.
    Hint

    Its structure is hierarchical, with operators and operands arranged as nodes.

    Answer

    tree

  22. 22
    For an expression containing two multiplications whose results are added, the abstract syntax tree places the addition
    _____
    the two multiplication subtrees.
    Hint

    The addition combines the results of the lower-level operations.

    Answer

    above

  23. 23
    The abstract syntax tree for an assignment places the assigned variable at the destination of the
    _____
    operation.
    Hint

    The tree must represent both the computed expression and the variable receiving its result.

    Answer

    assignment

  24. 24
    An optimizer transforms an intermediate representation to improve code quality and eliminate
    _____
    .
    Hint

    These are unnecessary repeated computations or structures.

    Answer

    redundancies

  25. 25
    The optimized result produced by the optimizer is called optimized
    _____
    .
    Hint

    This abbreviation means intermediate representation.

    Answer

    IR

  26. 26
    A compiler may use multiple intermediate representations; the abstract syntax tree is
    _____
    of them.
    Hint

    It is an example rather than the only possible intermediate representation.

    Answer

    one

  27. 27
    The compiler component that converts high-level code into a tree-like intermediate representation is the
    _____
    end.
    Hint

    It handles the earlier stages of compilation, before target-code generation.

    Answer

    front

  28. 28
    The compiler component responsible for generating assembly code is the
    _____
    end.
    Hint

    It operates after analysis and intermediate-representation processing.

    Answer

    back

  29. 29
    Selecting appropriate machine instructions for an intermediate representation is called instruction
    _____
    .
    Hint

    This process chooses which target instructions implement the code.

    Answer

    selection

  30. 30
    Determining the correct ordering of generated instructions is called instruction
    _____
    .
    Hint

    The key idea is arranging instructions in an effective sequence.

    Answer

    scheduling

  31. 31
    Deciding which variables should be placed in CPU registers is called register
    _____
    .
    Hint

    This process assigns limited registers to program variables.

    Answer

    allocation

  32. 32
    Register allocation is necessary because programs usually contain more variables than the CPU has available
    _____
    .
    Hint

    The compiler must decide which variables receive the limited fast storage locations.

    Answer

    registers

  33. 33
    Scanning divides a source program into
    _____
    or words.
    Hint

    Identifiers and operators are examples of these basic units.

    Answer

    tokens

  34. 34
    In scanning, a variable such as xy23 is treated as one
    _____
    representing a variable name.
    Hint

    Scanning groups the characters of an identifier into a single lexical unit.

    Answer

    token

  35. 35
    Scanning operates primarily at the
    _____
    level, while parsing operates at the sentence level.
    Hint

    Scanning forms words from characters.

    Answer

    word

  36. 36
    Parsing takes tokens and constructs
    _____
    out of them.
    Hint

    In a programming language, these correspond to complete syntactic structures or programs.

    Answer

    sentences

  37. 37
    Parsing is analogous to forming sentences from words, whereas scanning is analogous to forming words from
    _____
    .
    Hint

    These are the individual characters that make up tokens.

    Answer

    letters

  38. 38
    Semantic analysis checks whether syntactically formed programs are
    _____
    .
    Hint

    Syntax concerns grammatical form; semantics concerns meaning.

    Answer

    meaningful

  39. 39
    The term semantics refers to the
    _____
    of a program or sentence.
    Hint

    It answers what a syntactically valid construct represents or does.

    Answer

    meaning

  40. 40
    A program with correct syntax but incompatible operand and result types contains a
    _____
    error.
    Hint

    The program may look grammatically correct but does not make sense according to type rules.

    Answer

    semantic

  41. 41
    Expressions allow a program to
    _____
    values and represent computations.
    Hint

    They combine values, variables, and operators.

    Answer

    compute

  42. 42
    An assignment gives the result of an expression to a
    _____
    .
    Hint

    It is the named storage location on the left side of an assignment.

    Answer

    variable

  43. 43
    The conditional construct that chooses between alternatives is commonly written as
    _____
    .
    Hint

    It tests a condition and selects one of two branches.

    Answer

    if/else

  44. 44
    The construct used to repeat a group of instructions is a
    _____
    .
    Hint

    It allows instructions to execute repeatedly.

    Answer

    loop

  45. 45
    The basic compiler described in the lecture supports expressions, assignments, conditionals, and
    _____
    .
    Hint

    This construct provides repeated execution.

    Answer

    loops

  46. 46
    The basic compiler intentionally excludes advanced language features such as objects and
    _____
    .
    Hint

    This object-oriented feature allows classes to derive properties and methods from other classes.

    Answer

    inheritance

  47. 47
    Finite automata, regular expressions, and
    _____
    are theory-of-computation concepts applied in compiler construction.
    Hint

    This concept describes the rules used to form valid program structures.

    Answer

    grammars

  48. 48
    A
    _____
    is used in compiler construction to recognize patterns in the input during scanning.
    Hint

    It is a state-based computational model studied in theory of computation.

    Answer

    finite automaton

  49. 49
    A
    _____
    provides a notation for describing lexical patterns that can be recognized during scanning.
    Hint

    It describes patterns such as identifier forms.

    Answer

    regular expression

  50. 50
    A
    _____
    specifies structural rules for forming valid sentences in a programming language.
    Hint

    Parsing uses these rules to determine whether token sequences have valid structure.

    Answer

    grammar

  51. 51
    In compiler construction, concepts from theory of computation are used as an
    _____
    rather than studied only abstractly.
    Hint

    The compiler is a real system that puts theoretical concepts to practical use.

    Answer

    application

  52. 52
    The pumping lemma is an example of a theoretical topic that is
    _____
    the focus of this compiler course.
    Hint

    The course applies theory but does not concentrate on proving this result.

    Answer

    not

  53. 53
    The compiler course begins with an overview so students understand the
    _____
    picture of compiler structure.
    Hint

    This means the overall organization rather than implementation details.

    Answer

    big

  54. 54
    The stage that breaks source code into tokens is called
    _____
    .
    Hint

    It operates at the word or lexical level.

    Answer

    scanning

  55. 55
    The stage that constructs syntactic structures from tokens is called
    _____
    .
    Hint

    It operates at the sentence or grammatical-structure level.

    Answer

    parsing

  56. 56
    Context-sensitive analysis is another name used in the lecture for
    _____
    analysis.
    Hint

    This analysis checks meaning, types, and other context-dependent rules.

    Answer

    semantic

  57. 57
    Converting an abstract syntax tree into generic assembly is an example of basic code
    _____
    .
    Hint

    This is the process of producing target instructions from an intermediate representation.

    Answer

    generation

  58. 58
    The overall compiler process includes scanning, parsing, semantic analysis, intermediate representations, code generation, and code
    _____
    .
    Hint

    These transformations improve the generated code after or during translation.

    Answer

    optimizations

1 of 58
Question 1 of 58

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent