{"id":20204673,"url":"https://github.com/demiknight/coffeelang-pythoncompiler","last_synced_at":"2026-06-07T03:31:29.688Z","repository":{"id":118082445,"uuid":"410882055","full_name":"DemiKnight/CoffeeLang-PythonCompiler","owner":"DemiKnight","description":"Creating coffee language compiler from ANTLR ","archived":false,"fork":false,"pushed_at":"2021-11-05T12:52:23.000Z","size":172,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-13T20:44:01.186Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":false,"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/DemiKnight.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-27T12:49:33.000Z","updated_at":"2022-10-16T18:12:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"915ca919-4563-4c79-968d-47f386c828b0","html_url":"https://github.com/DemiKnight/CoffeeLang-PythonCompiler","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/DemiKnight%2FCoffeeLang-PythonCompiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DemiKnight%2FCoffeeLang-PythonCompiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DemiKnight%2FCoffeeLang-PythonCompiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DemiKnight%2FCoffeeLang-PythonCompiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DemiKnight","download_url":"https://codeload.github.com/DemiKnight/CoffeeLang-PythonCompiler/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241644544,"owners_count":19996177,"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":[],"created_at":"2024-11-14T05:14:28.851Z","updated_at":"2026-06-07T03:31:27.427Z","avatar_url":"https://github.com/DemiKnight.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Coffee Lang\n---\n\n- test/\n    - Unit tests for `semantics.py`\n- CoffeeLang/\n  - Result of `antlr -Dlanguage=Python3 -visitor ./Coffee.g4` \n\nTo test, inside `CoffeeLang` directory, run `grun Coffee program ../test.coffee -gui`\n\n# Tests\n- Run `pytest` \n\n## Semantic Rules \n1. Variables must be declared before use \n2. Variable declarations must have unique identifiers in a scope \n3. Method declarations (including imported methods) must have unique identifiers in a scope \n4. Method calls must refer to a declared method with an identical signature (return type, and number and type of parameters) \n5. Method calls referring to imported methods must produce a warning to check the argument and return types match that of the imported method \n6. Void methods cannot return an expression \n7. Non-void methods must return an expression \n8. The main method does not require a return statement, but if it has one, it must be of type int \n9. Branch statements (if-else) containing return statements do not qualify a method as having a return statement and a warning must be issued unless they appear in both the main branch and the else branch\n10. Loops containing return statements do not qualify a method as having a return statement and a warning must be issued \n11. The expression in a branch statement must have type bool \n12. The expression in a while loop must have type bool \n13. The low and high expressions in a limit must have type int \n14. Arrays must be declared with size greater than 0 \n15. The id in a for-loop must reference a declared array variable \n16. Arrays cannot be assigned during declaration \n17. Char expressions must be coerced to int \n18. The expression in an assignment must have type bool, int or float \n19. Locations of the from `\u003cid\u003e [ \u003cexpr\u003e ]` must refer to a declared array variable \n20. In a location, array indices must have type 'int' \n21. The expression in unary minus operation must have type int or float \n22. The expression in logical not operation must have type bool \n23. The expression(s) in an arithmetic operation must have type int or float \n24. The expression(s) in a logical operation must have type bool \n25. The singular expression in a block (expr) provides a valid return value for a method without requiring the return keyword \n26. Methods returning void cannot be used in an expression \n27. Break and continue statements must be contained within the body of a loop.\n\n#Coursework - Semantic \nSemantic Coursework Tasks 1 \u0026 2\n## Task 1 Method Invocation\n\nCreate a test source file with the following content:\n```c\nimport printf, printf; \nvoid foo(int x, int y) { \n  return 0; \n} \nint a = food(1, -2.0, 5);\n```\nUse the supplied Coffee compiler to discover the semantic errors.\ni) Identify all semantic errors (hint: rules 4, 6, 7, 26) in the above code and write code in your\nCoffeeTreeVisitor class to detect the errors.\n\n## Task 2 Arithmetic and Logic\nCreate a test source file with the following content:\n```c\nif (true \u0026\u0026 !1) { \n  return true; \n}\n```\n- Identify all semantic errors (hint: rules 8, 9, 11, 22) in the above code and write code in your\nCoffeeTreeVisitor class to detect the errors.\n\n# Coursework - CodeGen\nCodeGen Coursework Tasks 1 \u0026 2\n## Task 1 Expressions\ni) Arithmetic: Create a test source file with the following contents:\n```c\nint a, b;\na = 2 + 3 * 4; \nb = 5 - a % 10;\nreturn -(a + b);\n```\nWrite a solution which generates the correct assembly code and program output for the above Coffee code.\n\n# Task 3 Loops\ni) Limit / Step: Create a test source file with the following contents:\n```c\nint a = 0;\nfor (i in [1:10:2]) {\n  a = a + i;\n}\nreturn a;\n```\nWrite a solution which generates the correct assembly code and program output for the above Coffee\ncode.\nTip: in addition to visitFor for the loop, you will have to write visitAssign for the assignment of a + i;","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdemiknight%2Fcoffeelang-pythoncompiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdemiknight%2Fcoffeelang-pythoncompiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdemiknight%2Fcoffeelang-pythoncompiler/lists"}