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

Discussion

The parse tree and the abstract syntax tree differ in that the syntax tree

  • A.records the type of every expression appearing in the program
  • B.omits the nodes that carry no meaning beyond the grammar itself
  • C.contains strictly more nodes than the corresponding parse tree
  • D.is built by the lexical analyser rather than by the parser

Answer: B

Correct answer: omits the nodes that carry no meaning beyond the grammar itself

A parse tree records every production applied, including the chains of single-child nodes that grammars need to express precedence and associativity. Most of those nodes convey nothing about the program.

An abstract syntax tree keeps only what matters - operators and operands - so it has fewer nodes, not more, and is the form later phases actually walk. Types are added by semantic analysis afterwards, and both trees are built by or from the parser.

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

Post your comment

Please log in or register to post a comment.