Exam 11: Compilers and Language Translation
Regardless of which programming language is being analyzed, every scanner performs virtually the same set of operations. What are they?
-It discards blanks and other nonessential characters and looks for the beginning of a token;
-When it finds the beginning, it puts characters together until
-It detects the end of the token, at which point it classifies the token and begins looking for the next one.
What are the four phases of compilation?
• Phase I: Lexical analysis-The compiler examines the individual characters in the source program and groups them into syntactical units, called tokens, that will be analyzed in succeeding stages. This operation is analogous to grouping letters into words prior to analyzing text.
• Phase II: Parsing-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. This phase is roughly equivalent to checking whether the words in the text form grammatically correct sentences.
• Phase III: Semantic analysis and code generation-If the high-level language statement is structurally correct, then the compiler analyzes its meaning and generates the proper sequence of machine language instructions to carry out the intended actions.
• Phase IV: Code optimization-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, or possibly both.
The collection of all statements that can be successfully parsed is called the ____ defined by a grammar.
A
____ parsing algorithms examine several tokens "down the road" to see what would happen if a certain choice was made.
Performing local optimization is much more difficult than performing global optimization.
In BNF, the ____ is used to separate two alternative definitions of a nonterminal.
In _______, a nonterminal is an intermediate grammatical category used to help explain and organize the language.
____________________ for high-level languages like C++ or Java are very large.
One of the possible _______ optimizations is eliminating unnecessary operations.
Explain what metasymbols are and discuss their use as part of BNF rules.
A high-level language statement is translated into a single machine language instruction.
____ is the replacement of slow arithmetic operations with faster ones.
During parsing, a compiler deals only with the ____ of a statement.
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.
If a parser is analyzing a statement in a language and it sees exactly the same sequence of objects that appears on the right-hand side of a BNF rule, what is it allowed to do?
The English-language sentence, "The orange artichoke flew through the pink eight-legged elephant" is semantically meaningful . _________________________
In global optimization, the compiler looks at ______ segments of the program to decide how to improve performance.
A(n)____ definition defines a nonterminal symbol in terms of itself.
Building two parse trees implies that the parser has demonstrated correctness in two different ways. _________________________
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)