Quiz 10 Flashcards

(10 cards)

1
Q

Which data structure is mainly used in shift-reduce parsing?
Graph; Stack; Tree; Queue

A

Stack

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Which of the following is true regarding ambiguity in a context-free grammar?
A grammar is ambiguous if it allows multiple distinct parse trees for the same sentence; Ambiguity is unavoidable in arithmetic expressions; Ambiguity can be resolved by adding more non-terminal symbols to the grammar; A grammar is ambiguous if it has at least one production rule with multiple options

A

A grammar is ambiguous if it allows multiple distinct parse trees for the same sentence

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Which of the following best describes a syntax diagram?
A graphical representation of the semantic rules of a language; A tool for identifying the data types in a language; A purely textual notation that formalizes programming language syntax; A visual representation of grammatical rules, with paths showing how tokens combine

A

A visual representation of grammatical rules, with paths showing how tokens combine

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

ANTLR is a parser generator that works only with the C programming language, T/F?

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Top-down parsers start at the root and build downward, T/F?

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Consider the expressions 3 - 2 - 1. Given a left-associative rule for subtraction, which of the following parse trees represents the correct evaluation order?
3-(2-1); 1-(2-3); (3-2)-1; (1-2)-3

A

(3-2)-1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Left recursion in a grammar leads to right-associativity, T/F?

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Each non-terminal in recursive descent parsing is implemented as a separate function or procedure, T/F?

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

In Extended Backus-Naur Form (EBNF), which of the following symbols is used to denote optional elements?
<…> […] (…) {…}

A

[…]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Which of the following is true about parser generators?
They produce parser code from grammar definitions; They only support the Java programming language; They only work for unambiguous grammars; They require manual implementation of every rule

A

They produce parser code from grammar definitions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly