Time Left - 15:00 mins
GATE CS 2018 - Compiler Design Boost_Up Quiz (LA,Parsing, SDT)
Attempt now to get your rank among 490 students!
Question 1
Match the following groups:
List-I
A- Lexical analyzer
B- Syntax analyzer
C- Type checking
List-II
1- Checks the structure of the program.
2- Analysis of entire program by reading each character.
3- Checks the consistency requirements in a context of the program.
List-I
A- Lexical analyzer
B- Syntax analyzer
C- Type checking
List-II
1- Checks the structure of the program.
2- Analysis of entire program by reading each character.
3- Checks the consistency requirements in a context of the program.
Question 2
In C programming, which of the following is not used as a token separator during lexical analysis?
Question 3
Consider the C program
Main()
{
int x = 10;
x = x + y + z;
}
How many tokens are identified by lexical analyzer?
Main()
{
int x = 10;
x = x + y + z;
}
How many tokens are identified by lexical analyzer?
Question 4
Consider the following grammar.
S →S * E
S →E
E →F + E
E →F
F →id
Consider the following LR(0) items corresponding to the grammar above.
(i) S → S *.E
(ii) E → F. +E
(iii) E → F +.E
Given the items above, which two of them will appear in the same set in the canonical sets-of-items for the grammar?
S →S * E
S →E
E →F + E
E →F
F →id
Consider the following LR(0) items corresponding to the grammar above.
(i) S → S *.E
(ii) E → F. +E
(iii) E → F +.E
Given the items above, which two of them will appear in the same set in the canonical sets-of-items for the grammar?
Question 5
Which of the following describes a handle (as applicable to LR-parsing) appropriately?
Question 6
A canonical set of items is given below
On input symbol < the set has
On input symbol < the set has
Question 7
Consider the following grammar G
where S,F, and Hare non-terminal symbols , p, d, and care terminal symbols. Which of the following statement (s) is / are correct?
S1. LL(1) can parse al strings that are generated using grammar G
S2. LR(1) can parse all strings that are generated using grammar G
where S,F, and Hare non-terminal symbols , p, d, and care terminal symbols. Which of the following statement (s) is / are correct?
S1. LL(1) can parse al strings that are generated using grammar G
S2. LR(1) can parse all strings that are generated using grammar G
Question 8
Let G be a grammar is used for arithmetic expressions. The grammar G is shown below with sematic actions and attribute “sign” can contain either 0 or 1.
EE1+E2 [E.sign=E2.sign]
EE1(E2) {E.sign=E1.signE2.sign}
EE1/E2 {if (E1.sign==0) then E.sign=1 else E.sign=0}
E+E1 {E.sign=0}
E-E1 {E.sign=1}
Eid {E.sign=0}
Find the attribute alue at the root E for the given input -id(-id+id)
[Note: EE1+E2 is same as EE+E].
EE1+E2 [E.sign=E2.sign]
EE1(E2) {E.sign=E1.signE2.sign}
EE1/E2 {if (E1.sign==0) then E.sign=1 else E.sign=0}
E+E1 {E.sign=0}
E-E1 {E.sign=1}
Eid {E.sign=0}
Find the attribute alue at the root E for the given input -id(-id+id)
[Note: EE1+E2 is same as EE+E].
Question 9
Consider the following SDT
GA-T{Print “-”}
AEa {Print “*”}
EEb {Print “+”}
E {Print “0”}
TEb {Print “1”}
In the SDT uses L-attribute definition, what is the output printed for evaluation of an input string “ba-bb”?
GA-T{Print “-”}
AEa {Print “*”}
EEb {Print “+”}
E {Print “0”}
TEb {Print “1”}
In the SDT uses L-attribute definition, what is the output printed for evaluation of an input string “ba-bb”?
Question 10
Consider the following SDT.
EE+T {E.x=E.xT.x}
ET {E.x=T.x}
TT*F {T.x=T.x-F.x}
TF {T.x=F.x-1}
Fid {F.x=5}
If bottom up parsing uses S-attributed definition then what is the value of attribute evaluated at root E for an input string " id+id*id "?
EE+T {E.x=E.xT.x}
ET {E.x=T.x}
TT*F {T.x=T.x-F.x}
TF {T.x=F.x-1}
Fid {F.x=5}
If bottom up parsing uses S-attributed definition then what is the value of attribute evaluated at root E for an input string " id+id*id "?
- 490 attempts
- 2 upvotes
- 10 comments
Jun 25GATE & PSU CS