chapter 3 Flashcards
(101 cards)
________ is the process of constructing a syntactic structure (parse tree) from a stream of tokens
Answer: Parsing
The parser receives a string of tokens from the ________ analyzer and verifies if the string of token names can be generated by the grammar for the source language.
Answer: lexical
Which phase of the compiler constructs the abstract syntax tree?
a) Lexical Analysis
b) Syntax Analysis
c) Semantic Analysis
d) Code Generation
Answer: b) Syntax Analysis
what does the The parser in syntax analysis perform?
context free syntax analysis,
guides context-sensitive analysis,
constructs an intermediate representation, produces meaningful error messages,
and attempts error correction.
________ parsing methods include the CYK algorithm and Earley’s algorithm.
Answer: Universal
what are the three general types of parsers for grammars?
universal,
top-down, and
bottom-up
Which of the following parsers build parse trees from the top (root) to the bottom (leaves)?
a) Bottom-Up Parsers
b) Top-Down Parsers
c) CYK Parsers
d) Earley Parsers
Answer: b) Top-Down Parsers
Universal parsing methods are, too inefficient to use in production compilers.
t
Compilers assist programmers in identifying and locating ________.
Answer: errors
The information which syntax analysis phase gets from the previous phase (lexical
analysis) is _________ and _________
- whether a token is valid or not and
- which class of tokens does it belong to.
it is beyond the capabilities of the syntax analysis phase to settle issues
like:
Whether or not a variable has already been declared?
Whether or not a variable has been initialized before use?
Whether or not a variable is of the type on which the operation is allowed?
what are Error handler goals
Report the presence of errors clearly and accurately
Recover from each error quickly enough to detect subsequent errors
Add minimal overhead to the processing of correct programs
Which of the following is not a common programming error?
a) Lexical Error
b) Syntactic Error
c) Semantic Error
d) Predictive Error
Answer: d) Predictive Error
In ________ , the parser discards input symbols until a designated synchronization token is found.
Answer: Panic Mode recovery
______ errors include misspellings of identifiers, keywords, or operators
Lexical
_______ errors include misplaced semicolons or extra or missing braces; that
is, “{“ or “}.”
Syntactic
_____ errors include type mismatches between operators and operands.
Semantic
what are The four main strategies in error handling:
a) Panic Mode Recovery
b) Phrase Level Recovery
c) Error Productions
d) Global Correction
Which error recovery strategy involves making local corrections to allow the parser to continue?
a) Panic Mode Recovery
b) Phrase Level Recovery
c) Error Productions
d) Global Correction
Answer: b) Phrase Level Recovery
________ augment grammar with productions that generate erroneous constructs.
Answer: Error Productions
_____ Simplest method of recovery used by most parsing methods.
Panic Mode Recovery
Panic mode recovery will lead to an infinite loop.
f
________ Replaces a prefix of remaining input by some string that allows the parser to continue.
Phrase Level Recovery
Care should be taken by the replacements , not to lead to infinite loops in ______ recovery
Phrase Level Recovery