{"id":21561879,"url":"https://github.com/easonzero/compiler","last_synced_at":"2025-04-10T12:06:41.701Z","repository":{"id":112072331,"uuid":"71619054","full_name":"Easonzero/Compiler","owner":"Easonzero","description":"哈工大编译原理实验，使用node语言，实现了基于状态转换机制的词法分析器,以及自顶而下分析的语法分析器，gui基于electron\u0026angular制作，数据可视化使用的是d3.js。","archived":false,"fork":false,"pushed_at":"2019-04-07T07:46:31.000Z","size":517,"stargazers_count":64,"open_issues_count":0,"forks_count":11,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-24T10:56:27.137Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/Easonzero.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}},"created_at":"2016-10-22T05:33:54.000Z","updated_at":"2024-10-09T09:29:54.000Z","dependencies_parsed_at":"2023-04-10T08:18:58.154Z","dependency_job_id":null,"html_url":"https://github.com/Easonzero/Compiler","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Easonzero%2FCompiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Easonzero%2FCompiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Easonzero%2FCompiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Easonzero%2FCompiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Easonzero","download_url":"https://codeload.github.com/Easonzero/Compiler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248217076,"owners_count":21066633,"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","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":[],"created_at":"2024-11-24T09:29:05.247Z","updated_at":"2025-04-10T12:06:41.682Z","avatar_url":"https://github.com/Easonzero.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Compiler\n\n[![Badge](https://img.shields.io/badge/link-996.icu-red.svg)](https://996.icu/#/zh_CN)\n\n哈工大编译原理实验，使用node语言，实现了基于状态转换机制的词法分析器,以及自顶而下分析的语法分析器，gui基于electron\u0026angular制作，数据可视化使用的是d3.js。\n\n# 还有什么好说的！  \n# 学弟学妹们快上车，随便拿去用！\n\n还是多说几句吧^_^核心代码在compiler文件夹中，已经做了解耦，可以单独拿出来用。gui的渲染则在view文件夹中。代码量很少，读起来应该比较轻松，就不做说明了，想要对核心代码或者界面进行修改，只需要动这两部分的代码即可。\n\n##运行\n\n运行需要自行搭建node环境和npm，全局安装好electron。下面展示linux下如何使用：\n\n\u003esudo apt-get install nodejs(node其实不建议这么安装，建议到官网下载)  \nsudo apt-get install npm  \nsudo npm install electron -g\n\n如上环境就算都弄好了，现在展示如何运行项目：\n\n\u003eelectron .\n\n\n![结果](./image/result.png)\n\n这样一个Material Design风格的桌面应用就运行起来了\n\n##特性\n\n* 支持测试用例文件直接拖入应用执行\n* 全Material Design的界面设计风格\n![Material结果](./image/table_result.png)\n* 支持语法分析器的结果采用树状图可视化输出,树状图支持放缩和移动\n![树状图结果](./image/tree_result.png)\n* 状态表和文法表与程序流程完全解耦，可以简便的扩展词法分析器和语法分析器\n* 支持前端路由\n![路由结果](./image/menu_result.png)\n* 支持界面跟随窗口内容自适应\n* 语法分析器支持三种具体情况的错误判断，并提供错误行信息。\n\n##需要注意的问题\n\n1.对于状态转换机制应该算是基本功了，主要需要注意的是状态转换时的终止判定：  \n* 我使用的方式是判断输入和当前状态的二元对在不在状态转换表内，如果不在且当前状态是终止状态，则认为是终止状态，可以重置状态机。\n* 另外一种方式是使用界符，但是这种方式需要单独维护界符的数据结构，增加了判定终止状态的复杂度。\n\n2.关于查错也有两种方式：  \n* 简单的方法是不在状态转换机就是出错，这种方法非常简单，但是不能够得到具体的报错信息，同时如果采用这种方式，判定终止条件的方式则需要使用界符。\n* 另外一种方法则是将报错维护在状态转换机中，这样可以获得具体的报错信息，但是状态转换图的复杂度当然也相应增加。\n\n3.关于状态转换图：  \n* 本项目的状态转换基于一个自己攒出来的状态转换表，大概囊括了40个左右的终止状态，反正实验内容要求的那些应该没有问题。  \n* 状态转换表的结构分为5个字段，分别是S(状态集合)，I（输入集合），T（转换表），SS（起始状态），FS(终止状态集合)。  \nT的格式则是{S:{I:S...}...}这种json格式，整体的字段格式也是json，解析起来还是非常容易的。  \n* 值得注意的是这个转换表其实有些繁琐了，主要是按照老师的ppt定的状态转换机的这5个输入，写完之后反思觉得其实没必要这么麻烦，S和I都是不必要的。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feasonzero%2Fcompiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feasonzero%2Fcompiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feasonzero%2Fcompiler/lists"}