Machine-translated by Google. Questions are authored in English.
Top

Symbol Table Management Questions and Answers

Answer: A

The element type and bounds together determine the width and the address computation. Values exist only at run time and are of no concern to the table. Bounds are also what a compiler needs in order to emit range checks.

Please log in or register to report this question.

Answer: B

Correct answer: the number of elements multiplied by the element width

The total is the product of the dimensions multiplied by the width of one element, all of which the symbol table holds from the declaration. The address is not needed - it is what the width helps to determine, since storage is allocated by advancing a running total.

Please log in or register to report this question.

63.

An array is declared with dimensions 4 by 5 of 8 byte elements. How many bytes does it occupy?

Answer: C

Correct answer: 160

\[ 4 \times 5 \times 8 = 160\ \mathrm{bytes}. \] The dimensions multiply to give 20 elements, and each occupies 8 bytes. Adding the dimensions instead of multiplying them, or forgetting the element width, gives 72 and 20 respectively - both offered here.

Please log in or register to report this question.

Answer: D

Failing to find the name locally, the compiler searches each enclosing scope in turn. Only when the outermost is exhausted is the name reported as undeclared. The search cost is proportional to the depth of nesting at the point of use.

Please log in or register to report this question.

Answer: A

Correct answer: following access links or consulting a display

A nested procedure’s variables live in the activation record of whichever invocation of the enclosing procedure is current, and that is found at run time. An access link in each frame points to the enclosing frame, so the chain is followed as far as the nesting depth requires; a display holds those pointers in an array so the frame is reached in one step.

Please log in or register to report this question.

Answer: B

Correct answer: determine how many access links to follow at run time

The difference between the nesting depth of the use and that of the declaration is exactly the number of links to traverse, and the compiler computes it from the two symbol table entries. That is why the depth is recorded: it turns a run-time search into a fixed number of pointer dereferences known at compile time.

Please log in or register to report this question.

Answer: C

The first three are standard attributes consulted by later phases. Which instruction reads a value is decided by the code generator and has no place in an entry. Confusing what the table records with what the back end decides is a common slip.

Please log in or register to report this question.

Answer: D

The scanner installs, semantic analysis annotates, code generation reads. Its position in the classical diagram reflects that shared use rather than any special size. The error handler is drawn the same way and for the same reason.

Please log in or register to report this question.

Answer: A

Lookup stays fast and collisions become rarer, so the only real penalty is space. Compilers usually start small and grow the table as the program turns out to require it. A very small program should not pay for a table sized for a very large one.

Please log in or register to report this question.

Answer: B

Installing a placeholder entry after the first report suppresses the repeats. The quality of diagnostics is one of the more visible consequences of symbol table design. Users judge a compiler heavily on how its error messages read.

Please log in or register to report this question.

Loading…
Tags: Symbol Table Management Questions and Answers || Symbol Table Management MCQ Questions and Answers || Symbol Table Management GK Questions and Answers || Symbol Table Management GK MCQ Questions || Symbol Table Management Multiple Choice Questions and Answers || Symbol Table Management GK || GK on Symbol Table Management || Compiler Design Questions and Answers || Compiler Design MCQ Questions and Answers || Compiler Design GK Questions and Answers || GK on Compiler Design