Questions: Parser Generators and Yacc/Bison

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A language designer adds a new ternary operator to a programming language that uses a Bison-generated parser. What is the primary change required to the parser?

AModify the grammar specification file to include the new operator's productions and precedence, then regenerate the parser
BUpdate the LALR(1) action/goto tables by hand to add new rows for the operator's tokens
CRewrite the recursive descent functions that handle expression parsing
DUpdate the FIRST and FOLLOW sets manually and patch the parser source code directly
Question 2 Multiple Choice

During parser generation, Bison reports a shift-reduce conflict. What does this indicate, and what are valid responses?

AThe grammar is ambiguous at that point; it can be resolved by rewriting the grammar, adding precedence declarations, or accepting Bison's default resolution
BThe grammar is syntactically incorrect and cannot produce a valid parser under any circumstances
CThe grammar is too complex for LALR parsing and must be converted to an LL grammar for ANTLR
DThe lexer is generating tokens in the wrong order, causing conflicts in the parsing table
Question 3 True / False

Bison and ANTLR both implement the same underlying parsing strategy (LALR), differing mainly in their target output language.

TTrue
FFalse
Question 4 True / False

A primary practical advantage of parser generators over hand-written recursive descent parsers is that generated parsers produce clearer, more informative syntax error messages.

TTrue
FFalse
Question 5 Short Answer

Why do some major production compilers use hand-written recursive descent parsers rather than parser generators, even though excellent tools like Bison and ANTLR exist?

Think about your answer, then reveal below.