INVITATION TO COMPUTER SCIENCE 6TH EDITION BY SCHNEIDER – TEST BANK
Chapter 11: Compilers and Language Translation
1. High-level languages must be translated into hybrid language before they can be exe-cuted. _________________________
2. Parsing is the first phase of the compilation process. _________________________
3. In BNF, the syntax of a language is specified as a series of grammars. _________________________
4. Building two parse trees implies that the parser has demonstrated correctness in two different ways. _________________________
5. The English-language sentence, “The orange artichoke flew through the elephant” is semantically meaningful. _________________________
1. The output of a(n) ____________________ is a list of all the tokens contained in a high-level language statement, as well as the classification number of each token found.
2. The output of a parser is a(n) complete ____________________, or an error message if one cannot be constructed.
3. If a parser can convert the sequence of input tokens into the goal symbol, then that sequence of tokens is a syntactically ____________________ statement of the language.
4. ____________________ for high-level languages like C++ or Java are very large.
5. One of the possible local ____________________ is eliminating unnecessary opera-tions.
1. A high-level language statement is translated into a single machine language instruc-tion.
2. The singular goal of compilers is correctness.
3. The code a compiler produces should be reasonably efficient and concise.
4. The input to a scanner is the machine language statement from the source program.
5. A BNF rule is also known as a production.
6. The righthand side of a BNF rule is the name of a single grammatical category.
7. The goal symbol is the final nonterminal.
8. A grammar that allows the construction of two or more distinct parse trees for the same statement is called a recursive grammar.
9. Online debuggers help programmers locate and correct errors in programs.
10. Performing local optimization is much more difficult than performing global optimiza-tion.
1. During the ____ phase, the sequence of tokens formed by the scanner is checked to see whether it is syntactically correct according to the rules of the programming language.
a. lexical analysis c. code optimization
b. parsing d. semantic analysis and code generation
2. In the ____ phase, the compiler examines the individual characters in the source pro-gram and groups them into tokens.
a. semantic analysis and code generation c. lexical analysis
b. parsing d. code optimization
3. In the ____ phase, the compiler takes the generated code and sees whether it can be made more efficient, either by making it run faster or having it occupy less memory.
a. code optimization c. lexical analysis
b. parsing d. semantic analysis and code generation
4. A high-level language program is called a(n) ____ program.
a. object c. lexical
b. source d. token
5. A ____ shows how individual tokens can be grouped into predefined grammatical cat-egories until the desired goal is reached.
a. parse tree c. parser
b. scanner d. compiler
6. In BNF, a ____ is an intermediate grammatical category used to help explain and or-ganize the language.
a. production c. terminal
b. rule d. nonterminal
7. The collection of all statements that can be successfully parsed is called the ____ de-fined by a grammar.
a. language c. nonterminal
b. terminal d. rule
8. The Greek character lambda represents ___.
a. zero c. the defined string
b. the null string d. the unknown string
9. In BNF, the ____ is used to separate two alternative definitions of a nonterminal.
a. forward slash c. backward slash
b. vertical bar d. asterisk
10. ____ parsing algorithms examine several tokens “down the road” to see what would happen if a certain choice was made.
a. Look-ahead c. Down-the-road
b. Token prediction d. Recursive
11. A(n) ____ definition defines a nonterminal symbol in terms of itself.
a. ambiguous c. local
b. recursive d. global
12. During parsing, a compiler deals only with the ____ of a statement.
a. semantics c. grammar
b. syntax d. rules
13. A ____ is a data structure that stores information about a nonterminal, such as the ac-tual name of the object and its data type.
a. rule c. parse tree
b. production d. semantic record
14. Following ____, the compiler makes a second pass over the parse tree to produce the translated code.
a. semantic analysis c. code optimization
b. lexical analysis d. code generation
15. ____ begins at the productions in the tree that are nearest to the original input tokens.
a. Code generation c. Lexical analysis
b. Parsing d. Semantic analysis
16. ____ is where the compiler polishes and fine-tunes the translation so that it runs a little faster or occupies a little less memory.
a. Compilation c. Optimization
b. Generation d. Efficiency
17. ____ is the ability to write highly optimized programs that contain no wasted time or unnecessary memory cells.
a. Conciseness c. Code-aware
b. Ambiguity d. Efficiency
18. A(n) ____ is a compiler embedded with a collection of supporting software.
a. debugger c. visual development library
b. reusable code library d. integrated development environment
19. ____ is the replacement of slow arithmetic operations with faster ones.
a. Strength reduction c. Eliminating unnecessary operations
b. Constant evaluation d. Parse tree construction
20. In ____ optimization, the compiler looks at large segments of the program to decide how to improve performance.
a. local c. semantic
b. global d. syntactical