{"id":13667750,"url":"https://github.com/zuisong/chen_lang","last_synced_at":"2025-07-10T15:31:10.365Z","repository":{"id":38314948,"uuid":"193363621","full_name":"zuisong/chen_lang","owner":"zuisong","description":"A super tiny and toy language write by rust","archived":false,"fork":false,"pushed_at":"2024-06-03T04:39:51.000Z","size":294,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-11T03:33:26.657Z","etag":null,"topics":["compiler","interpreters","language","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/zuisong.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":"2019-06-23T15:19:20.000Z","updated_at":"2024-03-13T17:09:16.000Z","dependencies_parsed_at":"2024-08-02T07:01:56.803Z","dependency_job_id":"b58dd613-23d8-405f-8c96-e65ebf714cfe","html_url":"https://github.com/zuisong/chen_lang","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zuisong%2Fchen_lang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zuisong%2Fchen_lang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zuisong%2Fchen_lang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zuisong%2Fchen_lang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zuisong","download_url":"https://codeload.github.com/zuisong/chen_lang/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225643376,"owners_count":17501376,"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":["compiler","interpreters","language","rust"],"created_at":"2024-08-02T07:00:48.867Z","updated_at":"2024-11-20T23:18:29.496Z","avatar_url":"https://github.com/zuisong.png","language":"Rust","readme":"\n# chen_lang\n\n## A tiny programming language written in [Rust](https://www.rust-lang.org)\n\n[🇨🇳 中文版](./readme_cn.md)\n\n---\n\n### Sample Code\n\n```\n# This is a comment \n# Comments start with #, and go to the end of the line\n# The expressions in if and for evaluate to bool\nlet i=1\nfor i\u003c=9 {\n    let j = 1\n    for j\u003c=i {\n        print(j + \"x\" + i + \"=\" + i*j + \" \")\n        j = j + 1\n    }\n    println(\"\")\n    i=i+1\n}\n```\n\nOutput:\n\n```\n1x1=1  \n1x2=2 2x2=4\n1x3=3 2x3=6 3x3=9\n1x4=4 2x4=8 3x4=12 4x4=16\n1x5=5 2x5=10 3x5=15 4x5=20 5x5=25\n1x6=6 2x6=12 3x6=18 4x6=24 5x6=30 6x6=36\n1x7=7 2x7=14 3x7=21 4x7=28 5x7=35 6x7=42 7x7=49\n1x8=8 2x8=16 3x8=24 4x8=32 5x8=40 6x8=48 7x8=56 8x8=64  \n1x9=9 2x9=18 3x9=27 4x9=36 5x9=45 6x9=54 7x9=63 8x9=72 9x9=81\n```\n\n---\n\n```\nlet i = 100\nlet sum = 0 \nfor i!=0 {\n    i = i - 1\n    # Here is relatively complex logical operation\n    if (i%2!=0) || (i%3==0) {\n        # println(i)\n        # Uncomment the line above\n        # Print out all odd numbers or even numbers divisible by 3\n        sum = sum + i\n    }\n}\nprintln(\"The sum of odd numbers or even numbers divisible by 3 below 100 is\")  \nprintln(sum)\n```\n\nOutput:\n\n```\nThe sum of odd numbers or even numbers divisible by 3 below 100 is\n3316\n```\n\n---\n\n```\n# Use chen_lang to print the first 30 Fibonacci numbers \nlet n = 1\nlet i = 1\nlet j = 2\nprintln(\"Print the first 10 Fibonacci numbers\")\nfor n \u003c= 30 {\n   println(i)\n   let tmp = i\n   i = j\n   j = tmp + j\n   n = n + 1 \n}\n```\n\nOutput:\n\n```\nPrint the first 10 Fibonacci numbers\n1\n2\n3  \n5\n8\n13\n21\n34\n55\n89\n```\n\n---\n\n### TODO\n\n* [x] if condition statements\n* [x] else statements\n* [x] for loops\n* [ ] Support break and continue keywords\n* [x] bool type\n* [x] int type\n* [x] Arithmetic operators + - * / %\n* [x] Comparison operators \u003e \u003e= \u003c \u003c= == !=\n* [x] Logical operators \u0026\u0026 || !\n* [x] Operator precedence\n* [x] Operator precedence can be changed dynamically with parentheses\n* [ ] Custom methods\n* [ ] More code comments\n* [ ] Write blog to document this project\n* [ ] More comprehensive unit tests\n* [ ] Object oriented features\n\n---\nAfterword: I finally implemented a program I've always wanted to write, thanks to the compiler principles course at Harbin Institute of Technology.\n","funding_links":[],"categories":["库"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzuisong%2Fchen_lang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzuisong%2Fchen_lang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzuisong%2Fchen_lang/lists"}