{"id":13630451,"url":"https://github.com/chai2010/tinylang","last_synced_at":"2025-09-06T08:48:28.002Z","repository":{"id":49828823,"uuid":"220598771","full_name":"chai2010/tinylang","owner":"chai2010","description":"Tiny玩具语言(Go语言实现/包含Tiny编译器/CASL汇编器/COMET虚拟机/调试器/支持WebAssembly/LLVM)","archived":false,"fork":false,"pushed_at":"2024-07-22T13:36:20.000Z","size":1346,"stargazers_count":72,"open_issues_count":1,"forks_count":12,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-08-30T05:45:15.096Z","etag":null,"topics":["go","goyacc","llvm","tinylang","wasm","webassembly","yacc"],"latest_commit_sha":null,"homepage":"","language":"Go","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/chai2010.png","metadata":{"files":{"readme":"README.md","changelog":"changes.md","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":"2019-11-09T05:58:17.000Z","updated_at":"2025-06-27T17:12:42.000Z","dependencies_parsed_at":"2024-06-19T01:27:49.565Z","dependency_job_id":"aa22f33c-5bf4-4039-8cf7-85845bf5ae01","html_url":"https://github.com/chai2010/tinylang","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/chai2010/tinylang","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chai2010%2Ftinylang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chai2010%2Ftinylang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chai2010%2Ftinylang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chai2010%2Ftinylang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chai2010","download_url":"https://codeload.github.com/chai2010/tinylang/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chai2010%2Ftinylang/sbom","scorecard":{"id":272966,"data":{"date":"2025-08-11","repo":{"name":"github.com/chai2010/tinylang","commit":"764be0863f0e8cac02190a9fdb2ca9d1053c3816"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-17T13:49:01.131Z","repository_id":49828823,"created_at":"2025-08-17T13:49:01.131Z","updated_at":"2025-08-17T13:49:01.131Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273879937,"owners_count":25184428,"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-09-06T02:00:13.247Z","response_time":2576,"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":["go","goyacc","llvm","tinylang","wasm","webassembly","yacc"],"created_at":"2024-08-01T22:01:43.542Z","updated_at":"2025-09-06T08:48:27.967Z","avatar_url":"https://github.com/chai2010.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"\n# Tiny玩具语言(Go语言版)\n\n- *凹语言™: https://github.com/wa-lang/wa*\n\n---\n\nTiny语言是[《编译原理及实践》](https://book.douban.com/subject/1088057/)书中定义的玩具语言。\n\n这里是Go语言实现(注释采用Go语言风格)。\n\n实现原理：\n\n- [COMET虚拟计算机说明](./comet/README.md)\n- [COMET虚拟机的设计与实现.pdf](./_docs/comet-vm.pdf)\n\n## 例子\n\n以下的例子计算1到n之和：\n\n```\n// sum = 1 + 2 + ... + n\n\nread n;\nif 0 \u003c n then\n  sum := 0;\n  repeat\n    sum := sum + n;\n    n := n - 1\n  until n = 0;\n  write sum\nend\n```\n\n运行tiny程序:\n\n```\n$ tinylang sum.tiny \n100\n5050\n```\n\n也可以通过`-ast`查看生成的语法树，通过`-casl`查看生成的CASL汇编程序，或通过`-debug`调试执行：\n\n![](./_docs/images/tiny-demo.cast.gif)\n\n## WebAssembly 支持\n\n切换到 `wasm` 目录, 通过以下命令执行 `hello.tiny`:\n\n```\n$ go run main.go hello.tiny\nREAD: 100\n5050\n```\n\n`READ` 表示需要输入一个整数, 这里的 100 表示计算 1 到 100 的和, 结果是 5050.\n\n通过 `-o` 参数输出 WebAssembly 二进制模块:\n\n```\n$ go run main.go -o hello.wasm hello.tiny\n```\n\n实用 `wasm2wat` 将二进制格式转换为文本格式:\n\n```\n$ wasm2wat hello.wasm \u003e hello.wast\n```\n\n输出的 `hello.wast` 内容如下:\n\n```wasm\n(module $tinylang\n  (type (;0;) (func (result i32)))\n  (type (;1;) (func (param i32)))\n  (type (;2;) (func))\n  (import \"env\" \"__tiny_read\" (func (;0;) (type 0)))\n  (import \"env\" \"__tiny_write\" (func (;1;) (type 1)))\n  (func $_start (type 2)\n    call 0\n    set_global 1\n    i32.const 0\n    get_global 1\n    i32.lt_s\n    if  ;; label = @1\n      i32.const 0\n      set_global 2\n      loop  ;; label = @2\n        get_global 2\n        get_global 1\n        i32.add\n        set_global 2\n        get_global 1\n        i32.const 1\n        i32.sub\n        set_global 1\n        get_global 1\n        i32.const 0\n        i32.eq\n        i32.eqz\n        br_if 0 (;@2;)\n      end\n      get_global 2\n      call 1\n    end)\n  (memory (;0;) 1 1)\n  (global (;0;) i32 (i32.const 0))\n  (global (;1;) (mut i32) (i32.const 0))\n  (global (;2;) (mut i32) (i32.const 0))\n  (export \"memory\" (memory 0))\n  (export \"_start\" (func $_start)))\n```\n\n如果要单独执行输出的 WebAssembly 模块, 需要注入 `__tiny_read` 和 `__tiny_write` 函数。\n\n\n## LLVM 支持\n\n假设在 `darwin/amd64` 环境, 切换到 `llvm` 目录, 通过以下命令将 `hello.tiny` 编译为 LLVM-IR 格式:\n\n```\n$ go run main.go hello.tiny \u003e a.out.ll\n```\n\n然后用Clang命令将 LLVM-IR 文件编译为本地课执行程序:\n\n```\n$ clang -Wno-override-module -o a.out.exe a.out.ll\n```\n\n执行输出的 `a.out.exe` 计算 1 到 100 的和, 结果是 5050.\n\n```\n$ ./a.out.exe \nREAD: 100\n5050\n```\n\n## 版权\n\n保留所有权利。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchai2010%2Ftinylang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchai2010%2Ftinylang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchai2010%2Ftinylang/lists"}