{"id":20840794,"url":"https://github.com/joeyvanlierop/golf","last_synced_at":"2025-08-07T22:57:09.399Z","repository":{"id":143401437,"uuid":"614030969","full_name":"joeyvanlierop/golf","owner":"joeyvanlierop","description":"A simple compiler for a programming language called GoLF ⛳","archived":false,"fork":false,"pushed_at":"2024-11-04T16:54:21.000Z","size":454,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-08T22:06:35.285Z","etag":null,"topics":["code-generation","compiler","golang","lexer","parser","programming-language","semantic-analysis"],"latest_commit_sha":null,"homepage":"","language":"C++","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/joeyvanlierop.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,"zenodo":null}},"created_at":"2023-03-14T18:47:59.000Z","updated_at":"2025-02-23T20:01:44.000Z","dependencies_parsed_at":"2025-05-08T22:06:36.924Z","dependency_job_id":"2064b715-1247-4191-a4c3-dc407bb70c55","html_url":"https://github.com/joeyvanlierop/golf","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/joeyvanlierop/golf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeyvanlierop%2Fgolf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeyvanlierop%2Fgolf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeyvanlierop%2Fgolf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeyvanlierop%2Fgolf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joeyvanlierop","download_url":"https://codeload.github.com/joeyvanlierop/golf/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeyvanlierop%2Fgolf/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269338064,"owners_count":24400179,"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-07T02:00:09.698Z","response_time":73,"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":["code-generation","compiler","golang","lexer","parser","programming-language","semantic-analysis"],"created_at":"2024-11-18T01:17:48.777Z","updated_at":"2025-08-07T22:57:09.378Z","avatar_url":"https://github.com/joeyvanlierop.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# The GoLF Language\n\nThis is a stack-based, multi-pass compiler written in C++ for a programming language called GoLF. This was created as part of a term project for a course at the University of Calgary (CPSC 411) taught by John Aycock. If you are reading this and he is still teaching the course, enroll in it. Right now. Seriously.\n\n## Features\n\nYou can read through the whole specification [here](./SPECIFICATION.md). Otherwise, here are some short snippets of what you can do in GoLF:\n\n- GoLF has built-in functions:\n\n  - `printb(b bool)`: To print a boolean to the console,\n  - `printc(c int)`: To print a character to the console,\n  - `printb(i int)`: To print a number to the console,\n  - `printb(s string)`: To print a string to the console,\n  - `getchar()`: To receive user input,\n  - `len(s string)`: To get the length of a string,\n  - `halt()`: To halts the execution of the program,\n\n- GoLF has support for arithmetic operators: `+`, `-`, `/`, `*`, `%`\n\n- GoLF has support for comparison operators: `==`, `\u003c`, `\u003c=`, `\u003e=`, `\u003e`\n\n- GoLF has support for binary operators: `\u0026\u0026`, `||`\n\n- GoLF has support for unary operators: `!`, `-`\n\n- GoLF supports the `break` statement in loops\n\n## Building\n\nIn order to build and compile, you need to install `Make` plus the toolchain of your choice, e.g. `g++` or `clang`. After you setup `Make` with your toolchain of choice, clone the repository and build the project as follows:\n\n```shell\ngit clone https://github.com/joeyvanlierop/golf.git\ncd golf/\nmake\n```\n\n## Hello World\n\nTo run a \"hello world\" program, create a file named `hello-world.golf` on your computer, and place the following inside it:\n\n```go\nfunc main() {\n    prints(\"Hello, world!\\n\")\n}\n```\n\nThen, in a terminal window, navigate to the unzipped folder and run:\n\n```shell\n$ golf hello-world.golf\n```\n\n## The Classic Fibonacci Number Calculator:\n\n```go\nfunc main() {\n    var i int\n    i = 0\n\n    // Anything larger than 47 overflows a 32-bit int...\n    for i \u003c= 47 {\n        prints(\"fib(\")\n        printi(i)\n        prints(\") = \")\n        printi(fib(i))\n        prints(\"\\n\")\n        i = i + 1\n    }\n}\n\nfunc fib(n int) int {\n    if n == 0 { return 0 }\n    if n == 1 { return 1 }\n    return fib(n-1) + fib(n-2)\n}\n```\n\n\u003c!-- ### A Little Greeting Loop\n\n```go\nwhile true {\n    var name = input(\"Who are we greeting? \");\n    print(\"Hello there, \" + name + \"!\\n\");\n\n    if input(\"Greet again? (y/n): \") != \"y\" {\n        break;\n    }\n}\n``` --\u003e\n\n## Lifecycle of a GoLF Program\n\nGoLF programs get executed in four separate steps: lexing, parsing, semantic analysis, and code generation.\n\n- [**Lexing**](./src/lexer.cpp): The process of breaking down the source code into a stream of tokens, which represent the smallest units of meaning in the programming language.\n\n- [**Parsing**](./src/parser.cpp): The process of analyzing the sequence of tokens to construct an abstract syntax tree, which represents the structure of the program according to the rules of the programming language's grammar.\n\n- [**Semantic Analysis**](./src/semantic.cpp): Performs a series of checks on the abstract syntax tree to ensure that it conforms to the rules of the programming language, such as type checking, scoping, and name resolution.\n\n- [**Code Generation**](./src/code_gen.cpp): Transforms the abstract syntax tree into executable code, generating machine instructions or bytecode for a virtual machine.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoeyvanlierop%2Fgolf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoeyvanlierop%2Fgolf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoeyvanlierop%2Fgolf/lists"}