{"id":20391896,"url":"https://github.com/seucs/compiler","last_synced_at":"2025-08-18T09:48:26.976Z","repository":{"id":95343346,"uuid":"49542049","full_name":"seucs/compiler","owner":"seucs","description":"SEU CS Compiler Course Design: Python Implementation of LEX \u0026 YACC for Cminus","archived":false,"fork":false,"pushed_at":"2017-12-05T11:37:44.000Z","size":22737,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T11:49:43.314Z","etag":null,"topics":["compiler","dfa","lex","lexical-analysis","nfa","python","syntax-analysis","visualization","yacc"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/seucs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-01-13T01:56:52.000Z","updated_at":"2023-05-16T16:01:37.000Z","dependencies_parsed_at":"2023-07-15T01:32:06.812Z","dependency_job_id":null,"html_url":"https://github.com/seucs/compiler","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/seucs/compiler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seucs%2Fcompiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seucs%2Fcompiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seucs%2Fcompiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seucs%2Fcompiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/seucs","download_url":"https://codeload.github.com/seucs/compiler/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seucs%2Fcompiler/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270975114,"owners_count":24678253,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-18T02:00:08.743Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compiler","dfa","lex","lexical-analysis","nfa","python","syntax-analysis","visualization","yacc"],"created_at":"2024-11-15T03:37:33.182Z","updated_at":"2025-08-18T09:48:26.957Z","avatar_url":"https://github.com/seucs.png","language":"Python","readme":"# Compiler\n东南大学编译原理课程设计——基于python的Lex和Yacc实现\n\n## Contributor (equal contribution)\n\n|Contributor | Contribution|\n|:----:|----|\n|[Zhixin Piao](https://github.com/a367) | lex与yacc的文件读取，状态图的生成，最后代码整合 |\n|[Shengjia Yan](https://github.com/yanshengjia) | RE-\u003eNFA，LR(1)总控程序的实现 |\n|[Ruiming Wang](https://github.com/Rimenwang)|NFA-\u003eDFA，DFA最小化，LR(1) GOTO图、预测分析表的生成|\n\n## Environment\nPython 2.7.10 (64 bit),\nnetworkx 1.10,\npydot 1.0.29,\ngraphviz 2.38\n\n## Feature\n### Lex\n* 全部使用python原创编写\n* 使用了 networks 中 MutiDiGraph可重边可有回路的有向图来表示 NFA，非常清晰直观\n* 最后生成的 NFA、DFA 用 GraphViz 直接画出图形，可以直观方便地观察生成的 结果\n* 没有将 RE 中缀转后缀，通过一个 mg_stack 栈和转换函数的递归调用的配合来完成 RE 到 NFA 的转换 \n* 可以识别 \\( 普通左括号, \\) 普通右括号, \\*普通乘号 \n* 可以识别[a-zA-Z_], 实际上我们是把这种形式的正则表达式预处理了，转化成(a|b|c|….|A|B|C….|_)这种形式再转换\n\n\n### Yacc\n* 通过python动态添加函数的功能将yacc中的语义动作动态的加入类中，从而实现不生成临时代码来执行yacc中的语义动作\n* 语法支持epsilon的存在，比如：int main(int a),int main ()都是合法的。实现的方式为PPT表中会存在epsilon这个终结符。当总控程序发现在PPT表中出现error时，会先选择epsilon，观察是否还是error\n\n## Visualization\nNFA部分可视化结果（[完整版](https://raw.githubusercontent.com/seucs/compiler/master/graph/nfa.jpg)）：\n![](graph/nfa_part.png)\n\nGOTO图部分可视化结果（[完整版](https://raw.githubusercontent.com/seucs/compiler/master/graph/goto.jpg)）：\n![](graph/goto_part.png)\n\nDFA部分可视化结果（[完整版](https://raw.githubusercontent.com/seucs/compiler/master/graph/dfa.jpg)）：\n![](graph/dfa_part.png)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseucs%2Fcompiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseucs%2Fcompiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseucs%2Fcompiler/lists"}