Knowledge points in the compilation principle test questions

1. The concept of basic blocks (P152)

Local optimization refers to the optimization of each linear part of the code, so that there is only one entry and one exit in this linear part, and this linear part is called the basic block

The so-called basic block refers to a sequence of statements executed sequentially in a program, in which there is only one entry and one exit. The entry is the first statement of the sequence, and the exit is the last statement of the sequence. For a basic block, it can only enter from its entrance and exit from its exit during execution.

example:

2. The basic block of the program is (D).
A. A subroutine B. A statement with only one entry and one exit
C. A program segment without nesting D. A group of program segments executed sequentially, with only one entry and one exitInsert picture description here

Local optimization is an optimization limited to a basic block .

Recursive descent analysis method (P47)

The recursive descent analysis method is a top-down analysis method. Each non-terminal symbol of the grammar corresponds to a recursive process (function). The analysis process is to perform a set of recursive processes (functions) from the beginning of the grammar, and push it down until the sentence is introduced; or from the root node to find a leftmost matching sequence for the input string from top to bottom, and build a tree Syntax tree.

example

  1. Among the syntax analysis methods commonly used in high-level language compilers, the recursive descent analysis method belongs to the (B) analysis method.
    A. From left to right B. From top to bottom C. Bottom-up D. Right to left

Grammar (P35)

The grammar is a four-tuple: G = {VT,VN,S,P}

其中VT是一个非空有限的符号集合,它的每个元素成为终结符号。VN也是一个非空有限的符号集合,它的每个元素称为非终结符号,并且VT∩VN=Φ。S∈VN,称为文法G的开始符号。P是一个非空有限集合,它的元素称为产生式。所谓产生式,其形式为α→β,α称为产生式的左部,β称为产生式的右部,符号“→”表示“定义为”,并且α、β∈(VT∪VN)*,α≠ε,即α、β是由终结符和非终结符组成的符号串。开始符S必须至少在某一产生式的左部出现一次。另外可以对形式α→β,α→γ的产生式缩写为α→β|γ,以方便书写。

The following one is clearer, but the order is different from the book
Insert picture description here

example

1. 一个上下文无关文法 G 包括四个组成部分:一组终结符,一组非终结符,**一个(C ),以及一组(B )**。				

A. String B. Production C. Start symbol D. grammar

6. The language described by a grammar is (A); the grammar described by a language is (C).
A. The only B. Not the only C. May be unique or not

The attributes of grammar symbols include comprehensive attributes and ( integrated attributes ).

Compiled definition (P1)

The compiler can convert a source program written in a high-level language into a logically equivalent low-level language target program through it.

The process of compiling a program has five stages: lexical analysis stage, syntax analysis stage, semantic analysis stage and intermediate code generation stage, optimization stage, target code generation stage

5. The target program obtained after compilation is (D).
A. Quaternary sequence B. Indirect ternary sequence
C. Binary sequence D. Machine language program or assembly language program

  1. The working process of the compiler is generally divided into 5 stages: lexical analysis, (4), semantic analysis and intermediate code generation, code optimization and (5). There are also (6) and error handling.

4: Syntax analysis
5: Target code production
6: Form management

Dynamic storage allocation (P191)

Different compilers may have different storage allocation strategies for data space, but there are two schemes used in most compilations
: static storage allocation scheme and dynamic storage allocation scheme, and the latter is divided into ( stacked dynamic storage allocation ) and ( Heap dynamic storage allocation ).

Reverse Polish style (suffix style) – P116

The suffix of the expression x+y z/(a+b) is (**xyz ab+/+**).

Address calculation and intermediate code form of array elements

Store by line

Insert picture description here

Store by column

Insert picture description here

Assuming that the two-digit array is stored in rows, and each element occupies one storage unit, the address calculation formula for an element a[i,j] of the array a[1…15,1…20] is ( a+20 (i- 1)+j-1 *).

Analysis: Because each element occupies a storage unit,
the array starts from 1 after C=1 , so we are 20-1+1
and how many i-1 rows are there, j-1-0+1, And this question is j-1-1+1=j-1;
but I don’t understand that the first address is a, so the answer is a+20(i-1)+j-1;

Norm derivation, norm statute (P41)

The rightmost derivation is the normative derivation.
The inverse process of norm derivation is norm statute (leftmost statute)

  1. The normative statute is the most ( left ) statute.

Operator precedence analysis method (P64)

Operator precedence analysis is a simple and intuitive bottom-up analysis method, which is particularly suitable for analyzing various expressions in programming languages, and is suitable for manual implementation

The so-called operator priority analysis is to perform grammatical analysis in accordance with the four arithmetic operations of arithmetic expressions, that is, this analysis method must predefine the optimization relationship and combination properties between operators (to be precise, terminal symbols), and then use This relationship compares the precedence of adjacent operators to determine the "reducible string" of the sentence pattern for reduction. Therefore, the operator precedence algorithm is not a normative statute. What plays a decisive role in the entire statute process is the precedence relationship of two successive terminals.

example

Among the usual grammatical analysis methods, ( operator-first analysis method ) is especially suitable for the analysis of expressions.

Ambiguity of Grammar (P45)

If two different leftmost derivations (or rightmost derivations) can be found for a sentence of grammar G[S], or there are two different grammar trees, the sentence is said to be ambiguous. If a grammar contains ambiguous sentences, the grammar is ambiguous, otherwise it is unambiguous.

example

7. If there is a sentence in grammar G, when it meets one of the following conditions ( BCD ), the grammar is said to be an ambiguous grammar.
A. The leftmost derivation and the rightmost derivation are the same B. The sentence has two different leftmost derivations
C. The sentence has two different rightmost derivations D. The sentence has two different grammar trees
E. The syntax tree corresponding to the sentence is unique

Zipper-backfill technology (P120)

The following ( calculation of Boolean expressions, conditional statements, loop statements ) grammar-guided translation uses zipper-backfill technology.

Guess you like

Origin blog.csdn.net/weixin_44522477/article/details/112133091