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

Discussion

A language that requires declaration before use is easier to compile in a single pass because

  • A.no semantic analysis is required for such a language at all
  • B.the lexical analyser can then discard the identifiers immediately
  • C.the symbol table entry exists before the name is ever referenced
  • D.the grammar of such a language is always unambiguous by definition

Answer: C

Correct answer: the symbol table entry exists before the name is ever referenced

A single-pass compiler must generate code for a reference at the moment it meets it, which requires the name's type, size and storage already to be known.

Declaration before use guarantees exactly that: the declaration has been processed and the symbol table entry created before any use is scanned. Without the rule, a forward reference would have to be left incomplete and filled in later - backpatching, or a second pass. Semantic analysis is still required, and the rule says nothing about ambiguity.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.