{"id":21121640,"url":"https://github.com/y-nak/tiger-cranelift","last_synced_at":"2025-07-13T16:03:18.993Z","repository":{"id":62105070,"uuid":"235911187","full_name":"Y-Nak/tiger-cranelift","owner":"Y-Nak","description":"Tiger language implementation using cranelift","archived":false,"fork":false,"pushed_at":"2020-03-24T13:22:23.000Z","size":87,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-08T17:03:48.670Z","etag":null,"topics":["compiler","cranelift","rust","tiger"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/Y-Nak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-24T00:07:41.000Z","updated_at":"2025-04-11T17:37:24.000Z","dependencies_parsed_at":"2022-10-26T13:00:26.489Z","dependency_job_id":null,"html_url":"https://github.com/Y-Nak/tiger-cranelift","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Y-Nak/tiger-cranelift","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Y-Nak%2Ftiger-cranelift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Y-Nak%2Ftiger-cranelift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Y-Nak%2Ftiger-cranelift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Y-Nak%2Ftiger-cranelift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Y-Nak","download_url":"https://codeload.github.com/Y-Nak/tiger-cranelift/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Y-Nak%2Ftiger-cranelift/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264352915,"owners_count":23594994,"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","cranelift","rust","tiger"],"created_at":"2024-11-20T03:54:03.888Z","updated_at":"2025-07-08T21:32:51.055Z","avatar_url":"https://github.com/Y-Nak.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tiger-Cranelift\n\nTiger-Cranelift is a Tiger language implementation using [cranelift](https://github.com/bytecodealliance/cranelift). This project is intended to be yet another demo of cranelift.  \nThe compiler emits native binaries using cranelift-object backend.  \nYou can also find official cranelift-jit example [simplejit-demo](https://github.com/bytecodealliance/simplejit-demo).  \n\n## Specification\nSee [Tiger Compiler Reference Manual](https://www.lrde.epita.fr/~tiger/tiger.html).  \nSome features in the specification are still missing.  \nI'll implement them in my free time.\n\n## Implementation Summary\n\n### Parsing\nSimple hand-written recursive descent parser. So there is nothing to saying about parsing phase.\n\n### Semantic Analysis\nTiger language allows to define nested functions though closure is not allowed.  \nIn order to resolve nested functions, I adopted lambda-lifting because it make easier to build Cranelift IR in later.\n\n### IR Building\nAll types in Tiger are lowered into ptr type of target machine to allow recursive type declaration like `type IntList = {head:int, tail: list}`.  \nIn semantic analysis phase all functions are lifted up to top-level functions, so IR building phase is quite straight forward.  \n\n## Run\nIn the project root,\n```\nCargo run file_path\n```\n\n### Compiler Options\n```\nUSAGE:\n    tigerc [FLAGS] [OPTIONS] \u003cfile\u003e\n\nFLAGS:\n    -d               Also dump cranelift IR\n    -h, --help       Prints help information\n    -V, --version    Prints version information\n\nOPTIONS:\n    -O, --opt-level \u003clevel\u003e    Specify optimization level [default: none]  [possible values: none, speed,\n                               speed_and_size]\n    -o \u003cpath\u003e                  Place the output into \u003cfile\u003e [default: ./a.out]\n\nARGS:\n    \u003cfile\u003e \n```\n\n## Test\nIn the project root,\n```\n./test_all.sh\n```\n\nThis command runs all unit tests + file tests.\n\n## TODO\n* [ ] Add error handling returned from cranelift.\n* [ ] Add simple GC.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fy-nak%2Ftiger-cranelift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fy-nak%2Ftiger-cranelift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fy-nak%2Ftiger-cranelift/lists"}