Upload
sunita-aher
View
450
Download
17
Embed Size (px)
Citation preview
Digital Technique Mrs. Sunita M Dol, CSE Dept
Walchand Institute of Technology, Solapur Page 1
Chapter 4: Syntax Directed Translation
1) A grammar oriented compiling technique known as
a) Syntax directed translation
b) Data flow engines
c) One pass compiler
d) Two pass compiler
2) A parse tree showing the value of attributes at each node
a) Annotated parse tree
b) Syntax tree
c) Semantic tree
d) all of the above
3) In which situation inherited attribute is natural choice
a) Evaluation of arithmetic expression
b) Keeping track of variable declaration
c) Checking for correct use of L-values and R-values
d) Both b and c
4) Syntax directed translation is desirable because
a) It is based on syntax
b) It is easy to modify
c) Its description is independent of any implementation
d) All of above
5) Synthesized attributes can easily simulated by
a) LL grammar
b) Ambiguous grammar
c) LR grammar
d) None of the above
Digital Technique Mrs. Sunita M Dol, CSE Dept
Walchand Institute of Technology, Solapur Page 2
6) A syntax directed definition is said to be ----------- if dependency graph contains
cycle
a) DAG
b) Circular
c) Noncircular
d) None of the above
7) Which one of the following restricts the class of syntax directed definitions that
can be implemented
a) Parse tree methods
b) Rule-based methods
c) Oblivious methods
d) None of the above
8) Syntax directed definition is a--------------type of grammar.
a) LL grammar
b) Context free grammar
c) LK grammar
d) All of the above
9) Terminals can have synthesized attributes but not inherited attributes.
a) True
b) False
10) An SDD without side effects is called
a) Context free grammar
b) Operator grammar
c) Attribute grammar
d) Both a and c
11) An SDD that involves only synthesized attributes is called-------------------.
a) S-Attributed
b) L-Attributed
c) Both a and b
d) None of the above
Digital Technique Mrs. Sunita M Dol, CSE Dept
Walchand Institute of Technology, Solapur Page 3
12) ---------------- are useful tool for determining an evaluation order for the
attribute instances in given parse tree.
a) DAG
b) Dependency graph
c) Graph coloring graph
d) None of these
13) In an L-attributed SDD , attributes may be inherited or synthesized.
a) True
b) False
14) Notations for associating semantic rules with productions are-------------------.
a) Syntax directed definition
b) Translation scheme
c) Both a and b
d) None of the above
15) The translation of token stream is result obtained by evaluated the
a) Productions
b) Syntax rules
c) Semantic rules
d) None of these
16) A SDD is generalization of CFG in which each grammar has associated with
set of attributes called
a) Synthesized
b) Inherited
c) Evaluated
d) Both a and b
Digital Technique Mrs. Sunita M Dol, CSE Dept
Walchand Institute of Technology, Solapur Page 4
17) A parse tree for ----------------- can be always annotated by evaluating semantic
rules for attributes at each node bottom-up.
a) S-attributed definition
b) Inherited attributes
c) Both a and b
d) Syntax directed definition
18) Inherited attributes are convenient for
a) Using attributes exclusively
b) Expressing dependence of programming language construct
c) Evaluating expressions
d) None of these
19) The interdependencies among inherited & synthesized attributes at nodes in
parse tree can be depicted by
a) DAG
b) Dependency graph
c) Interdependency graph
d) Wait for graph
20) Consider node for production T->T1*F, so the T.val at this node defined by
a) T.val:=T1.val*F1.val
b) T.val:=T.val* F.val
c) T.val: =T1.val*F. val
d) T.val: =T.val*F. val
21) In topological sort, dependent attributes c1,c2…ck in semantic rule b:
=f(c1,c2…..ck) are available at node before -------------------- is evaluated.
a) c1…..ck
b) b
c) b: =f(c1,c2…ck)
d) f
Digital Technique Mrs. Sunita M Dol, CSE Dept
Walchand Institute of Technology, Solapur Page 5
22) An (abstract) -------------------- is condensed form of parse tree useful for
representing language constructs.
a) Dependency graph
b) Evaluation tree
c) Syntax tree
d) None of these
23) ------------------ syntax for mknode is:
a) mknode (op ,left)
b) mknode (id ,left ,right)
c) mknode (op ,right)
d) mknode (op ,left ,right)
24) -------------syntax of mkleaf is:
a) mkleaf (id , num)
b) mkleaf (num , val)
c) mkleaf (id , entry)
d) Both b & c
25) DAG is used for
a) Identifying common sub expression in expression
b) Identifying parse tree for expression
c) Identifying syntax tree for expression
d) Both b & c
26) A translator for an s-attributed definition can be implemented with
a) SLR parser
b) LR parser
c) SALR parser
d) None of these
Digital Technique Mrs. Sunita M Dol, CSE Dept
Walchand Institute of Technology, Solapur Page 6
27) Value-number method for constructing node in DAG uses
a) Index search techniques
b) Sequential search
c) Hash function
d) Both b & c
28) L-attributed definitions can always be evaluated in
a) Breadth first order
b) Depth first order
c) Both a & b
d) None of these
29) L-attributed definitions include all syntax directed definitions
a) LL(1) grammar
b) LK(1) grammar
c) LR(0) grammar
d) Both a & c
30) A translation scheme is CFG in which attributes are associated with grammar
symbols and
--------------at right side
a) Semantic rules
b) Syntax rules
c) Semantic actions
d) None of these
31) If translation have both inherited and synthesized attributes then
a) An action must not refer to synthesized attribute of a symbol to right of the
action
b) An inherited attribute for symbol on right side of a production must be
computed in action before that symbol
c) A synthesized attribute for nonterminal on left can only be computed after
all attributes it references have been computed
d) All of above
Digital Technique Mrs. Sunita M Dol, CSE Dept
Walchand Institute of Technology, Solapur Page 7
32) Translation scheme with left recursive grammar for production E->E1+T is
a) E.val:=E1.val+T.val
b) E.val:=E.val + T.val
c) Both a and b
d) None of these
33) Recursive evaluators can be constructed for a class of syntax directed
definitions called
a) Circular definition
b) Strongly non-circular definition
c) Both a & b
d) None of these