LATEST UPDATE

CIMA study stuff added

BOX

Monday, November 29, 2010

PAPER

Department of Computer Science

University of Karachi

BSCS- Compiler Construction

Q1) Select true or false of the following.

1. All variables must be declared before they are used. True / False

2. The expressions a + b % c and (a + b) % c are equivalent. True / False

3. The expressions a - b - c and a - (b - c) are equivalent. True / False

4. The expressions 15 / 3 and 15 / 3.0 are equivalent. True / False

5. The following declaration is used to declare a variable with Boolean type.
bool flag ; True / False

6. If str is a string variable that holds the string "The good life", then str[3] refers to the character 'e'. True / False

7. A header file typically contains type definitions, function prototypes and the implementations of the function. True / False

8. If a function has a local variable x and there is also a global variable called x, then the statements in the function which use x refer to the local variable. True / FalseA lexical analyzer transforms a stream of tokens into an AST (Abstract Syntax Tree). True / False

9. Lexical analyzers based on a FSA (Finite State Automaton) efficiently match multiple token descriptions concurrently to the input stream. True / False

10. Each input character is inspected only once. True / False

11. A lexical analyzer generated by lex is essentially a FSA. True / False

12. A parser transforms a stream of tokens into an AST (Abstract Syntax Tree). True / False

13. A lexical analyzer generator automatically constructs a FSA (Finite State Automaton) that recognizes tokens. True / False

14. The generator is driven by a regular description True / False

15. A parser transforms a stream of characters into a stream of tokens. True / False


Q2) Select one from the following- MCQs

1. In C, the term ``white space'' means:
a. A single space, tab or new-line character.
b. Several spaces, tabs or new-line characters.
c. Any combination of spaces, tabs and new-line characters.
d. All of the above.

Your answer: ______

2. What is the value of the integer expression: 1 - 3 * 5 + 6 / 4 % 2
a. 0
b. -6
c. -8
d. -13

Your answer: ______

3. By the rules of short-circuit evaluation, in the following expression,
p || ( n < style="">

a. if p is true, then n <> will not be evaluated.
b. if
p is false, then n <> will not be evaluated.
c. if
p is true, then n <> will be evaluated.
d. None of the above.

Your answer: ______

4. If p and q are Boolean variables, which expression is equivalent to the following expression?
! ( p || q)
a.
!p || !q
b.
p || q
c.
!p && !q
d.
p && q

Your answer: ______

Q3) Give unambiguous grammar of Algebraic expressions that parse +, -, *, / and ^ operators as well as ++ increment and -- decremetn operator.

Q4) Give selection set of the grammar of Q1.

Q5) Give grammar that parse the following patterns.

a) 1n 0n

b) 1n0m1m0n

Q6) Give attributed translation grammar that parse if / else construct and generate appropriate jump, conditional jump and label intermediate instructions.

No comments:

Post a Comment

UBIT

SMS AT ANY NETWORK

STAND UP 4 THE CHAMPION

Search This Blog