{"id":18877900,"url":"https://github.com/ladingwu/compiler_java_python","last_synced_at":"2025-07-27T15:42:07.316Z","repository":{"id":95578313,"uuid":"42664310","full_name":"ladingwu/compiler_java_python","owner":"ladingwu","description":"简易编译器实现，最终翻译成伪汇编代码","archived":false,"fork":false,"pushed_at":"2021-11-21T10:29:24.000Z","size":190,"stargazers_count":33,"open_issues_count":0,"forks_count":22,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-14T18:57:01.981Z","etag":null,"topics":["compiler","java"],"latest_commit_sha":null,"homepage":"","language":"Java","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/ladingwu.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}},"created_at":"2015-09-17T15:25:39.000Z","updated_at":"2023-12-15T22:10:52.000Z","dependencies_parsed_at":"2023-05-20T22:30:26.051Z","dependency_job_id":null,"html_url":"https://github.com/ladingwu/compiler_java_python","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ladingwu/compiler_java_python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ladingwu%2Fcompiler_java_python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ladingwu%2Fcompiler_java_python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ladingwu%2Fcompiler_java_python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ladingwu%2Fcompiler_java_python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ladingwu","download_url":"https://codeload.github.com/ladingwu/compiler_java_python/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ladingwu%2Fcompiler_java_python/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267379104,"owners_count":24077863,"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-07-27T02:00:11.917Z","response_time":82,"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","java"],"created_at":"2024-11-08T06:22:40.027Z","updated_at":"2025-07-27T15:42:07.250Z","avatar_url":"https://github.com/ladingwu.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# compiler_java_python\n简易编译器实现，最终翻译成伪汇编代码\n\n项目太老，原先在eclipse上实现的，现在已经迁移到AndroidStudio，把分支切换到dev_android打开即可\n\n## 编译器主要编译t语言（暂且这么称呼）\n\n\n## t语言关键字：\n- func  用于定义函数\n- main  主函数名，文件中必须包含主函数\n- while  循环关键字\n- if 条件分支 关键字\n- else 必须与if 一起才能识别\n- num 数字类型\n- string 字符串类型\n- bool 布尔值类型\n\n## t语言的比较符号：\n- \u003e\n- \u003c\n- \u003e=\n- \u003c=\n- ==\n\n示例：\n\n\n    func  main(){\n    \n    num a,b;\n    \n    a=1;\n    \n    b=0;\n    \n    while(b\u003c5){\n\t    \n\t    num c,k;\n\t    \n\t    b=b+1;\n\t    \n\t    if(b\u003c3){\n\t\t    \n\t\t    c=b+b*a;\n\t    \n\t    }else{\n\t\t  \n\t\t    c=b;\n\t    \n\t    }\n    }\n    \n    num d,c;\n    \n    c=1;\n    \n    a=b\\*a\\*c+b*4;\n\n  }\n\n输出伪汇编代码（三地址码的四元式）格式为：\u003c操作符，操作数1，操作数2，结果存放\u003e\n以上示例的输出结果：\n- DEFINE , num , null , a\n- DEFINE , num , null , b\n- SEND , 1 , null , a\n- SEND , 0 , null , b\n- LABEL , null , null , Label1\n- CJMP_L , b , 5 , Label2\n- DEFINE , num , null , c\n- DEFINE , num , null , k\n- ADD , b , 1 , $\n- SEND , $ , null , b\n- CJMP_L , b , 3 , Label3\n- MUL , b , a , $\n- ADD , b , $ , $\n- SEND , $ , null , c\n- LABEL , null , null , Label3\n- SEND , b , null , c\n- JMP , null , null , Label1\n- LABEL , null , null , Label2\n- DEFINE , num , null , d\n- DEFINE , num , null , c\n- SEND , 1 , null , c\n- MUL , b , a , $\n- MUL , $ , c , $\n- MUL , b , 4 , $\n- ADD , $ , $ , $\n- SEND , $ , null , a\n\n\n\n\n##个别操作符的含义：\n- DEFINE: 定义变量\n- SEND : 赋值\n- JMP: 无条件跳转\n- CJMP_E: 等于时执行下面的语句，否则跳转到某个label\n- CJMP_B : 大于时........\n- CJMP_B_E : 大于等于的时候...... \n- LABEL: 定义一个标签（用于跳转）\n- $ : 用于存放左边操作数运算的结果，或者代表上面的运算结果，主要作用是把被分解的表达式连接起来\n- null 表示该操作数不进行操作，仅仅起占位的作用\n\n\n\n## 补充说明：\n- 为了简化编译工作\n    - t语言只支持一个mian(),函数，所以不分析函数之间的跳转\n    - t语言只支持变量之间的加减乘除，自动识别运算优先级，不允许使用（）\n    - t语言以只支持while这一种循环，而且不支持break跳出循环。\n\n由于第一次编写编译器，所以很多工作可能不是很好，但是对于理解编译原理，还是有很大帮助的，有意向的同学欢迎交流....\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fladingwu%2Fcompiler_java_python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fladingwu%2Fcompiler_java_python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fladingwu%2Fcompiler_java_python/lists"}