In compiler construction, which table made during lexical analysis lists every literal used in the source program?

Difficulty: Easy

Correct Answer: Literal table

Explanation:


Introduction / Context:
Lexical analysis (the scanner phase) reads raw source text and converts it into a stream of tokens. During this process, the compiler builds auxiliary tables to manage tokens efficiently. Understanding which table stores which kind of lexical item is essential for both compiler design and language tooling.


Given Data / Assumptions:

  • Literals are constant values written directly in code (e.g., numbers, character constants, string constants).
  • Identifiers name variables, functions, classes, etc.
  • The lexer populates symbol-like tables to enable fast lookup and to avoid duplication.


Concept / Approach:
The literal table records each literal encountered (with attributes such as type, length, and value). The identifier table (or symbol table) holds names and their scope/linkage attributes. Parser structures like productions and reductions belong to syntax analysis, not lexical analysis.


Step-by-Step Solution:
1) Classify tokens: identifiers vs. literals vs. keywords/operators.2) Associate storage: literals are stored in a literal table; identifiers go to a symbol/identifier table.3) Exclude parsing artifacts: reductions/productions are grammar-level, not lexical tables.4) Select the correct table for literals: the literal table.


Verification / Alternative check:
Many compiler textbooks and tools (e.g., classic one-pass or two-pass compilers) separate pools for literals (string pool) and symbols, confirming the role of the literal table.


Why Other Options Are Wrong:
Terminal table (option a) is a grammar concept listing terminal symbols. Identifier table (option c) stores names, not constants. Reductions (option d) occur in parsing actions, not lexical storage. Production table (option e) describes grammar rules.


Common Pitfalls:
Confusing string literals with identifiers because both are alphanumeric; literals are values, identifiers are names.


Final Answer:
Literal table

Discussion & Comments

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