{"id":43459936,"url":"https://github.com/wokron/tolangc","last_synced_at":"2026-02-03T05:27:17.893Z","repository":{"id":236180950,"uuid":"792086938","full_name":"wokron/tolangc","owner":"wokron","description":"Example compiler and tutorials of \"Compiler Technology\" course at Beihang University","archived":false,"fork":false,"pushed_at":"2024-12-13T16:00:34.000Z","size":3436,"stargazers_count":38,"open_issues_count":0,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-11-05T08:29:54.717Z","etag":null,"topics":["beihang-university","buaa","buaa-compiler","compiler","example-project","llvm-ir","mips","pcode","tutorial"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wokron.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","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":"2024-04-26T00:27:45.000Z","updated_at":"2025-10-25T14:05:36.000Z","dependencies_parsed_at":"2024-06-29T10:35:14.508Z","dependency_job_id":"1c5b331d-1ae8-48c2-a542-f03da0c4d4f7","html_url":"https://github.com/wokron/tolangc","commit_stats":null,"previous_names":["wokron/tolangc"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/wokron/tolangc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wokron%2Ftolangc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wokron%2Ftolangc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wokron%2Ftolangc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wokron%2Ftolangc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wokron","download_url":"https://codeload.github.com/wokron/tolangc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wokron%2Ftolangc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29034080,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-03T02:28:16.591Z","status":"ssl_error","status_checked_at":"2026-02-03T02:27:48.904Z","response_time":96,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["beihang-university","buaa","buaa-compiler","compiler","example-project","llvm-ir","mips","pcode","tutorial"],"created_at":"2026-02-03T05:27:15.181Z","updated_at":"2026-02-03T05:27:17.888Z","avatar_url":"https://github.com/wokron.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tolangc: tolang compiler\n\ntolang 指 “toy lang”，是一款用于教学目的的简单编程语言。tolangc 即 tolang compiler，是 tolang 语言的样例编译器，可以为编译技术的学习者提供对编译器架构的初步认识。\n\n\u003e 本编译器为北京航空航天大学本科三年级《编译技术》课程实验教程的配套示例，实验教程同样位于本仓库中。\n\n## tolangc 介绍\n\n- 使用 C++ 编写\n- 以 LLVM / Pcode 作为中间代码形式\n- 支持输出 MIPS 汇编码 / Pcode 解释执行\n\n## 文法定义\ntolang 语言（v1）的文法由下面的 EBNF 范式确定：\n\n```text\nCompUnit: {FuncDef} {VarDecl} {Stmt}\n\nFuncDef: 'fn' Ident '(' [FuncFParams] ')' '=\u003e' Exp ';'\n\nFuncFParams: Ident { ',' Ident }\n\nVarDecl: 'var' Ident ';'\n\nStmt:\n    'get' Ident ';'\n    | 'put' Exp ';'\n    | 'tag' Ident ';'\n    | 'let' Ident '=' Exp ';'\n    | 'if' Cond 'to' Ident ';'\n    | 'to' Ident ';'\n\nExp: AddExp\n\nAddExp:\n    MulExp\n    | AddExp ('+' | '-') MulExp\n\nMulExp:\n    UnaryExp\n    | MulExp ('*' | '/') UnaryExp\n\nUnaryExp:\n    PrimaryExp\n    | Ident '(' [FuncRParams] ')'\n    | ('+' | '-') UnaryExp\n\nPrimaryExp:\n    '(' Exp ')'\n    | Ident\n    | Number\n\nFuncRParams: Exp { ',' Exp }\n\nCond:\n    Exp ('\u003c' | '\u003e' | '\u003c=' | '\u003e=' | '==' | '!=') Exp\n```\n\n其中\n\n```text\nIdent: [a-zA-Z_][0-9a-zA-Z_]*\nNumber: (0|[1-9][0-9]*)(\\.[0-9]+)?\n```\n\n## 项目维护\n\n见 [CONTRIBUTING.md](CONTRIBUTING.md)。\n\n## 编译构建\n\n- 经过测试的编译环境：ubuntu-22.04、macos-14。\n- 前置条件：已安装 cmake、make、clang。\n- 构建方式：运行 `./script/build.sh` 脚本，并指定对应后端，如  `bash ./script/build.sh llvm`。\n\n## Todo\n- [x] 编译器前端\n  - [x] 词法分析\n  - [x] 语法树数据结构\n  - [x] 语法分析\n  - [x] 符号表\n  - [x] 中间代码数据结构\n  - [x] 中间代码构建接口\n  - [x] 语义分析\n  - [x] 中间代码输出\n\n- [x] 编译器后端\n    - [x] 寄存器分配\n    - [x] 目标代码生成\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwokron%2Ftolangc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwokron%2Ftolangc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwokron%2Ftolangc/lists"}