{"id":16799409,"url":"https://github.com/georgesittas/minijava-compiler","last_synced_at":"2025-04-11T00:21:07.992Z","repository":{"id":159891484,"uuid":"409166134","full_name":"georgesittas/minijava-compiler","owner":"georgesittas","description":"MiniJava to LLVM IR compiler","archived":false,"fork":false,"pushed_at":"2023-03-09T02:32:56.000Z","size":854,"stargazers_count":14,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T21:05:17.872Z","etag":null,"topics":["compiler","java","jflex-cup","jtb","llvm","minijava","minijava-compiler","visitor-pattern"],"latest_commit_sha":null,"homepage":"","language":"LLVM","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/georgesittas.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":"2021-09-22T10:51:13.000Z","updated_at":"2024-08-31T11:32:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"21c67560-23f4-4d27-ae0e-1df2020fefca","html_url":"https://github.com/georgesittas/minijava-compiler","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/georgesittas%2Fminijava-compiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/georgesittas%2Fminijava-compiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/georgesittas%2Fminijava-compiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/georgesittas%2Fminijava-compiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/georgesittas","download_url":"https://codeload.github.com/georgesittas/minijava-compiler/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248318904,"owners_count":21083745,"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":["compiler","java","jflex-cup","jtb","llvm","minijava","minijava-compiler","visitor-pattern"],"created_at":"2024-10-13T09:28:45.501Z","updated_at":"2025-04-11T00:21:07.982Z","avatar_url":"https://github.com/georgesittas.png","language":"LLVM","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MiniJava Compiler\n\nThis is a [MiniJava](https://cgi.di.uoa.gr/~compilers/20_21/project.html#hw2) compiler that targets LLVM,\nwritten in Java with the help of JFlex, JavaCUP and JTB.\n\nI would like to thank [Stefanos Baziotis](https://github.com/baziotis) for contributing his [MiniJava\ntestsuite](https://github.com/baziotis/minijava-testsuite)!\n\n\n## Usage\n\n```bash\n# Compile the project\nmake\n\n# Run the compiler\njava Main file1 [file2 [file3 ...]]\n\n# Cleanup\nmake clean\n```\n\n## Implementation\n\n### Scoping \u0026 Symbol Table\n\nMiniJava is a simple language when it comes to scoping: all declarations precede statements.\nThis property prevents declarations from showing up in nested compound statements such as\nif-else, while and block statements. Thus, the symbol table need only keep track of class\ndeclarations, class-scoped declarations (i.e. fields and methods) and method-scoped declarations\n(i.e. formal parameters and local variables).\n\n### Compilation Phases\n\nWe start by producing an AST for the source program with the help of JFlex, JavaCUP and JTB. Then,\nwe check its semantics \u0026 finally generate the LLVM IR code with the help of the following visitor\nclasses:\n\n1. `STVisitor` populates the symbol table\n\n2. `SCVisitor` type checks the program\n\n3. `VTVisitor` populates the virtual method table\n\n4. `CGVisitor` generates the resulting LLVM IR code\n\n### Notes\n\n- The `MainClass` class and its `main` method are not handled as special cases. The method's\nargument is stored in the symbol table with type `String[]`, so, if it appears in any\nexpression in the program, a type error will be triggered by `SCVisitor` inevitably.\n\n- Scopes are implemented by constructing strings of the form `ClassID [\":\" [MethodID]]` and passing\nthem as arguments to children nodes as the visitors are walking the AST. \n\n- LLVM-IR code virtual registers are assigned names of the form `%_number`, where `number` is an\nauto-incrementing integer.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeorgesittas%2Fminijava-compiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeorgesittas%2Fminijava-compiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeorgesittas%2Fminijava-compiler/lists"}