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

Discussion

Consider the following two sets:

Set XSet Y
P.Lexical Analyzer1.Abstract Syntax Tree
Q.Syntax Analyzer2.Token
R.Intermediate Code Generator3.Parse Tree
S.Code Optimizer4.Constant Folding

Which one of the following options is the CORRECT match from Set X to Set Y ?

  • A.P - 4; Q - 1; R - 3; S - 2
  • B.P - 2; Q - 3; R - 1; S - 4
  • C.P - 2; Q - 1; R - 3; S - 4
  • D.P - 4; Q - 3; R - 2; S - 1

Answer: B

The correct match is P - 2; Q - 3; R - 1; S - 4.

  1. The lexical analyzer reads characters and produces tokens (P-2).
  2. The syntax analyzer checks the token stream against the grammar and builds a parse tree (Q-3).
  3. The intermediate code generator works from the abstract syntax tree (R-1), a condensed form of the parse tree.
  4. Constant folding, evaluating constant expressions at compile time, is a code optimization (S-4).

The option P - 2; Q - 1; R - 3; S - 4 swaps the parse tree and the abstract syntax tree. Options pairing the lexical analyzer with constant folding misplace both, since a lexer only produces tokens.

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

Post your comment

Please log in or register to post a comment.