编译原理实验报告算术表达式递归下降分析程序设计

上传人:r****d 文档编号:93593983 上传时间:2022-05-20 格式:DOC 页数:56 大小:340.50KB
收藏 版权申诉 举报 下载
编译原理实验报告算术表达式递归下降分析程序设计_第1页
第1页 / 共56页
编译原理实验报告算术表达式递归下降分析程序设计_第2页
第2页 / 共56页
编译原理实验报告算术表达式递归下降分析程序设计_第3页
第3页 / 共56页
资源描述:

《编译原理实验报告算术表达式递归下降分析程序设计》由会员分享,可在线阅读,更多相关《编译原理实验报告算术表达式递归下降分析程序设计(56页珍藏版)》请在装配图网上搜索。

1、武 汉 工 程 大 学计算机科学与工程学院编译原理实验报告专业班级实验地点学生学号指导教师学生姓名实验时间实验项目实验二、算术表达式递归下降分析程序设计实验类别操作性() 验证性() 设计性() 综合性( ) 其它实验目的及要求(1)掌握自上而下语法分析的要求与特点。 (2)掌握递归下降语法分析的基本原理和方法。(3)掌握相应数据结构的设计方法。成 绩 评 定 表类 别评 分 标 准分值得分合 计上机表现积极出勤、遵守纪律主动完成实验设计任务30分实验报告及时递交、填写规范内容完整、体现收获70分说明: 评阅教师: 日 期: 实 验 内 容一、 实验目的(1)掌握自上而下语法分析的要求与特点。

2、(2)掌握递归下降语法分析的基本原理和方法。(3)掌握相应数据结构的设计方法。二、 实验内容编程实现给定算术表达式的递归下降分析器。算术表达式文法如下: EE+T | TTT*F | FF(E) | i 设计说明:首先改写文法为LL(1)文法;然后为每一个非终结符,构造相应的递归函数,函数的名字表示规则左部的非终结符;函数体按规则右部符号串的顺序编写。三、 设计分析(1)消去该文法左递归,得到文法: ETE1E1+TE1|TFT1T1*FT1|F(E)| I(2)根据LL(1)文法的判断条件,计算这个文法的每个非终结符的FIRST集和FOLLOW集,经验证,改后的文法已经是LL(1)文法。(3

3、)最后构造递归下降分析程序,每个函数名是相应的非终结符,函数体则是根据右部符号串的结构编写。a.当遇到非终结符时,如:+。则编写语句 if(当读来的输入符号 = +) 读下一个输入符号b.当遇到非终结符时,例如:T。则编写语句调用T()。c.当遇到非终结符规则时,例如:T。则编写语句 if(当前读来的输入字符不属于FOLLOW(T) error()d.当某个非终结符的规则有很多个候选式时。按LL(1)文法的条件能唯一的选择一个候选式进行推导。 (4)递归下降分析法是确定的自上而下分析法,基本思想是,对文法中的每个非终结符编写一个函数,每个函数的功能是识别由该非终结符所表示的语法成分。因此需要分

4、别构造E,E1,T,T1,F函数来执行自己的识别功能,根据文法的内容顺序决定函数的识别功能。Scaner函数用于字符串的推进,input函数用于字符串的输入。四、 程序代码#include #include #include using namespace std;char a80; char sym;int i=0; void E();void E1();void T();void T1();void F();void input();void Scaner();void Error();void input()puts(输入需要分析的字符串(以#键结尾):);cina;void Scane

5、r()sym = ai;i+;void Error()coutErrorendl;exit (0);void main()while(1)input();Scaner();E();if (sym = #)printf(此字符串是该文法的字符串!n);elseprintf(Error!n);i=0;void E()T();E1();void E1()if (sym = +)Scaner();T();E1();else if (sym!=) & (sym!=#)Error();void T()F();T1();void T1()if (sym = *)Scaner();F();T1();else

6、if (sym!=+ & sym!=) & sym!=#)Error();void F()if (sym = ()Scaner();E();if (sym = )Scaner();else Error();else if (sym =i)Scaner();elseError();五、 测试用例1. 输入的字符串只含有一个字符时:输入 i# a#2输入的字符串含有 + 时:输入 +#输入 i+#输入 i+i#3输入的字符串含有 * 时: 输入 *# 输入 *i# 输入 *i*# 输入 i*i# i*i*#3输入的字符串含有 () 时:输入 ()#(i)#4输入的字符串含有多种字符: 输入i+i*

7、i#(i+i)*i#(i+i)*(i+i)#(i+*# 实 验 总 结此次实验,使我掌握自上而下语法分析的要求与特点,也更加了解递归下降语法分析的基本原理和方法并学会相应数据结构的设计方法。递归下降分析法简单、直观,易于构造程序,但它对文法要求较高,必须是LL(1)文法,同时递归调用较多,在编程的时候要特别注意,函数的顺序不能打乱,函数声明要位置明确,不能乱,掌握一定的规律,使程序有条理。在实验中也出现了一些错误和碰到了一些难题,不过在同学的帮助下基本上都解决了。在刚开始的设计分析思路和程序设计中,也遇到过一些问题,一般的情况是对所学的知识还没有完全掌握好,没有透彻理解,对所学知识不能够灵活运

8、用,在课后需要多巩固。在以后的日子里,需要学习的还有很多,不能懈怠。(英文版 ) Two regulations promulgated for implementation is in the party in power for a long time and the rule of law conditions, the implementation of comprehensive strictly strategic plan, implementation in accordance with the rules and discipline to manage the party

9、, strengthen inner-party supervision of major initiatives. The two regulations supporting each other, the adhere to a positive advocate, focusing on morality is of Party members and Party leading cadres can see, enough to get a high standard; around the party discipline, disciplinary ruler requireme

10、nts, listed as negative list, focusing on vertical gauge, draw the party organizations and Party members do not touch the bottom line . Here, the main from four square face two party rules of interpretation: the first part introduces two party Revised regulations the necessity and the revision proce

11、ss; the second part is the interpretation of the two fundamental principles of the revision of laws and regulations in the party; the third part introduces two party regulations modified the main changes and needs to grasp several key problems; the fourth part on how to grasp the implementation of t

12、he two regulations of the party. and revised the necessity and revised history of the CPC Central Committee the amendment to the Chinese Communist Party members and leading cadres honest politics several guidelines and column 1 by 2015 to strengthen party laws and regulations focus. Two party regula

13、tions revision work lasted a Years, pooling the wisdom of the whole party, ideological consensus, draw historical experience, respect for the wisdom of our predecessors, which reflects the unity of inheritance and innovation; follow the correct direction, grasp the limited goals, adhere to the party

14、s leadership, to solve the masses of the people reflect a focus on the problem. The new revision of the and , reflects the partys 18 and the eighth session of the third, the spirit of the fourth plenary session, reflecting the experience of studying and implementing the General Secretary Xi Jinping

15、series of important speech, reflects the partys eighteen years comprehensive strictly practice. (a) revised two regulations of the party need of in based on revised, the promulgation and implementation of January 2010, to strengthen the construction of the contingent of leading cadres play an import

16、ant role. But with the party to manage the party strictly administering the deepening, has not been able to fully meet the actual needs. Content is too complicated, eight prohibition, 52 are not allowed to hard to remember, and also difficult to put into practice; the second is concisely positive ad

17、vocated by the lack of prohibited provisions excessive, no autonomy requirements; the third is banned terms and discipline law, both with the party discipline, disciplinary regulations repeat and Criminal law and other laws and regulations repeat; the fourth is to clean the theme is not prominent, n

18、ot for the existing problems, and is narrow, only needle of county-level leading cadres above. is in 1997 based on revision, in December 2003 the promulgation and implementation, to strengthen the construction of the party play very important role. Along with the development of the situation, which

19、many provisions have been unable to fully meet the comprehensive strictly administering the practice needs. One is Ji law, more than half of the provisions and criminal law and other countries laws and regulations Repetition; two is the political discipline regulations is not prominent, not specific

20、, for violation of the party constitution, damage the authority of Party Constitution of misconduct lack necessary and serious responsibility to pursue; third is the main discipline for the leading cadres, does not cover all Party members. Based on the above situation, need to and the two is likely

21、to be more relevant regulations first amendment. By revising, really put the authority of Party discipline, the seriousness in the party tree and call up the majority of Party members and cadres of the party constitution of party compasses party consciousness. (II) two party regulations revision pro

22、cess the Central Committee of the Communist Party of China attaches great importance to two regulations revision . Xi Jinping, general books recorded in the Fifth Plenary Session of the eighth session of the Central Commission for Discipline Inspection, on the revised regulations made clear instruct

23、ions. According to the central deployment, the Central Commission for Discipline Inspection from 2014 under six months begin study two regulations revision. The Standing Committee of the Central Commission for Discipline Inspection 4 review revised. Comrade Wang Qishan 14 times held a special meetin

24、g to study two regulations revision, amendment clarifies the direction, major issues of principle, path and target, respectively held a forum will listen to part of the province (area) secretary of the Party committee, Secretary of the Discipline Inspection Commission, part of the central ministries

25、 and state organs Department The first party committee is mainly responsible for people, views of experts and scholars and grassroots party organizations and Party members. Approved by the Central Committee of the Communist Party of China, on 7 September 2015, the general office of the Central Commi

26、ttee of the Party issued a notice to solicit the provinces (autonomous regions, municipalities) Party, the central ministries and commissions, state ministries and commissions of the Party (party), the General Political Department of the military, every 3 people organization of Party of two regulati

27、ons revision opinion. Central Commission for Discipline Inspection of extensive solicitation of opinions, careful study, attracting, formed a revised sent reviewers. In October 8 and October 12, Central Committee Political Bureau Standing Committee and the Political Bureau of the Central Committee A

28、fter consideration of the two regulations revised draft. On October 18, the Central Committee of the Communist Party of China formally issued two regulations. Can say, two laws amendment concentrated the wisdom of the whole party, embodies the party. Second, and revision of the basic principles of t

29、wo party regulations revision work and implement the partys eighteen, ten eight plenary, the spirit of the Fourth Plenary Session of the Eleventh Central Committee and General Secretary Xi Jinping important instructions on the revised and , highlighting the ruling party characteristics, serious disc

30、ipline, the discipline quite in front of the law, based on the current, a long-term, advance as a whole, with Bu Xiuding independent and . Main principle is: first, adhere to the party constitution to follow. The constitution about discipline and self-discipline required specific, awaken the party c

31、onstitution of party compasses party consciousness, maintaining the authority of the constitution. General Secretary Xi Jinping pointed out that no rules, no side round. Party constitution is the fundamental law, the party must follow the general rules. In early 2015 held the eighth session of the C

32、entral Commission for Discipline Inspection Fifth Plenary Session of the 16th Central Committee, Xi Jinping again pointed out that constitution is the party must follow the general rules, but also the general rules. the revision of the and is Method in adhere to the regulations established for the p

33、urpose of combining rule of virtue is to adhere to the party constitution as a fundamental to follow, the constitution authority set up, wake up the party constitution and party rules the sense of discipline, the party constitution about discipline and self-discipline specific requirements. 4 second

34、 is to adhere to in accordance with the regulations governing the party and the party. The Party of rule of virtue de, mainly refers to the partys ideals and beliefs, excellent traditional style. The revised the closely linked to the self-discipline, insisting on the positive initiative, for all mem

35、bers, highlight the vital few, emphasized self-discipline, focusing on the morality, and the majority of Party members and the ideological and moral standards. The revised Ji method separately, Ji, Ji Yan to Method, as a negative list, emphasizing the heteronomy, focusing on vertical gauge. Is this

36、one high and one low, a positive reaction, the strict party discipline and practice results transformation for the integration of the whole party to observe moral and discipline requirements, for the majority of Party members and cadres provides benchmarking and ruler. Third, insist on to. In view o

37、f the problems existing in the party at the present stage, the main problems of Party members and cadres in the aspect of self-discipline and abide by the discipline to make clearly defined, especially the partys eighteen years strict political discipline and political rules, organization and discip

38、line and to implement the central eight provisions of the spirit against the four winds and other requirements into Disciplinary provisions. Not one pace reachs the designated position, focusing on in line with reality, pragmatic and effective. After the revision of major changes, major changes in t

39、he and modified and needs to grasp several key problems (a) adhere to according to regulations governing the party and party with morals in combination, for at the present stage, the leadership of the party members and cadres and Party members in existing main problems of self-discipline, put forwar

40、d principles, requirements and specifications, showing Communists noble moral pursuit, reflected at all times and in all over the world ethics from high from low 5 common requirements. One is closely linked to the self-discipline, removal and no direct relation to the provisions of . the second is a

41、dhere to a positive advocate, eight prohibition 52 are not allowed to about the content of the negative list moved into synchronization amendment . Three is for all the party members, will apply object from the leadership of the party members and cadres to expand to all Party members, fully embodies

42、 the comprehensive strictly required. The fourth is prominent key minority, seize the leadership of the party members and cadres is the key, and put forward higher requirements than the ordinary Party members. Five is to simplify, and strive to achieve concise, easy to understand, easy to remember.

43、The revised is the ruling Party since the first insists on a positive advocate forAll Party members and the self-discipline norms, moral declaration issued to all members of the party and the National Peoples solemn commitment. criterion of a clean and honest administration consists of 4 parts, 18,

44、more than 3600 words. After the revision of the , a total of eight, 281 words, including lead, specification and Party member cadre clean fingered self-discipline norms, etc. Part 3 members low-cost clean and self-discipline, the main contents can be summarized as four must eight code. Lead part, re

45、iterated on ideal and faith, fundamental purpose, the fine traditions and work style, noble sentiments, such as four must the principle of requirements, strong tone of self-discipline, The higher request for 6 and supervised tenet, the foothold in permanent Bao the partys advanced nature and purity,

46、 to reflect the revised standards requirements. Members of self-discipline norms around the party members how to correctly treat and deal with the public and private, cheap and rot thrifty and extravagance bitter music, put forward the four norms. Party leader cadre clean fingered self-discipline no

47、rms for the leadership of the party members and cadres of the vital few, around the clean politics, from civil servant of the color, the exercise of power, moral integrity, a good family tradition and other aspects of the leadership of the party members and cadres of the four norms to fully adapt to

48、 the strictly requirements, reflects the according to the regulations governing the law of recognition of deepening, the realization of the discipline construction and Jin Ju. is party a ruler, members of the basic line and follow. And the majority of Party members and cadres of Party organizations

49、at all levels should adhere to the bottom line of thinking, fear discipline, hold the bottom line, as a preventive measure, to keep the partys advanced nature and purity. 1, respect for the constitution, refinement and discipline. Revised from comprehensive comb physical constitution began, the part

50、y constitution and other regulations of the Party of Party organizations and Party discipline requirements refinement, clearly defined in violation of the party constitution will be in accordance with regulations to give the corresponding disciplinary action. The original 10 categories of misconduct

51、, integration specification for political discipline, discipline, honesty and discipline masses Ji Law and discipline and discipline and other six categories, the content of real return to Party discipline, for the majority of Party members and listed a negative list. 7 2, highlighting the political

52、 discipline and political rules. Regulations according to the stage of the discipline of outstanding performance, emphasizing political discipline and political rules, organization and discipline, in opposition to the partys leadership and the partys basic theory, basic line, basic program and basic

53、 experience, the basic requirement of behavior made prescribed punishment, increase the cliques, against the organization such as violation of the provisions, to ensure that the central government decrees and the Party of centralized and unified. 3, adhere to strict discipline in the law and discipl

54、ine In front, Ji separated. Revised adhere to the problem oriented, do Ji separated. Any national law existing content, will not repeat the provisions, the total removal of 79 and criminal law, repeat the content of the public security management punishment law, and other laws and regulations. In th

55、e general reiterated that party organizations and Party members must conscientiously accept the partys discipline, die van comply with national laws and regulations; at the same time, to investigate violations of Party members and even criminal behavior of Party discipline and responsibility, Regula

56、tions distinguish five different conditions, with special provisions were made provisions, so as to realize the connection of Party discipline and state law. 4, reflect Wind building and anti-corruption struggle of the latest achievements. the partys eighteen years implement the spirit of the centra

57、l provisions of the eight, against the requirements of the four winds and transformation for disciplinary provisions, reflecting the style construction is always on the road, not a gust of wind. In the fight against corruption out of new problems, increase the trading rights, the use of authority re

58、latives profit and other disciplinary terms. Prominent discipline of the masses, the new against the interests of the masses and ignore the demands of the masses and other disciplinary terms and make provisions of the disposition and the destruction of the partys close ties with the masses. Discipli

59、ne to protect the partys purpose. 8 of these regulations, a total of three series, Chapter 15, 178, more than 24000 words, after the revision of the regulations a total of 3 series, Chapter 11, 133, 17000 words, divided into general and special provisions and Supplementary Provisions Part 3. Among them, add, delete, modify th

展开阅读全文
温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!