{"id":21048015,"url":"https://github.com/yc/goat","last_synced_at":"2025-03-13T22:41:42.425Z","repository":{"id":63393986,"uuid":"324139245","full_name":"YC/goat","owner":"YC","description":"Goat Compiler for COMP90045 2019 (Targetting LLVM IR)","archived":false,"fork":false,"pushed_at":"2023-12-15T21:53:59.000Z","size":908,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-20T18:11:33.497Z","etag":null,"topics":[],"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/YC.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-24T11:21:31.000Z","updated_at":"2022-11-17T09:57:05.000Z","dependencies_parsed_at":"2023-12-15T22:49:36.804Z","dependency_job_id":null,"html_url":"https://github.com/YC/goat","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YC%2Fgoat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YC%2Fgoat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YC%2Fgoat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YC%2Fgoat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/YC","download_url":"https://codeload.github.com/YC/goat/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243495489,"owners_count":20299921,"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":[],"created_at":"2024-11-19T14:41:36.473Z","updated_at":"2025-03-13T22:41:42.397Z","avatar_url":"https://github.com/YC.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Goat\nA compiler for Goat, a procedual language from the assignments of\nCOMP90045 - Programming Language Implementation,\n[Semester 1 2019](https://handbook.unimelb.edu.au/2019/subjects/comp90045/print).\n\nThis is my implementation in Rust, to relearn some compiler concepts.\n\n## Implementation\n- [x] Lexer\n  - [x] Regular Expression to NFA\n  - [x] NFA to DFA (via subset construction)\n- [x] Parser\n  - [x] Recursive Descent\n- [x] Semantic Analysis\n- [x] Code generation\n  - [x] LLVM IR\n  - [ ] Oz\n\n## Usage\nInstall `clang` (optional, to compile executable).\n\nCompile the compiler:\n```sh\n$ cargo build --release\n```\n\nExecute:\n```\n$ ./goat [-p] source.gt -o \u003cexecutable-name\u003e\n```\n- If `-p` is specified, pretty printing of the source will be performed per stage 1 specification.\n- If `-v` is specified, information determined by the lexer/parser/codegen will be printed.\n- If `-o \u003cexecutable-name\u003e`, `goat` will use `clang` to compile `\u003csource\u003e.gt` into `\u003cexecutable-name\u003e`.\n\nNote that this implementation currently does not support compilation to Oz,\nthe target language from stage 3 of the specification.\n\n## Tests\n1. Build the compiler.\n2. Run the test script.\n```sh\n$ ./tests/test.sh target/release/goat\n```\n\n## Performance\nNFA vs DFA for Lexer\n```\nBenchmark 1: ./test.sh ../target/release/goat-dfa\n  Time (mean ± σ):      4.698 s ±  0.030 s    [User: 2.368 s, System: 2.401 s]\n  Range (min … max):    4.657 s …  4.753 s    10 runs\n\nBenchmark 2: ./test.sh ../target/release/goat-nfa\n  Time (mean ± σ):      5.538 s ±  0.111 s    [User: 3.147 s, System: 2.437 s]\n  Range (min … max):    5.414 s …  5.775 s    10 runs\n\nSummary\n  './test.sh ../target/release/goat-dfa' ran\n    1.18 ± 0.02 times faster than './test.sh ../target/release/goat-nfa'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyc%2Fgoat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyc%2Fgoat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyc%2Fgoat/lists"}