编译原理课程设计:词法分析器

上传者: RLIRiong | 上传时间: 2023-03-05 14:33:24 | 文件大小: 7.3MB | 文件类型: RAR
所使用的开发环境:Windows10、python(PyCharm)环境 注意,main.py里面有一个写函数,如果没有该位置可能会出错,建议注释掉。 课题功能: 创建一个词法分析程序,该程序支持分析常规语法。使用DFA(确定性有限自动机)来实现此程序。 程序有两个输入:1)一个文本文档,包括一组3º语法(正规文法)的产生式;2)一个源代码文本文档,包含一组需要识别的字符串。 程序的输出是一个token(令牌)表,该表由5种token组成:关键词,标识符,常量,限定符和运算符。 项目简介: 词法分析器读入三型文法,将三型文法构建成一个起点和一个终点的NFA,然后将NFA用子集法构造成DFA,创建DFA的索引表,后续读取要扫描的代码,将代码中的每个词依次带入DFA的索引表进行状态转换,如果到达终态说明词符合文法要求,输出token列表(三元组:所在行号,类别,token 内容)如果出错会输出另一种三元组(行号, 对错判定, token内容),并将token列表写入txt文件供任务二LR(1)语法分析器来使用,同时也会将结果输出到result.txt文件来观测。

文件下载

资源详情

[{"title":"( 28 个子文件 7.3MB ) 编译原理课程设计:词法分析器","children":[{"title":"Lexical analyzer","children":[{"title":"expression","children":[{"title":"ex1.txt <span style='color:#111;'> 1.57KB </span>","children":null,"spread":false},{"title":"ex_test.txt <span style='color:#111;'> 43B </span>","children":null,"spread":false}],"spread":true},{"title":"main.py <span style='color:#111;'> 2.25KB </span>","children":null,"spread":false},{"title":"to_dfa.py <span style='color:#111;'> 2.10KB </span>","children":null,"spread":false},{"title":"__pycache__","children":[{"title":"to_dfa.cpython-310.pyc <span style='color:#111;'> 1.24KB </span>","children":null,"spread":false},{"title":"to_nfa.cpython-310.pyc <span style='color:#111;'> 2.43KB </span>","children":null,"spread":false},{"title":"read.cpython-310.pyc <span style='color:#111;'> 3.20KB </span>","children":null,"spread":false},{"title":"to_regularExpression.cpython-310.pyc <span style='color:#111;'> 160B </span>","children":null,"spread":false}],"spread":true},{"title":"result.txt <span style='color:#111;'> 515B </span>","children":null,"spread":false},{"title":"read.py <span style='color:#111;'> 4.15KB </span>","children":null,"spread":false},{"title":"main.exe <span style='color:#111;'> 7.47MB </span>","children":null,"spread":false},{"title":"state_changes.txt <span style='color:#111;'> 1.39KB </span>","children":null,"spread":false},{"title":".idea","children":[{"title":"Lexical analyzer.iml <span style='color:#111;'> 291B </span>","children":null,"spread":false},{"title":"misc.xml <span style='color:#111;'> 208B </span>","children":null,"spread":false},{"title":"modules.xml <span style='color:#111;'> 291B </span>","children":null,"spread":false},{"title":"sonarlint","children":[{"title":"issuestore","children":[{"title":"8","children":[{"title":"5","children":[{"title":"85fa96350dc65779022e6c2da7f2243ead074fb9 <span style='color:#111;'> 78B </span>","children":null,"spread":false}],"spread":false},{"title":"e","children":[{"title":"8ecbbfe65d0f37809cc3c58983cc84bd63ddf58a <span style='color:#111;'> 115B </span>","children":null,"spread":false}],"spread":false}],"spread":false},{"title":"index.pb <span style='color:#111;'> 232B </span>","children":null,"spread":false},{"title":"f","children":[{"title":"1","children":[{"title":"f1bdda93d9a278e358509d498e17d97764c1fb29 <span style='color:#111;'> 0B </span>","children":null,"spread":false}],"spread":false}],"spread":false},{"title":"3","children":[{"title":"e","children":[{"title":"3eeb74d2b070a6b9469281ad495e4ce9d8e54482 <span style='color:#111;'> 258B </span>","children":null,"spread":false}],"spread":false}],"spread":false}],"spread":false}],"spread":true},{"title":"workspace.xml <span style='color:#111;'> 2.65KB </span>","children":null,"spread":false},{"title":".gitignore <span style='color:#111;'> 50B </span>","children":null,"spread":false},{"title":"inspectionProfiles","children":[{"title":"Project_Default.xml <span style='color:#111;'> 410B </span>","children":null,"spread":false},{"title":"profiles_settings.xml <span style='color:#111;'> 174B </span>","children":null,"spread":false}],"spread":false}],"spread":true},{"title":"to_nfa.py <span style='color:#111;'> 3.36KB </span>","children":null,"spread":false},{"title":"code","children":[{"title":"code1.txt <span style='color:#111;'> 149B </span>","children":null,"spread":false},{"title":"code_test.txt <span style='color:#111;'> 92B </span>","children":null,"spread":false}],"spread":true},{"title":"main.spec <span style='color:#111;'> 852B </span>","children":null,"spread":false}],"spread":false}],"spread":true}]

评论信息

免责申明

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