{"id":16562860,"url":"https://github.com/sword-smith/hfasto","last_synced_at":"2026-05-10T18:02:51.909Z","repository":{"id":136419578,"uuid":"58306416","full_name":"Sword-Smith/hfasto","owner":"Sword-Smith","description":"Implementing a compiler for the fuctional programming language fasto in Haskell","archived":false,"fork":false,"pushed_at":"2016-05-24T19:45:18.000Z","size":42,"stargazers_count":1,"open_issues_count":2,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-15T17:11:33.406Z","etag":null,"topics":["calling-conventions","compiler","functional-programming","mips-assembly","register-allocation"],"latest_commit_sha":null,"homepage":"","language":"Haskell","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/Sword-Smith.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2016-05-08T10:08:58.000Z","updated_at":"2023-01-19T20:56:38.000Z","dependencies_parsed_at":"2023-07-06T18:32:17.789Z","dependency_job_id":null,"html_url":"https://github.com/Sword-Smith/hfasto","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/Sword-Smith%2Fhfasto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sword-Smith%2Fhfasto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sword-Smith%2Fhfasto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sword-Smith%2Fhfasto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Sword-Smith","download_url":"https://codeload.github.com/Sword-Smith/hfasto/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241975135,"owners_count":20051428,"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":["calling-conventions","compiler","functional-programming","mips-assembly","register-allocation"],"created_at":"2024-10-11T20:37:30.971Z","updated_at":"2026-05-10T18:02:51.846Z","avatar_url":"https://github.com/Sword-Smith.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Synopsis\n\nThe compiler compiles from Fasto to Mips assembly.\n\nThis is an attempt to port a compiler for the language Fasto from SML to\nHaskell. Small extensions to the language definition has been made such\nthat it for example is possible to write several declarations within a let\nstatement.\n\nTwo library functions are provided: read and write. They compile to system calls\ncompatible with the MARS implementation of the MIPS architechture.\n\n## Fasto Code Example\n\n### A recursive factorial function in Fasto\n```\nfun int fact(int n) =\n  if n == 0\n  then 1\n  else n*fact(n-1)\n\nfun int main() =\n  let n = read()\n      p = fact(n)\n  in write(p)\n```\n\n### A recursive Fibonacci function in Fasto\n```\nfun int fibo(int n) =\n  if n == 0 then 0\n  else if n == 1 then 1\n  else fibo(n - 1) + fibo(n - 2)\n\nfun int main() =\n  let n = read()\n      p = fibo(n)\n  in write(p)\n```\n\n## Modules\n\nThe compiler consists of the following modules\n\n1. FastoParser.hs\n   * Parses the fasto code and generates an abstract syntax tree (AST). The types in the AST are defined in the file Fasto.hs.\n2. FastoCodeGenerator.hs\n   * Takes the Fasto AST as input and creates another AST as output. The output AST is of an intermediate language type. The syntax of the intermediate language is defined in Imp.hs. It is a subset of the intermediate language defined in Torben Ægidius Mogensen's Introduction to Compiler Design.\n3. MipsCodeGenerator.hs\n    * Generates the symbolic machine code where an infinite number of registers\nare available but where calling conventions are observed. \n4. MipsRegAlloc.hs\n    * Translates from MIPS code with symbolic registers to MIPS code with actual \nregister names. The register names that in the input start with \"$\" are not\nmapped to real registers since these registers are already real registers which\nare set by the MipsCodeGenerator in order to observe the calling conventions.\n5. TypeChecker.hs \n    * Not yet being used by Main.hs. Should be inserted between the FastoParser.hs\nand the FastoCodeGenerator.hs modules.\n\n## Calling Conventions\n\nThe calling conventions found in http://www.cs.cornell.edu/courses/cs3410/2012sp/lecture/14-calling-w.pdf is followed at the moment.\n\n## Installation\n\nYou can run\n```\nstack install\n```\nor compile manually using\n```\nghc Main.hs\n```\nAnd the needed modules should also be installed manually.\n\n## Run the Files\n\nThe compiled assembly code can be run using the MARS MIPS Simulater available at\nhttp://courses.missouristate.edu/KenVollmar/MARS/\n\n## License\n\nThe project is released under the MIT license. See LICENSE.txt in the root\ndirectory.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsword-smith%2Fhfasto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsword-smith%2Fhfasto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsword-smith%2Fhfasto/lists"}