欢迎来到天天文库
浏览记录
ID:10477417
大小:241.00 KB
页数:19页
时间:2018-07-06
《大连理工大学编译原理实验报告》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、编译原理实验报告课程名称:编译原理课程设计考试形式:实验报告授课院(系):软件学院交作业日期:2013年7月26日共19页班级:学号:姓名:联系方式:电子邮件:手机号码:上机检查出勤实验报告(二)实验报告(三)总分标准分7010155100得分一、上机实验检查(总计70分):(1)分离解释和编译器(10分):将解释器从已有代码中分离出来,形成一个独立的解释器,对于中间代码文件,可以执行并输出相应的结果。(2)注释处理(10):增加对注释的支持,注释由(*和*)包含,不允许嵌套。(3)布尔数据处理(10分):增加对于布尔类型的支持,其产生式见《编译原理实
2、践教程》。(4)布尔表达式的短路处理(10分):在上面工作的基础上,对and和or采取短路计算。(5)for语句处理(10分): 参照C语言,增加对于for语句处理。(6)编译器界面实现(10分):增加界面实现,以可视化方法展示编译器运行过程。(7)编译器界面动画实现(10分):增加界面动画实现,以动态可视化方法展示编译器运行过程。二、完成情况(15分):一、完成情况(15分):1.修改后的PL/0词法(正规式)下面是本设计用到的正规式,bool类型的常量与变量都是通过保留字来体现的,number只是用于识别整型变量与常量。空白w->’’;//空格n
3、->;//回车t->Tab;//制表blank->(w
4、n
5、t)+;-19-保留字begin->begin;//保留字end->end;if->if;then->then;while->while;do->do;call->call;const->const;var->var;procedure->procedure;boolean->boolean;bool->true
6、false;//布尔常量数字以及IDdigit->0
7、1
8、2
9、3
10、4
11、5
12、6
13、7
14、8
15、9;number->digit(digit)*;letter->a-zA-Z;id->let
16、ter(digit
17、letter)*;特殊符号becomes->:=;leq->‘<=’;les->’<’;req->‘>=’;res->‘>’;relation->=
18、<=
19、>=
20、>
21、<;//关系运算符plus->‘+’;minus->‘-’;times->‘*’;slash->‘/’;odd->‘odd’;equ->’=’;lparen->’(’;rparen->‘)’;comma->‘,’;semicolon->‘;’;period->‘.’;and->‘&’;or->‘
22、’;not->‘!’;详情如下表:-19-空白w‘’空格n‘’回车t‘
23、t’Tabblank(w
24、n
25、t)+关键字beganbeganendendififthenthenwhilewhiledodocallcallconstconstvarvarprocedureprocedurebooleanbooleanboolfalse
26、true数字
27、IDdigit1
28、2
29、3
30、4
31、5
32、6
33、7
34、8
35、9
36、0numberdigit(digit)*lettera-zA-Zidletter(letter
37、digit)*特殊符号becomes:=leq<=les=res>relation=
38、>=
39、<=
40、>
41、42、imes*slash/oddoddequ=lparen(rparen)comma,semicolon;period.and&or43、44、not!-19-Program->Block.Block->Const_decl45、Var_option46、Procedures47、Statement48、Block49、εProcedure_decl->procedureidentifier;Block;Procedures->Procedure_declProcedures50、εConst_decl->constConst_menber51、ε Const_menber->ident=n52、umber,Const_menber53、ident=number; Var_option->varVar_decl_list54、ε Var_decl_list->Var_decl55、Var_decl_listVar_decl Var_decl->Ident_list:Type Ident_list->ident,Ident_list56、identifier Type->integer57、bool Statement->ident:=Condition; Statement->callidentifier; Statement->beginStatementsen58、d Statements->StatementStatements59、ε Statement->
42、imes*slash/oddoddequ=lparen(rparen)comma,semicolon;period.and&or
43、
44、not!-19-Program->Block.Block->Const_decl
45、Var_option
46、Procedures
47、Statement
48、Block
49、εProcedure_decl->procedureidentifier;Block;Procedures->Procedure_declProcedures
50、εConst_decl->constConst_menber
51、ε Const_menber->ident=n
52、umber,Const_menber
53、ident=number; Var_option->varVar_decl_list
54、ε Var_decl_list->Var_decl
55、Var_decl_listVar_decl Var_decl->Ident_list:Type Ident_list->ident,Ident_list
56、identifier Type->integer
57、bool Statement->ident:=Condition; Statement->callidentifier; Statement->beginStatementsen
58、d Statements->StatementStatements
59、ε Statement->
此文档下载收益归作者所有