{"id":15101428,"url":"https://github.com/simomux/kaleidoscopecompiler","last_synced_at":"2026-01-08T01:51:18.780Z","repository":{"id":232155733,"uuid":"773859204","full_name":"simomux/KaleidoscopeCompiler","owner":"simomux","description":"Project for my front-end compilers exam A.Y. 2023-2024","archived":false,"fork":false,"pushed_at":"2024-06-09T12:39:33.000Z","size":484,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-05T11:49:51.564Z","etag":null,"topics":["ast","bison-flex","clang","kaleidoscope","llvm"],"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/simomux.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":"2024-03-18T14:22:36.000Z","updated_at":"2024-07-15T09:32:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"cc65a3aa-07cd-4d49-8962-e11bd821ca12","html_url":"https://github.com/simomux/KaleidoscopeCompiler","commit_stats":null,"previous_names":["simomux/progettocompilatori","simomux/kaleidoscopecompiler"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simomux%2FKaleidoscopeCompiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simomux%2FKaleidoscopeCompiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simomux%2FKaleidoscopeCompiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simomux%2FKaleidoscopeCompiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simomux","download_url":"https://codeload.github.com/simomux/KaleidoscopeCompiler/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246301999,"owners_count":20755514,"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":["ast","bison-flex","clang","kaleidoscope","llvm"],"created_at":"2024-09-25T18:22:53.993Z","updated_at":"2026-01-08T01:51:18.754Z","avatar_url":"https://github.com/simomux.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Assignment for my front-end compilers class A.Y. 2023-2024\n\n## Objective\n\nCreate a front-end compiler for Kaleidoscope extending the skeleton template from a modified version of the code from [My First Language Frontend with LLVM Tutorial](https://llvm.org/docs/tutorial/MyFirstLanguageFrontend/index.html).\n\nThe assignment is divided in 4 parts, each one giving you a grammar and reuqiring the implementation of it and of the necessaries AST nodes.\n\n### First level grammar\n\nFisrt part requires to implement assignment logic for variables.\n\n\u003cdetails\u003e\u003csummary\u003eGrammar\u003c/summary\u003e\n\n```bison\n% start startsymb;\n\nstartsymb:\n\tprogram \n\nprogram:\n\t% empty\n| top \";\" program % left \":\";\n\ntop:\n\t% empty\n| definition\n|\texternal\n| globalvar\n\ndefinition:\n\t\"def\" proto block\n\nexternal:\n\t\"extern\" proto\n\nproto:\n\t\"id\" \"(\" idseq \")\"\n\nglobalvar :\n\" global \" \"id\"\n\nidseq :\n\t% empty\n|\t\"id\" idseq\n\n%left \":\";\n%left \" \u003c\" \"==\";\n%left \"+\" \" -\";\n%left \"*\" \"/\";\n\nstmts :\n\tstmt\n|\tstmt \";\" stmts\n\nstmt :\n\tassignment\n|\tblock\n|\texp\n\nassignment\n\t\"id\" \"=\" exp\n\nblock:\n\t\"{\" stmts \"}\"\n|\t\"{\" vardefs \";\" stmts \"}\"\n\nvardefs:\n\tbinding\n| vardefs \";\" binding\n\nbinding:\n\t\"var\" \"id\" initexp\n\nexp:\n\texp \"+\" exp\n| exp \" -\" exp\n| exp \"*\" exp\n| exp \"/\" exp\n| idexp\n| \"(\" exp \")\"\n| \"number\"\n| expif\n\ninitexp:\n\t%empty\n| \"=\" exp\n\nexpif:\n \tcondexp \"?\" exp \":\" exp\n\ncondexp:\n\texp \"\u003c\" exp\n|\texp \"==\" exp\n\nidexp:\n\t\"id\"\n|\t\"id\" \"(\" optexp \")\"\n\noptexp:\n\t%empty\n|\texplist\n\nexplist:\n\texp\n| exp \",\" explist\n```\n\n\u003c/details\u003e\n\n\n### Second level grammar\n\nImplements rules and logic for `if` construct, `for` loops and initializations.\n\n```bison\nstmt:\n\tassignment\n| block\n| ifstmt\n| forstmt\n| exp\n\nifstmt:\n\t\"if\" \"(\" condexp \")\" stmt\n| \"if\" \"(\" condexp \")\" stmt \" else \" stmt\n\nforstmt:\n\t\"for\" \"(\" init \";\" condexp \";\" assignment \")\" stmt\n\ninit:\n\tbinding\n| assignment\n```\n\n### Third level grammar\n\nImplements boolean operators `and`, `or` and `not` for consecutive conditional expressions.\n\n```bison\ncondexp:\n\trelexp\n| relexp \"and\" condexp\n| relexp \"or\" condexp\n| \"not\" condexp\n| \"(\" condexp \")\"\n\nrelexp:\n\texp \"\u003c\" exp\n| exp \"==\" exp\n```\n\n### Fourth level grammar\n\nTODO\n\n```bison\nbinding:\n\t\"var\" \"id\" initexp\n| \"var\" \"id\" \"[\" \"number\" \"]\"\n| \"var\" \"id\" \"[\" \"number\" \"]\" \"=\" \"{\" explist \"}\"\n\nidexp:\n\t\"id\"\n|\t\"id\" \"(\" optexp \")\"\n|\t\"id\" \"[\" exp \"]\"\n\nassignment:\n\t\"id\" \"=\" exp\n|\t\"id\" \"[\" exp \"]\" \"=\" exp\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimomux%2Fkaleidoscopecompiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimomux%2Fkaleidoscopecompiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimomux%2Fkaleidoscopecompiler/lists"}