CST 8152 Compilers Midterm #2 Review Questions
Define briefly: backtracking, predictive parsing, recursive-descent parsing, grammar production, terminal symbol, non-terminal symbol, top-down parsing, bottom-up parsing, semantic action symbols, translation scheme, token, look ahead token, white space, lexeme, value stack, panic-mode recovery, phrase-level recovery, error productions, unary minus.
Why cant a recursive-decent parsing function be written for the following grammar rule: <> -> <> + <> (Hint: Try to write the function.)
Define and document a C language data structure that would hold one element of the symbol table needed for Assignment 5.
Define and document a C language data structure implementing the global data returned by the scanner() in Assignment 5.
What are three goals of the error handler in a parser?
Describe four levels at which errors may occur in a program. Which level has been given the most attention by compiler writers and why?
Statistically, what kinds of errors occur in real programs?
What is the difference between error recovery and error repair in a parser?
Why not quit the parser upon finding the first error?
Briefly describe three error recovery methods for a parser.
How can a parser distinguish between different statement types in a language, e.g. between for() and while() statements?
Draw a block diagram showing the difference between an interpreter and a compiler.
List some (up to seven) advantages of an interpreter over a compiler.
List some disadvantages of interpreters.
Why are loops so difficult for interpreters?
What four basic types of functions are needed for an interpreter?
What three data structures are needed for an interpreter?
How can the scanner differentiate between subtract and unary minus?
How can the parser differentiate between subtract and unary minus?
Write a recursive descent parsing function that implements any of the grammar productions in the Toy Grammar from the notes. No semantic actions are required; the functions need only recognize the input.
Write pseudocode functions that shows what code is needed to write a recursive descent parser, with semantic actions, for the following simple grammar: