{"id":16596524,"url":"https://github.com/austaras/acompiler","last_synced_at":"2025-08-26T14:12:56.755Z","repository":{"id":253191736,"uuid":"616346455","full_name":"Austaras/ACompiler","owner":"Austaras","description":"Compiler for ADF lang","archived":false,"fork":false,"pushed_at":"2025-02-21T08:24:01.000Z","size":643,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-06T19:35:22.605Z","etag":null,"topics":["compiler","programming-language"],"latest_commit_sha":null,"homepage":"","language":"F#","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/Austaras.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":"2023-03-20T07:56:14.000Z","updated_at":"2025-02-21T08:24:05.000Z","dependencies_parsed_at":"2024-09-13T18:52:25.264Z","dependency_job_id":"fc300c79-bedc-412e-a99f-29fd533846c6","html_url":"https://github.com/Austaras/ACompiler","commit_stats":null,"previous_names":["austaras/acompiler"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Austaras/ACompiler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Austaras%2FACompiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Austaras%2FACompiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Austaras%2FACompiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Austaras%2FACompiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Austaras","download_url":"https://codeload.github.com/Austaras/ACompiler/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Austaras%2FACompiler/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272228037,"owners_count":24895728,"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-08-26T02:00:07.904Z","response_time":60,"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":["compiler","programming-language"],"created_at":"2024-10-11T23:53:31.665Z","updated_at":"2025-08-26T14:12:56.709Z","avatar_url":"https://github.com/Austaras.png","language":"F#","funding_links":[],"categories":[],"sub_categories":[],"readme":"Test out various compiler technology with a toy compiler for a toy language **in between** rust and OCaml.\n\n### Reference Material\n\n#### Book\n\n- _Modern Compiler Implementation in ML_\n- _Engineering a Compiler_\n- _Programming Language Concepts_\n- _Compilers: Principles, Techniques, and Tools_\n\n#### Paper\n\n- _Typing Haskell in Haskell_\n- _Type classes: an exploration of the design space_\n- _Type Classes with Functional Dependencies_\n\n### Design Decisions\n\n1. ML syntax with Rust characteristics\n   - That means, {} for block, =\u003e for pattern match, fn for function, () for function call, = for assign, == for equal, != for not equal, |a, b| a + b for closure\n   - not whitespace sensitive, but without mandatory semicolons; if there's ambiguity, **prefer line break**\n   - break/continue/return/struct/enum keyword\n2. ML semantic with Rust characteristics\n   - HM type inference with trait and operator overloading\n   - c style function declaration that are hoisted and cannot capture environment\n   - internal mutable\n   - impl block and trait, but impl trait has name and user need to import them like in Scala\n   - string is UTF8 and char is UTF32\n3. Pratically functional\n   - provide immutable std lib and tail call optimization\n   - but also mutable std lib and control keyword\n4. Focus on performance and optimization\n   - no auto boxing, provide general reference type(s) tracked by GC\n   - no object header, no object identity\n   - rust doesn't assume anything, ADF assumes memory allocation tracked by GC\n   - user can roll their own container like in Rust\n5. suffix is .adf which stands for **A**dvanced **D**ominance **F**unctional language\n\n### Major TODO\n\n#### Design decisions\n\n- [ ] effect system, immtuable, pure, lazy\n- [ ] region\n- [ ] const generic\n- [ ] refinement type\n- [ ] ABI\n- [ ] GC\n- [ ] macro\n- [ ] Fn trait\n\n#### Implementation\n\n- [ ] cross module type check\n- [x] type class\n  - [x] multi parameter type class\n  - [x] functional dependency\n  - [ ] number type class\n  - [ ] field selection\n  - [ ] existential type\n  - [ ] TRIE based resolution\n  - [ ] name instance\n  - [ ] lower\n- [ ] pattern match\n  - [ ] coverage\n  - [ ] lower\n- [ ] fixed size array\n- [x] IR lower\n  - [ ] function call\n  - [ ] generic\n- [x] SSA\n- [ ] optimization\n  - [x] LVN\n  - [x] DCE\n  - [x] SCCP\n  - [x] Aggressive DCE\n  - [ ] LICM\n  - [ ] SCEV\n\n### Code Architecture\n\n1. plain ADT for AST\n\n   [AST](./src/Syntax/Library.fs)\n\n2. hand written recursive descendant parser\n\n   [Parser](./src/Syntax/Parser.fs)\n\n3. HM type inference with trait\n\n   [Semantic](./src/Semantic)\n\n4. FLIR, which stands for First Linear Intermediate Representation\n\n   [FLIR](./src/Optimize/Library.fs)\n\n   - three address code, basic block, SSA\n   - eliminates ADT, operator overloading, assign operator and pattern\n   - lambda lifting\n   - monotyped\n\n### Syntax Construct\n\n```hs\nModule :: [ModuleItem]\nModuleItem :: \u003cVisbility\u003e Declaration\nVisibility :: pub | intl\nDeclaration :: Function | Let | Const | Struct | Enum | TypeAlias | Use\nFunction :: fn IDENTIFIER ( [Argument, ] ) \u003c -\u003e Type \u003e Block\nStatement :: Declaration | Expression\nLet :: let Pattern \u003c : Type \u003e = Expression\nConst :: const IDENTIFIER \u003c : Type \u003e = Expression\nStruct :: struct IDENTIFIER { [ IDENTIFIER: Type ] }\nEnum :: enum IDENTIFIER { [ IDENTIFIER \u003c ( [Type, ] ) \u003e ] }\nTypeAlias :: type IDENTIFIER = Type\nExpression :: If | Match | Call | Binary | Unary | Field | Index | Assign\n            | Closure | StructInit | Tuple | Array | Block\n            | Range | For | While | Continue | Break | Return\n            | Identifier | Literal | Path | Self\nBlock :: { [Statement (; | NewLine ) ] }\nIf :: if IfCond Block [else if Condition Block] \u003celse Block\u003e\nCondition :: Expression | let Pattern = Expression\nMatch :: match { [ Pattern \u003cif Expression\u003e =\u003e Expression, ] }\nCall :: Expression ( [Expression, ] )\nBinary :: Expression BinaryOp Expression\nUnary :: UNARY Expression\nField :: Expression . IDENTIFIER\nIndex :: Expression [ Expression ]\nAssign :: LValue ASSIGN Expression\nClosure :: \u003c \u003c[ TypeParam, ]\u003e \u003e | [ Argument, ] | \u003c -\u003e Type \u003e Expression\nStructInit :: IDENTIFIER { [ IDENTIFIER: Expression, ] \u003c ...Expression \u003e }\nTuple :: ( [ Expression, ] )\nArray :: [ [ Expression, ] ] | [ Expression; Expression ]\nRange :: \u003cExpression\u003e..\u003cExpression\u003e\nFor :: for \u003cPattner\u003e in \u003cExpression\u003e Block\nWhile :: While Condition Block\nContinue :: continue\nBreak :: break\nReturn :: return \u003c Expression \u003e\nIdentifier :: IDENTIFIER\nLiteral :: IntLiteral | FloatLiteral | BoolLiteral | StringLiteral | CharLiteral\nSelf :: self\n\nIDENTIFIER :: \\uXID_Start[\\uXID_Continue]\nASSIGN :: += -= *= /= \u0026= |= ^= \u003c\u003c= \u003e\u003e=\nBINARY :: + - * / \u0026 | ^ \u0026\u0026 || \u003c\u003c \u003e\u003e == \u003e= \u003c= != \u003c \u003e |\u003e as\nUnary :: - * \u0026\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faustaras%2Facompiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faustaras%2Facompiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faustaras%2Facompiler/lists"}