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

Symbol Table Management Questions and Answers

Answer: C

Unused declarations are legal in almost every language. A warning is helpful because such a declaration often indicates a typing mistake or leftover code. Treating it as an error would break a great deal of legitimate code.

Please log in or register to report this question.

Answer: D

A simple flag or counter on the entry suffices. The check is made when the scope closes, at which point no further use of that declaration is possible. The same flag also supports warnings about variables assigned but never read.

Please log in or register to report this question.

Answer: A

The C typedef problem shows why this matters, since whether a name is a type changes how a construct parses. The distinction is recorded as an attribute on the entry. The scanner then asks the table which kind of token to return.

Please log in or register to report this question.

Answer: B

Whether a construct is a declaration or an expression depends on whether the name is a type. Feeding semantic information back into the parser is the usual pragmatic solution. Languages designed later often avoid the construct that causes the difficulty.

Please log in or register to report this question.

55.

State whether the following is true or false.
A symbol table can be discarded as soon as syntax analysis is complete.

Answer: C

Correct answer: False

The symbol table is needed long after parsing: semantic analysis checks types against it, intermediate code generation reads storage and scope from it, the code generator allocates from it, and debugging information is produced from it. It is one of the longest-lived structures in the compiler.

Please log in or register to report this question.

Answer: D

A marker pushed at block entry records where to stop popping. The operation is cheap, which matters because deeply nested code enters and leaves scopes constantly. A loop body inside a procedure inside a module may open three scopes at once.

Please log in or register to report this question.

Answer: A

Each bucket chain is ordered most recent first, so a lookup finds the innermost declaration immediately. Popping a scope removes entries from the fronts of their chains. Both operations therefore cost time proportional only to what changed.

Please log in or register to report this question.

Answer: B

The most closely nested rule is realised by the chain order itself. No separate scope search is needed, which is what makes the combined design so efficient. One hash and one short chain walk resolve any name, however deeply nested.

Please log in or register to report this question.

Answer: C

Correct answer: stores the names in a separate string area and points into it

A fixed-size name field must be large enough for the longest identifier, which wastes space in every entry. Keeping the characters in a contiguous string area and holding an offset and a length in the entry makes the entries uniform and small while placing no limit on name length.

Please log in or register to report this question.

Answer: D

Comparing pointers is far cheaper than comparing strings, and comparisons are frequent. The interning table is itself usually a hash table over the character strings. The same table often serves as the compiler's whole string pool.

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