Thomas Scott
Test por , creado hace más de 1 año

Multiple choice quiz for exam two.

26
0
0
Thomas Scott
Creado por Thomas Scott hace más de 5 años
Cerrar

Exam 2

Pregunta 1 de 18

1

Which of the following is NOT a top-down parsing?

Selecciona una de las siguientes respuestas posibles:

  • Recursive descent parsing

  • Backtracking

  • LL(1) parsing

  • None of these

Explicación

Pregunta 2 de 18

1

Which of the following is true for parser generator

Selecciona una de las siguientes respuestas posibles:

  • The input of a parser generator is a token stream

  • The output of a parser generator is abstract syntax tree(AST)

  • CFG of a programming language is part of the input to a parser generator.

  • Flex is a parser generator

Explicación

Pregunta 3 de 18

1

Which of the follwoing is NOT true for parser?

i. The parser is to process a token stream
ii. One of the major responsibilities of parser is to detect syntax errors.
iii. The output of parser is an abstract syntax tree.

Selecciona una de las siguientes respuestas posibles:

  • i

  • i, ii

  • i, ii, iii

  • ii, iii

  • iii

  • None of the above.

Explicación

Pregunta 4 de 18

1

Grammar that produce more than one parse tree for same sentence:

Selecciona una de las siguientes respuestas posibles:

  • is ambiguous

  • is unambiguous

  • has syntax errors

  • is not LL(1) grammar

Explicación

Pregunta 5 de 18

1

Which of the following is WRONG

Selecciona una de las siguientes respuestas posibles:

  • A CFG grammar is said to be ambiguous if for a sentence, there is a leftmost derivation and a rightmost derivation

  • A DFG grammar is said to be ambiguous if for a sentence, there are two leftmost derivations.

  • A CFG grammar is said to be ambiguous if for a sentence, there are two rightmost derivations.

  • A CFG grammar is said to be ambiguous if for a sentence, there are two different parse tree representations.

Explicación

Pregunta 6 de 18

1

The context free grammar S -> SS | 0S1 | 1S0| ε generates.

Selecciona una de las siguientes respuestas posibles:

  • Equal number of 0's and 1's

  • Unequal number of 0's and 1's

  • Number of 0's followed by any number of 1's

  • None of the above.

Explicación

Pregunta 7 de 18

1

Which of the following is a Tiger program with syntax errors?

Selecciona una de las siguientes respuestas posibles:

  • 1

  • "1"

  • x = 5

  • var x: int := 5

  • All of the above

Explicación

Pregunta 8 de 18

1

Which of the following is a Tiger program without syntax errors?

Selecciona una de las siguientes respuestas posibles:

  • (1, 2, 3)

  • (1; 2; 3;)

  • (1; 2; 3)

  • (1, 2, 3,)

  • None of the above

Explicación

Pregunta 9 de 18

1

Which of the following is a Tiger expression with syntax errors?

Selecciona una de las siguientes respuestas posibles:

  • a(1)

  • b[1]

  • c[2] of 3

  • (10)

  • NONE of the above

Explicación

Pregunta 10 de 18

1

Which of the following derivations does a LL(1) parser use while parsing an input string? The input is assumed to be scanned in left to right order?

Selecciona una de las siguientes respuestas posibles:

  • Leftmost derivation

  • Rightmost derivation

  • None of the above

Explicación

Pregunta 11 de 18

1

Assume X (terminal or non-terminal) is the top symbol in the stack, and c is the next symbol in the input in LL(1) parsing, which of the following indicates a syntax error?

i. x is any terminal other than c
ii. x is a non-terminal, but the cell M[X,c] in the parsing table is empty
iii. x is any non-terminal other than c
iv. x is a non-terminal, but the cell M[X,c] in the parsing table is not empty

Selecciona una de las siguientes respuestas posibles:

  • i

  • i and iii

  • i, ii, iii, and iv

  • None of the above

Explicación

Pregunta 12 de 18

1

Assume FIRST(A) = {b, c, d, ε} for a non-terminal A, what's the result of FIRST(eAf) where e and f are terminals?

Selecciona una de las siguientes respuestas posibles:

  • {b, c, d, e}

  • {b, c, d}

  • {e, f}

  • {e}

Explicación

Pregunta 13 de 18

1

Assume FIRST(A) ={b, c, d, ε} for a non-terminal A, what's the result of FIRST(Ae) where e is a terminal?

Selecciona una de las siguientes respuestas posibles:

  • {b, c , d, e}

  • {b, c, d}

  • {e}

  • {b, c, d, e, ε}

Explicación

Pregunta 14 de 18

1

Assume FIRST(A) ={1, 2, ε}, and FIRST(B) = {b, d} for non- terminal A and B, what's the result of FIRST(AB)?

Selecciona una de las siguientes respuestas posibles:

  • {b, d, ε}

  • {1, 2}

  • {b, d, 1, 2}

  • {1, 2, ε}

  • {b, d, 1, 2, ε}

Explicación

Pregunta 15 de 18

1

Assume FIRST(A) ={1, 2, ε}, and FIRST(B) = {b, d} for non- terminal A and B, what's the result of FIRST(BA)?

Selecciona una de las siguientes respuestas posibles:

  • {b, d}

  • {1, 2}

  • {b, d, 1, 2}

  • {1, 2, ε}

  • {b, d, 1, 2, ε}

Explicación

Pregunta 16 de 18

1

Assume FIRST(A) ={1, 2, ε}, and FIRST(B) = {b, d, ε} for non- terminal A and B, what's the result of FIRST(BA)?

Selecciona una de las siguientes respuestas posibles:

  • {b, d, ε}

  • {1, 2}

  • {b, d, 1, 2}

  • {1, 2, ε}

  • {b, d, 1, 2, ε}

Explicación

Pregunta 17 de 18

1

Assume FOLLOW(A) ={b, d}, FIRST(B) = {1, 2}, for non-terminal A and B, which of the following statements is correct for a production: A-> ABgh where g and h are terminals?

Selecciona una de las siguientes respuestas posibles:

  • FOLLOW(B) contains g

  • FOLLOW(B) contains h

  • FOLLOW(B) contains both g and h

  • g and h are not in FOLLOW(B)

  • FOLLOW(B) contains b, and d

Explicación

Pregunta 18 de 18

1

Assume FOLLOW(A) ={b, d}, FIRST(B) = {1, 2, ε}, for non-terminal A and B, which of the following statements is correct for a production: A-> ACB where C is a non-terminal?

Selecciona una de las siguientes respuestas posibles:

  • FOLLOW(C) contains {1, 2, ε}

  • FOLLOW(C) contains {b, d}

  • FOLLOW(C) contains {1, 2, b, d, ε}

  • FOLLOW(C) contains {1, 2, b, d}

Explicación