Which of the following is a permanent database that has an entry for each…

2011

Which of the following is a permanent database that has an entry for each terminal symbol?

Answer: C. Terminal tableConceptA compiler keeps two kinds of databases, told apart by their lifetime. A permanent database is built once, when the compiler itself is constructed,…

  1. A.

    Literal table

  2. B.

    Identifier table

  3. C.

    Terminal table

  4. D.

    Source table

Attempted by 96 students.

Show answer & explanation

Correct answer: C

Concept

A compiler keeps two kinds of databases, told apart by their lifetime. A permanent database is built once, when the compiler itself is constructed, because it records something fixed about the source language and is therefore valid for every program written in that language. A temporary database is built afresh during each compilation, because its contents are drawn from the particular program being translated. Terminal symbols — the operators, delimiters and reserved keywords that make up a language's own vocabulary — are fixed by the language definition, so any table carrying one entry per terminal symbol must be of the permanent kind.

Applying it to this question

The terminal table is exactly that database. It is supplied along with the compiler and holds one row per terminal symbol of the source language, each row recording the symbol's spelling together with the class the scanner must assign to it — for example whether the symbol is an arithmetic operator, a delimiter or a reserved word. Because the set of terminal symbols is fixed by the language definition and does not vary from one program to the next, this table never has to be rebuilt, which is what makes it permanent.

Cross-check against the other databases

  • Literal table — temporary: one entry per constant, such as 3.14 or 'END', occurring in the program currently being compiled, so its contents change with every program.

  • Identifier table — temporary: one entry per programmer-chosen name (variable, array or label) declared in the program currently being compiled, with data type and address filled in as the declarations are processed.

  • Source table — the file’s own text rather than a table of entries: it reaches the scanner through the source-input routine as a raw character stream, and a fresh one arrives with every compilation.

So the permanent database holding an entry for each terminal symbol is the terminal table.

Explore the full course: Mppsc Assistant Professor Computer Science Paper 2

Loading lesson…