- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
北邮 编译原理 语法分析(国外英文资料)
北邮 编译原理 语法分析(国外英文资料)
Compiling principle
Syntax analysis
Class:
Student number:
Name: ytinrete
Programming 2
Title: the design and implementation of syntax analysis program.
Experiment content: write the syntax analysis program to realize the syntax analysis of arithmetic expressions. Requires that the analyzed arithmetic expressions are generated by the following grammar.
Experimental requirements: in the analysis of the input expression, the output produced by the formula.
Method 1: write recursive call program to achieve top-down analysis.
Method 2: write LL (1) syntax analysis program, which requires as follows.
(1) programming implementation algorithm 4.2, construct prediction analysis table automatically for given grammar.
(2) programming implementation algorithm 4.1, construct LL (1) prediction analysis program.
Method 3: write a parser to implement bottom up analysis, as follows.
(1) constructing DFA that identifies all active prefixes.
(2) construct LR analysis table.
(3) programming algorithm 4.3, the construction of LR analysis program.
Method 4: use YACC to automatically generate syntax analysis program, and call LEX automatically generated lexical analysis program.
Method 2: write LL (1) parser
First, we deal with grammars, extension grammars of stored grammars, FIRST sets of non - terminating characters and FOLLOW sets.
Secondly, the programming algorithm 4.2 is used to construct the analysis table automatically for a given grammar.
Finally enter the string to be processed, through the implementation of algorithm 4.1, using the analysis table to analyze the string, can accept, then return to accept, otherwise return error.
Source code:
#include iostream
#include cstdio
#include cstdlib
#include cstring
#include string
#include stack
#include windows.h
Using namespace std;
String original[9]={/ / save the original method
E-E+T, E-E-T, E-T,
T-T*F, T-T/F, T-F,
F-i, F- (E), F-n
};
String G[11]={/ / extended grammar
E-TA, A-+TA, A--TA, A-e,
T-FB, B-*FB, B-/
您可能关注的文档
- 冒号的用法(国外英文资料).doc
- 关键词优化计谋(国外英文资料).doc
- 决战2011高考英语专题教材:非谓语动词在句顶用作定语(国外英文资料).doc
- 几种简略单纯将三相电机改为单相电机应用方法(国外英文资料).doc
- 几种罕赐教授教化手腕在小学英语语法教授教化中的新应用(国外英文资料).doc
- 凡卡评课稿(国外英文资料).doc
- 出国留学小我自述写作说明及四篇典范(国外英文资料).doc
- 出现正在连接到媒体和准备就绪的处理计划(国外英文资料).doc
- 出现频率最高的法语短语和词汇(国外英文资料).doc
- 出现频率最高的法语短语和词组经典轨则(国外英文资料).doc
- 2024-2025学年湖南省湘西州吉首市九年级(上)期末化学试卷(含答案).docx
- 2024-2025学年江苏省南通市通州区、如东县九年级(上)期末化学试卷(含答案).docx
- (新教材)2025年部编人教版七年级上册语文 13. 纪念白求恩 第2课时 课件.ppt
- (新教材)2025年部编人教版七年级上册语文 13. 纪念白求恩 教材习题课件 课件.ppt
- 2024-2025学年内蒙古通辽一中高一(上)期末物理试卷(含答案).docx
- (新教材)2025年部编人教版七年级上册语文 5. 秋天的怀念 第1课时 课件.ppt
- (新教材)2025年部编人教版七年级上册语文 5. 秋天的怀念 教材习题课件 课件.ppt
- (新教材)2025年部编人教版七年级上册语文 6. 散步 教材习题课件 课件.ppt
- (新教材)2025年部编人教版七年级上册语文 6. 散步 第2课时 课件.ppt
- (新教材)2025年部编人教版七年级上册语文 7. 荷叶 母亲 课件.ppt
原创力文档


文档评论(0)