Compiler front end artifacts: During lexical analysis, which table records every literal constant that appears in the source program?

Difficulty: Easy

Correct Answer: Literal table

Explanation:


Introduction / Context:
Compilers break down source code through lexical analysis (tokenization), syntax analysis (parsing), and semantic analysis. Along the way they build tables of symbols to drive later stages of translation and optimization.



Given Data / Assumptions:

  • Literals are explicit constants such as numbers, strings, and character constants appearing in code.
  • Identifiers are names of variables, functions, and types.
  • The lexer categorizes input into tokens and may populate tables for reuse.


Concept / Approach:

A literal table stores each distinct literal constant, often with attributes such as type, value, and sometimes storage placement. This enables deduplication and consistent handling in later phases, including code generation where literals may be placed in constant pools or data segments.



Step-by-Step Solution:

Differentiate between identifiers and literals.Select the table specifically dedicated to literal constants.Exclude terminal table and reductions, which are parser related structures.Choose literal table.


Verification / Alternative check:

Compiler design references list symbol tables for identifiers and separate literal tables or constant pools for numeric and string constants.



Why Other Options Are Wrong:

  • Terminal table: grammar terminals in parsing, not literal constants per se.
  • Identifier table: names and bindings, not raw constants.
  • Reductions: steps in parsing, not a table.
  • None of the above: incorrect because literal table is correct.


Common Pitfalls:

Assuming all tokens go into a single symbol table; in practice, compilers separate identifiers from literals for clarity and efficiency.


Final Answer:

Literal table

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion