



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This was university exam and assignments
Typology: Exams
1 / 7
This page cannot be seen from the preview
Don't miss anything!




(For 19 lc 软工 1,1 8 lq 软工 1 ) Open book
Note: If the student number, name and class are not written, not all written or written outside the sealing line, the test paper will be invalidated.
1 、 In analysis phase, an intermediate representation is created from the given source
program. Lexical Analyzer , Syntax Analyzer and Semantic Analyzer are the
parts of this phase.
2 、 identifiers, operators, keywords, numbers, delimiters and so on are used to
describe tokens (lexical constructs)
3 、 A parse tree describes a syntactic structure.In a parse tree, all terminals are at
leaves.All inner nodes are non-terminals in a context free grammar.
4 、 When programming in a high-level language, target program and
error messages of the source program can be found by compiler.
5 、 Top-Down Parsing:Construction of the parse tree starts at the at the root and
proceeds towards the the leaves..
Total score
Verifying person
name
number
Student Class
19 lc 软工 1
1 、 The purpose of dividing the compilation process into several "passes" is to
A、Improving the efficiency of program execution
B、Make the organization of the program clearer
C、Make use of limited machine memory and improve machine execution efficiency
D、Use limited machine memory but reduce machine execution efficiency.
2 、 The input to the lexical analyzer is( B )。
A、Word string
B、source program
C、Grammatical unit
D、Target program
3 、 Compilers spend most of their time on( B )。
A、Error handling; B、lexical analysis;
C、Target code generation; D、Table management
4 、 Any operator precedence grammar ( D ) precedence function。
A、 there is one
B、 No
C、 There are several
D、 there may be several
5 、 The following is an incorrect description of the grammar tree( C )。
A、The root node is marked with the beginning S of the grammar G [S].
B、Each node is marked with a terminator or non-terminator of G[S].
C、If a node is marked as ε it must be a leaf node.
D、Internal nodes can be non-terminators
It is proved that this method has ambiguity. answer:Because there are two grammar trees in the sentence pattern 9 - 5 + 2 of this grammar:
Answer:
五、The following grammar G : E->TE’
E’->+E| ε
T' - >*FT’| ε
F-> (E)|id
(1) how to construct id+id*id, use parsing table M for grammar? (10 points)
(2) moves made by predictive parser on input id+id*id.Prove that this method is LL(1)。
(10points)
(3) The leftmost derivation for the id+id*id。(10 points)
Answer: 1