Q. In syntax-directed translation, what does an attribute represent?
-
A.
A semantic value associated with a grammar symbol
-
B.
A token type in lexical analysis
-
C.
A machine instruction in code generation
-
D.
A parsing strategy
Solution
An attribute represents a semantic value associated with a grammar symbol in syntax-directed translation.
Correct Answer:
A
— A semantic value associated with a grammar symbol
Learn More →
Q. In syntax-directed translation, what is an intermediate code?
-
A.
A high-level representation of the source code
-
B.
A low-level machine code
-
C.
A representation that is easier to optimize than source code
-
D.
A representation that is not used in modern compilers
Solution
Intermediate code is a representation that is easier to optimize than the original source code.
Correct Answer:
C
— A representation that is easier to optimize than source code
Learn More →
Q. In syntax-directed translation, which of the following is true about synthesized attributes?
-
A.
They are computed from the attributes of the parent node
-
B.
They are computed from the attributes of the child nodes
-
C.
They can only be used in inherited attributes
-
D.
They are not used in syntax-directed definitions
Solution
Synthesized attributes are computed from the attributes of the child nodes in syntax-directed translation.
Correct Answer:
B
— They are computed from the attributes of the child nodes
Learn More →
Q. What is a common application of syntax-directed translation in compilers?
-
A.
Lexical analysis
-
B.
Code generation
-
C.
Syntax checking
-
D.
Semantic analysis
Solution
A common application of syntax-directed translation in compilers is semantic analysis.
Correct Answer:
D
— Semantic analysis
Learn More →
Q. What is the main advantage of using syntax-directed translation?
-
A.
It simplifies the parsing process
-
B.
It allows for easy integration of semantic analysis
-
C.
It eliminates the need for an intermediate representation
-
D.
It speeds up the lexical analysis phase
Solution
The main advantage of using syntax-directed translation is that it allows for easy integration of semantic analysis.
Correct Answer:
B
— It allows for easy integration of semantic analysis
Learn More →
Q. What is the output of a syntax-directed translation scheme?
-
A.
Source code
-
B.
Intermediate code
-
C.
Machine code
-
D.
Error messages
Solution
The output of a syntax-directed translation scheme is typically intermediate code.
Correct Answer:
B
— Intermediate code
Learn More →
Q. What is the primary purpose of syntax-directed translation?
-
A.
To generate machine code directly from source code
-
B.
To produce an intermediate representation from the parse tree
-
C.
To optimize the code for better performance
-
D.
To perform lexical analysis on the source code
Solution
Syntax-directed translation is primarily used to produce an intermediate representation from the parse tree.
Correct Answer:
B
— To produce an intermediate representation from the parse tree
Learn More →
Q. What is the purpose of semantic rules in syntax-directed translation?
-
A.
To define the syntax of the programming language
-
B.
To specify the actions to be taken during parsing
-
C.
To determine the types of variables
-
D.
To optimize the final machine code
Solution
Semantic rules specify the actions to be taken during parsing in syntax-directed translation.
Correct Answer:
B
— To specify the actions to be taken during parsing
Learn More →
Q. What is the role of semantic actions in syntax-directed translation?
-
A.
To define the grammar of the language
-
B.
To specify how to compute attribute values
-
C.
To optimize the generated code
-
D.
To perform error handling during parsing
Solution
Semantic actions specify how to compute attribute values during syntax-directed translation.
Correct Answer:
B
— To specify how to compute attribute values
Learn More →
Q. Which data structure is commonly used to represent the intermediate code in syntax-directed translation?
-
A.
Parse tree
-
B.
Abstract syntax tree
-
C.
Symbol table
-
D.
Control flow graph
Solution
An abstract syntax tree is commonly used to represent the intermediate code in syntax-directed translation.
Correct Answer:
B
— Abstract syntax tree
Learn More →
Q. Which of the following best describes inherited attributes?
-
A.
Attributes passed from parent to child nodes
-
B.
Attributes computed from child nodes
-
C.
Attributes that do not affect the translation
-
D.
Attributes that are only used in semantic actions
Solution
Inherited attributes are attributes passed from parent to child nodes in syntax-directed translation.
Correct Answer:
A
— Attributes passed from parent to child nodes
Learn More →
Q. Which of the following best describes synthesized attributes?
-
A.
Attributes that are passed down from parent to child nodes
-
B.
Attributes that are computed from the values of child nodes
-
C.
Attributes that are used only during lexical analysis
-
D.
Attributes that are not used in syntax-directed translation
Solution
Synthesized attributes are computed from the values of child nodes in the parse tree.
Correct Answer:
B
— Attributes that are computed from the values of child nodes
Learn More →
Q. Which of the following is a common form of intermediate code generated by syntax-directed translation?
-
A.
Assembly language
-
B.
Three-address code
-
C.
Bytecode
-
D.
Machine code
Solution
Three-address code is a common form of intermediate code generated by syntax-directed translation.
Correct Answer:
B
— Three-address code
Learn More →
Q. Which of the following is NOT a type of attribute in syntax-directed translation?
-
A.
Synthesized attribute
-
B.
Inherited attribute
-
C.
Static attribute
-
D.
Contextual attribute
Solution
Static attribute is not a recognized type of attribute in syntax-directed translation.
Correct Answer:
C
— Static attribute
Learn More →
Showing 1 to 14 of 14 (1 Pages)