编译原理复习回顾题

标签:
回顾总结编译原理杂谈 |
分类: 教学 |
各位同学:
一、
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.LR(0)分析中,“L”的含义是
11.SLR(1)分析中,“L”的含义是
12.LR(1)分析中,“L”的含义是
13.算术表达式:a*(-b+c)的逆波兰式表示为:
14.算术表达式:a+b*(c+d/e)的逆波兰式表示为:
15.在编译程序中安排中间代码生成的目的是
16.语法制导的翻译程序能同时进行
17.根据所涉及的程序范围,优化可分为
二、简单题
1.
2.
3.
{1n0m1m0n|n,m>=0}
{WaWr|W属于{0|1}*,Wr表示W的逆}
四、给出生成下列语言的三型文法:
{an|n>=0}
{anbm|n,m>0}
{anbmck|n,m,k>=0}
五、构造正规式1(0|1)*101相应的最小DFA。
六、构造正规式b(a|b)*bab相应的最小DFA。
七、已知文法G[S]: S->aH; H->aMd|d; M->Ab|ε; A->aM|e.
1.
2.
3.
八、已知文法G[B]:B->BoT|T; T->TaF|F; F->nF|(B)|t|f。
1.
2.
3.
九、文法G[S]:S->AB; A->aBa|ε;B->bAb|ε.
1.引入产生式S’->S,对文法进行改造为G[S’],计算G[S’]的First和Follow集,由此判断该文法是否是SLR(1)文法;
2.
3.若是SLR(1)文法,请构造它的分析表;
4.给出输入baab#的SLR(1)分析过程。
十、
1.
2.
3.
十一、将下面的程序段划分为基本块并作出其程序流图。
Read A,B
F:=1
C:=A*A
D:=B*B
If C<D goto L1
E=A*A
F=F+1
E:=E+f
Write E
Halt
L1:
Halt
L2:
十二、有下面基本块:
S0:=2
S1:=3/S0
S2:=T-C
S3:=T+C
R:=S0/S3
H:=R
S4:=3/S1
S5:=T+C
S6:=S4/S5
H:=S6*S2
1.
2.
十三、翻译下列关于LEX一点介绍的英文。
2. Lex Source.
The general format of Lex source is:
{definitions}
%%
{rules}
%%
{user subroutines}
where the definitions and the user subroutines are often omitted. The second %% is optional, but the first is required to mark the beginning of the rules. The absolute minimum Lex program is thus
%%
(no definitions, no rules) which translates into a program which copies the input to the output unchanged.
In the outline of Lex programs shown above, the rules represent the user’s control decisions; they are a table, in which the left column contains regular expressions (see section 3) and the right column contains actions, program fragments to be executed when the expressions are recognized. Thus an individual rule might appear
integer
to look for the string integer in the input stream and print the message ‘‘found keyword INT’’ whenever it appears. In this example the host procedural language is C and the C library function printf is used to print the string. The end of the expression is indicated by the first blank or tab character. If the action is merely a single C expression, it can just be given on the right side of the line; if it is compound, or takes more than a line, it should be enclosed in braces. As a slightly more useful example, suppose it is desired to change a number of words from British to American spelling. Lex rules such as
colour
mechanise
petrol
would be a start. These rules are not quite enough, since the word petroleum would become gaseum; a way of dealing with this will be described later.
十四、翻译下列有关yacc的一些英文介绍。
Introduction
YACC is short for Yet Another Compiler
Compiler.
YACC was originally written by S. C. Johnson on a UNIX
platform.
For both types of parser, either LR or LL, there is generally an
extra piece of information which specifies how many lookahead
tokens the parser uses to decide what action to
perform.