Quiz 10 Flashcards
(10 cards)
Which data structure is mainly used in shift-reduce parsing?
Graph; Stack; Tree; Queue
Stack
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 grammar is ambiguous if it allows multiple distinct parse trees for the same sentence
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 visual representation of grammatical rules, with paths showing how tokens combine
ANTLR is a parser generator that works only with the C programming language, T/F?
False
Top-down parsers start at the root and build downward, T/F?
True
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
(3-2)-1
Left recursion in a grammar leads to right-associativity, T/F?
False
Each non-terminal in recursive descent parsing is implemented as a separate function or procedure, T/F?
True
In Extended Backus-Naur Form (EBNF), which of the following symbols is used to denote optional elements?
<…> […] (…) {…}
[…]
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
They produce parser code from grammar definitions