Cs606 Midterm Solved MCQ by Sadaf Awan

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

CS606

Midterm MCQ
By Sadaf Awan
BSCS

1: An ----- does not need to examine the entire stack for a handle, the state symbol on the top
of the stack contains all the information it needs
LR parser
RL parser
BU parser
None of the giv

2: Yacc contains built-in support for handling ambiguous grammars resulting in shift-reduce
conflicts. By default these conflicts are solved by performing the ________.
Shift action
Reduce action
Shift and reduce actions
De-allocation of memory

3: S --> A | xb
A --> aAb | x
This grammar contains a reduce-reduce conflict
True
False

4: S --> a | B
B --> Bb | E
The non-terminal _______ is left recursive.
B
A
E
None of the given

5: When generating a lexical analyzer from a ________ description, the item sets (states) are
constructed by two types of “moves”: character moves and e moves.
Character
Grammar
Token (Page 18)
Sentence

6: Left factoring is enough to make a grammar LL(1).


True
False

7: S --> A B
A --> e | aA
B --> e | bB
FIRST(S) contains ___ elements.
3
4
5
6

7: Grammars with LL(1) conflicts can be made LL(1) by applying left-factoring,


substitution, and left-recursion removal. Left-factoring takes care of ________conflicts.
FIRST/FIRST
FIRST/SECOND
SECOND/FIRST
None of the given

8: Alternative of the backtrack in parser is Look ahead symbol in _________ .


Input (Page 46)
Output
Input and Output
None of the given

9: Typical compilation means programs written in high-level languages to low-level


____________.
Object code (page 2)
Byted code
Unicode
Both Object Code and byte code

10: In PASCAL ___________ represent the inequality test.


:
:=
=
<>
None of the given

11: LR parsing ______________ a string to the start symbol by inverting productions.


Reduces (Page 63)
Shifts
Adds
None of the given
12: In parser the two LL stand(s) for ____________ .
Left-to-right scan of input
left-most derivation
All of the given (Page 47)
None of the given

13: Parser always gives a tree like structure as output


True (Page 37)
False

14: Lexer and scanner are two different phases of compiler


True
False (Page 12)

15: In compilation process Hierarchical analysis is also called-----------


Parsing
Syntax analysis click here 4 details
Both Parsing and Syntax analysis
None of given

16: Ambiguity can easily be handled by Top-down Parser Select correct option:
True Click here 4 details
False

17: Front-end of a two pass compiler is consists of Scanner.


True (Page 5)
False

18: LL(1) parsing is called non-predictive parsing.


True Click here 4 details
False

19: In predictive parsing table the rows are ____________________ .


Non-terminals (Page 54)
Terminals
Both non-terminal and terminals
None of the given

20: In LL1() parsing algorithm _________ contains a sequence of grammar symbols.


Stack (Page 55)
Link list
Array
None
21: Consider the grammar
A --> B C D
B --> h B | epsilon
C --> C g | g | C h | i
D --> A B | epsilon
First of C is _______________ .
h
g, I
g, h, I, $
g

22: AST summarizes the grammatical structure with the details of derivations.
True
False (Page 8)

23: Left factoring is enough to make LL1 grammar


True
False (Rep)

24: A grammar is LR if a ------ shift reduce-reduce parser can recognize handles when they
appear on the top of stack.
left-to-reverse
left-to-rise
left-to-right Click here for detail
None of the given

25: Reduction of a handle to the ------- on the left hand side of the grammar rule is a step
along the reverse of a right most derivation.
Terminal
Non-terminal

26: The regular expressions a*|b* and (a|b)* describe the _____set of strings.
Same
Different
Onto

27: Yacc contains built-in support for handling ambiguous grammars resulting in _______
conflicts.
Shift-reduce
Shift-Shift
Shift-second
None of the given

28: A lexical analyzer generator automatically constructs a _____ that recognizes tokens.
FA (Page 18)
PDA
DP
None of the given

29: The following two items A -> P • Q B -> P • Q can co-exist in an ______ item set.
LR
LS
LT
PR

30: LR parsers can handle ________________ grammars.


Left-recursive (Page 63)
file-recursive
End-recursive
Start-recursive

31: _____ convert the reloadable machine code into absolute machine code by linking
library and reloadable object files.
Assembler
Loader/link-editor
Compiler
Preprocessor

32: One of the core tasks of compiler is to generate fast and compact executable code.
True (Page 2)
False

33: Compilers are sometimes classified as.


Single pass
Multi pass
Load and go
All of the given

34: Which of the statement is true about Regular Languages?


Regular Languages are the most popular for specifying tokens.
Regular Languages are based on simple and useful theory.
Regular Languages are easy to understand.
All of the given (Page 15)

35: The transition graph for an NFA that recognizes the language ( a | b)*abb will have
following set of states.
{0}
{0,1}
{0,1,2}
{0,1,2,3}
36: Functions of Lexical analyzer are?
Removing white space
Removing constants, identifiers and keywords
Removing comments
All of the given
37: Flex is an automated tool that is used to get the minimized DFA (scanner).
True
False (Page 26)

38: We use ----- to mark the bottom of the stack and also the right end of the input when
considering the Stack implementation of Shift-Reduce Parsing.
1. Epsilon
2. #
3. $ Click here for detail
4. None of the given

39: When generating a lexical analyzer from a token description, the item sets (states) are
constructed by two types of “moves”: character moves and ____ moves.
1. E Click here for detail
2. #
3. @
4. none of given

40: Bottom-up parsers handle a _________________ class of grammars.


1. Large (Page 42)
2. small
3. medium
4. none of the given

41: Parser takes tokens from scanner and tries to generate _______________ .
Binary Search tree
Parse tree
Syntax tree (Page 8)
None of the given

42: In Flex specification file different sections are separated by _________________ .


%% (Page 26)
&&
##
\\
43: In DFA minimization we construct one _______________ for each group of states from
the initial DFA.
State (Page 25)
NFA
PDA
None of given

44: Consider the grammar A --> B C D


B --> h B | epsilon
C --> C g | g | C h | i
D --> A B | epsilon
Follow of B is _____________ .
h
g, h, i, $
g, i
g

45: Consider the grammar A --> B C D


B --> h B | epsilon
C --> C g | g | C h | i
D --> A B | epsilon
Follow of C is _____________ .
g, h, i, $ (Page 47)
g, h, $
h, i, $
h, g, $

46: An important component of semantic analysis is __________________ .


code checking
type checking (Page 6)
flush checking
None of the given

47: Intermediate Representation (IR) stores the value of its operand in


_____________________ .
Registers
Memory
Hard disk
Secondary storage

48: ________________ algorithm is used in DFA minimization.


James‟s
Robert‟s
Hopcroft’s (Page 25)
None of given

49: A _______ is a top down parser.


Predictive Parsing (Page 46)
Reactive parser
Proactive parser
None of the given

50: Lexical Analyzer generator ________________ is written in Java.


Flex
Jlex (Page 26)
Complex
None of given

51: ____________avoid hardware stalls and interlocks.


Register allocation
Instruction scheduling (Page 10)
Instruction selection
None of given

52: Recursive ____________ parsing is done for LL(1) grammar.


Decent (Page 47)
Ascent
Forward
Backward

53: Left factoring of a grammar is done to save the parser from back tracking.
True (Page 61)
False

54: Responsibility of ______________ is to produce fast and compact code.


Instruction selection (Page 9)
Register allocation
Instruction scheduling
None of given

55: Optimal registers allocation is an NP-hard problem.


True
False (Page 10)

56: Front end of two pass compiler takes_________________ as input.


Source code (Page 5)
Intermediate Representation (IR)
Machine Code
None of the Given

57: In Three-pass compiler _____________ is used for code improvement or optimization.


Front End
Middle End (Page 10)
Back End
Both Front end and Back end

58: ________________ of a two-pass compiler is consists of Instruction selection, Register


allocation and Instruction scheduling.
Back end (Page 9)
Front end
Start
None of given

59: NFA is easy to implement as compared to DFA.


True
False (Page 19)

60: In Back End module of compiler, optimal register allocation uses_______________ .


O(log n)
O(n log n)
N P-Complete (Page 10)
None of the given

61: In a transition table cells of the table contain the ________ state.
Reject state
Next state (Page 18)
Previous state
None of the given

62:Can a DFA simulate NFA?


Yes
No
Sometimes
Depend upon nfa

63:______ phase which supports macro substitution and conditional compilation.


Syntax
Semantic
Preprocessing
None

64:In multi pass compiler during the first pass it gathers information about
___________________ .
Declarations
Bindings
Static information
None
65:Parser takes tokens from scanner and tries to generate_______________ .
Select correct option:
Binary Search tree
Parse tree
Syntax trace
None of the given

66: S --> A | xb
A --> aAb | x This grammar contains a reduce-reduce conflict.

If a DFA states contains both [X → α •, a] and [Y → β •, a], then on input “a” we don’t
know which production to reduce with. This is called a reduce-reduce conflict. Usually
due to gross ambiguity in the grammar.

True
False

67: goto L statement represent


Unconditional jump

68: What does following statement represent? x[i] = y


Index assignment

69: Three-address codes are often implemented as a ________.


Set of quadruples

70: The error handling mechanism of the yacc parser generator pushes the input
stream back when inserting ‘missing’ tokens.
True

False
71: What does the following statement represent? goto L

Unconditional jump

Copy statement

Conditional jump

None of the given

72: Following statement represents: if x relop y goto L


abstract jump

Conditional jump

While loop

None of the Given

73: S --> A | xb A --> aAb | x This grammar contains a reduce-reduce conflict


True
False

You might also like