编译原理实验词法分析

上传者: u010202637 | 上传时间: 2021-05-24 10:34:32 | 文件大小: 101KB | 文件类型: RAR
此资源包含源代码和实验报告。 一、实验目的 设计、编制、调试一个词法分析子程序-识别单词,加深对词法分析原理的理解。通过本实验的编程实践,使学生了解词法分析的任务,掌握词法分析程序设计的原理和构造方法,使学生对编译的基本概念、原理和方法有完整的和清楚的理解,并能正确地、熟练地运用。 二、实验要求 该程序要实现的是一个读单词过程,从输入的源程序中,识别出各个具有独立意义的单词,即关键字、标识符、数据、运算符、分界符等五大类,并依次输出各个单词的种类及单词符号自身值。若遇到错误则显示“Error”,然后跳过错误部分继续显示 。 三、实验内容 通过输入源程序从左到右对字符串进行扫描和分解,依次输出各个单词的内部编码及单词符号自身值;若遇到错误则显示“Error”,然后跳过错误部分继续显示。 以下是实现词法分析设计的主要工作: (1)从源程序文件中读入字符。 (2)删除空格类字符,包括回车、制表符空格。 (3)按拼写单词,并用(单词,属性)二元式表示。 (4)如果发现错误则报告出错。 单词的基本分类: 关键字:由程序语言定义的具有固定意义的标识符。也称为保留字例如 i f、const; 单词种别码为1。 标识符:用以表示各种名字,如变量名、数组名、函数名;种别码为2。 数据: 任何数值常数。如 125,3.14等;种别码为3。 运算符:+、-、*、/、<、<=、= 、>、>=、<>;种别码为4。 分界符: ; 、, 、(、) 、[、];种别码为5。 Error:#、%等。

文件下载

资源详情

[{"title":"( 33 个子文件 101KB ) 编译原理实验词法分析","children":[{"title":"编译原理大型实验","children":[{"title":"WordAnalysis","children":[{"title":"WordAnalysis.v11.suo <span style='color:#111;'> 35.50KB </span>","children":null,"spread":false},{"title":"WordAnalysis.sln <span style='color:#111;'> 926B </span>","children":null,"spread":false},{"title":"WordAnalysis","children":[{"title":"Form1.Designer.cs <span style='color:#111;'> 6.58KB </span>","children":null,"spread":false},{"title":"Program.cs <span style='color:#111;'> 524B </span>","children":null,"spread":false},{"title":"obj","children":[{"title":"Debug","children":[{"title":"TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs <span style='color:#111;'> 0B </span>","children":null,"spread":false},{"title":"WordAnalysis.Form1.resources <span style='color:#111;'> 180B </span>","children":null,"spread":false},{"title":"WordAnalysis.exe <span style='color:#111;'> 15.00KB </span>","children":null,"spread":false},{"title":"WordAnalysis.Properties.Resources.resources <span style='color:#111;'> 180B </span>","children":null,"spread":false},{"title":"DesignTimeResolveAssemblyReferencesInput.cache <span style='color:#111;'> 6.89KB </span>","children":null,"spread":false},{"title":"TempPE","children":null,"spread":false},{"title":"TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs <span style='color:#111;'> 0B </span>","children":null,"spread":false},{"title":"WordAnalysis.csprojResolveAssemblyReference.cache <span style='color:#111;'> 2.09KB </span>","children":null,"spread":false},{"title":"TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs <span style='color:#111;'> 0B </span>","children":null,"spread":false},{"title":"WordAnalysis.csproj.FileListAbsolute.txt <span style='color:#111;'> 3.01KB </span>","children":null,"spread":false},{"title":"WordAnalysis.csproj.GenerateResource.Cache <span style='color:#111;'> 975B </span>","children":null,"spread":false},{"title":"DesignTimeResolveAssemblyReferences.cache <span style='color:#111;'> 1.25KB </span>","children":null,"spread":false},{"title":"WordAnalysis.pdb <span style='color:#111;'> 39.50KB </span>","children":null,"spread":false}],"spread":false}],"spread":true},{"title":"bin","children":[{"title":"Debug","children":[{"title":"WordAnalysis.exe <span style='color:#111;'> 15.00KB </span>","children":null,"spread":false},{"title":"WordAnalysis.exe.config <span style='color:#111;'> 187B </span>","children":null,"spread":false},{"title":"lqs.txt <span style='color:#111;'> 136B </span>","children":null,"spread":false},{"title":"WordAnalysis.vshost.exe.config <span style='color:#111;'> 187B </span>","children":null,"spread":false},{"title":"WordAnalysis.vshost.exe.manifest <span style='color:#111;'> 490B </span>","children":null,"spread":false},{"title":"WordAnalysis.vshost.exe <span style='color:#111;'> 22.45KB </span>","children":null,"spread":false},{"title":"WordAnalysis.pdb <span style='color:#111;'> 39.50KB </span>","children":null,"spread":false}],"spread":true}],"spread":true},{"title":"Form1.cs <span style='color:#111;'> 10.45KB </span>","children":null,"spread":false},{"title":"WordAnalysis.csproj <span style='color:#111;'> 3.71KB </span>","children":null,"spread":false},{"title":"Form1.resx <span style='color:#111;'> 5.68KB </span>","children":null,"spread":false},{"title":"App.config <span style='color:#111;'> 187B </span>","children":null,"spread":false},{"title":"Properties","children":[{"title":"AssemblyInfo.cs <span style='color:#111;'> 1.33KB </span>","children":null,"spread":false},{"title":"Settings.Designer.cs <span style='color:#111;'> 1.07KB </span>","children":null,"spread":false},{"title":"Resources.resx <span style='color:#111;'> 5.48KB </span>","children":null,"spread":false},{"title":"Settings.settings <span style='color:#111;'> 249B </span>","children":null,"spread":false},{"title":"Resources.Designer.cs <span style='color:#111;'> 2.81KB </span>","children":null,"spread":false}],"spread":true}],"spread":true}],"spread":true},{"title":"词法分析实验报告.doc <span style='color:#111;'> 78.22KB </span>","children":null,"spread":false}],"spread":true}],"spread":true}]

评论信息

免责申明

【只为小站】的资源来自网友分享,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,【只为小站】 无法对用户传输的作品、信息、内容的权属或合法性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论 【只为小站】 经营者是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。
本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二条之规定,若资源存在侵权或相关问题请联系本站客服人员,zhiweidada#qq.com,请把#换成@,本站将给予最大的支持与配合,做到及时反馈和处理。关于更多版权及免责申明参见 版权及免责申明